From patchwork Tue Jun 15 20:02:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12322803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5119C48BDF for ; Tue, 15 Jun 2021 20:04:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 52DA6600EF for ; Tue, 15 Jun 2021 20:04:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52DA6600EF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E91BD6B006C; Tue, 15 Jun 2021 16:04:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E420D6B0071; Tue, 15 Jun 2021 16:04:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D31856B0072; Tue, 15 Jun 2021 16:04:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id A0C1A6B006C for ; Tue, 15 Jun 2021 16:04:31 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 335E68249980 for ; Tue, 15 Jun 2021 20:04:31 +0000 (UTC) X-FDA: 78257035542.39.6768C75 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 9CEAFA00024C for ; Tue, 15 Jun 2021 20:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/K2Rbrzi1/a5V8QQAme7rORjMQWprXhWq5HBHnlzt3E=; b=s/N+K1g5DM8AgZGy7u1xVvIxeh Bk5azVJ9VdGx43q6LOhrQoz3bNZtGuh1POvg8pTRyNm5tDrk9b1CmA1ks5IEf7NmLEebU6j5r7ZpH UW+UqcP4XtWXKoqWUGNVulaEspPqno9A+llqvZEPQ9uMvthGGc0wOoNvMcPaylE7lpR2AsLvAJ1O2 8TN+HTheOcqzTg6qRFrTz+n/e9PDnwHo5+E6J2z5lsV9EliBu2+LN5GhfOoTVh+7HgGVMkNZJ9M76 OY2E6iKBM5xnxtCXn/2T8sgua8djG+O6OJ481TNrHxiVB1W1a6ngetvTMNzULUrsrYZXHZLsI3eRg 2ucRcIVw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltFHh-007CcK-Or; Tue, 15 Jun 2021 20:03:47 +0000 From: "Matthew Wilcox (Oracle)" To: akpm@linux-foundation.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 3/5] mm/thp: Fix strncpy warning Date: Tue, 15 Jun 2021 21:02:40 +0100 Message-Id: <20210615200242.1716568-4-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210615200242.1716568-1-willy@infradead.org> References: <20210615200242.1716568-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="s/N+K1g5"; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Stat-Signature: 17e6skujts8km51zmeca6iurcbwjypcw X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9CEAFA00024C X-HE-Tag: 1623787462-205156 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Using MAX_INPUT_BUF_SZ as the maximum length of the string makes fortify complain as it thinks the string might be longer than the buffer, and if it is, we will end up with a "string" that is missing a NUL terminator. It's trivial to show that 'tok' points to a NUL-terminated string which is less than MAX_INPUT_BUF_SZ in length, so we may as well just use strcpy() and avoid the warning. Signed-off-by: Matthew Wilcox (Oracle) --- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 503c8e1aecc6..d513b0cd1161 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3101,7 +3101,7 @@ static ssize_t split_huge_pages_write(struct file *file, const char __user *buf, tok = strsep(&buf, ","); if (tok) { - strncpy(file_path, tok, MAX_INPUT_BUF_SZ); + strcpy(file_path, tok); } else { ret = -EINVAL; goto out;