From patchwork Mon Dec 9 09:50:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899228 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1009BE7717D for ; Mon, 9 Dec 2024 09:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TXhOkF+BRkbjEZRD727KKe3G5fsf3ooidZDOS5wP8XY=; b=NTbfmhWZCPLCTfTVu6n00HOARF +ad7Barqi9Lzz6Gq3g0ro2lmNikyO6X1e6zhkQ4lY441V03kGIo9riF8kOD1+OfH7JqBlPBMkX8S5 FkTcDl4ht4fzBMaLsQjKEQ+xy/1onoE9px0E4xIXya9kyRe9Fh1MRArOvZC9YLjNbxJRIMXU19v91 0xq7CluE8A0ugn48oG6J+wRr8MtYrqJqIXMlODcWWX55ngG0gZlAF4l8HY4p/qyBL6O5PlxvB9KJ8 9Cr+MJjNggtBeHi2MQW8uPKd0T0guN/IhAla/HShZTUWVsy+j3PhE4o8wJMb4gCRb0lJAxeuTulau FTWkCD9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKaXj-00000007BoB-3wxQ; Mon, 09 Dec 2024 09:59:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKaPe-000000079FU-2Zay for linux-arm-kernel@lists.infradead.org; Mon, 09 Dec 2024 09:50:49 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 44BAB143D; Mon, 9 Dec 2024 01:51:14 -0800 (PST) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3B6F33F720; Mon, 9 Dec 2024 01:50:44 -0800 (PST) From: Kevin Brodsky To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , akpm@linux-foundation.org, aruna.ramakrishna@oracle.com, catalin.marinas@arm.com, dave.hansen@linux.intel.com, joey.gouly@arm.com, keith.lucas@oracle.com, ryan.roberts@arm.com, shuah@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, x86@kernel.org Subject: [PATCH 03/14] selftests/mm: Fix strncpy() length Date: Mon, 9 Dec 2024 09:50:08 +0000 Message-ID: <20241209095019.1732120-4-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241209095019.1732120-1-kevin.brodsky@arm.com> References: <20241209095019.1732120-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241209_015046_713542_092ACD71 X-CRM114-Status: GOOD ( 10.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org GCC complains (with -O2) that the length is equal to the destination size, which is indeed invalid. Subtract 1 from the size of the array to leave room for '\0'. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/write_to_hugetlbfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/write_to_hugetlbfs.c b/tools/testing/selftests/mm/write_to_hugetlbfs.c index 1289d311efd7..34c91f7e6128 100644 --- a/tools/testing/selftests/mm/write_to_hugetlbfs.c +++ b/tools/testing/selftests/mm/write_to_hugetlbfs.c @@ -89,7 +89,7 @@ int main(int argc, char **argv) size = atoi(optarg); break; case 'p': - strncpy(path, optarg, sizeof(path)); + strncpy(path, optarg, sizeof(path) - 1); break; case 'm': if (atoi(optarg) >= MAX_METHOD) {