From patchwork Wed Dec 18 15:36:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13913872 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49060E77187 for ; Wed, 18 Dec 2024 15:36:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6330E6B009E; Wed, 18 Dec 2024 10:36:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E3676B00A0; Wed, 18 Dec 2024 10:36:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F8ED6B00A2; Wed, 18 Dec 2024 10:36:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 330296B009E for ; Wed, 18 Dec 2024 10:36:34 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E656F1A0DA0 for ; Wed, 18 Dec 2024 15:36:33 +0000 (UTC) X-FDA: 82908480354.01.87EA5B3 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 0C2F71C0017 for ; Wed, 18 Dec 2024 15:35:30 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734536162; a=rsa-sha256; cv=none; b=O7Vye0xqUXhdZBm0DSNIUFdATXuVc93UUuKZAQp48ab9qQO51ZnuoEihU6L0bNLqapss8I Hlp6FFz8EqgeEyFhWR7hQWe0AMbaNXdXnRd28vzrUPH7nZrI6/QbtVq8I4F6JTyDhtuJ7R jihZ060I8RevFjFQO8M0v/9xowFeJdo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734536162; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ek1bSpTwItKNd3Ic8QlEpJYptCCTpK1qsHK9ezTvxFU=; b=tKf1+8Vg5/6l6I0j5L8jOfvDzgX0tEF8CW/9JRkFF78AhKVKccMqBULG0KWiCICfbYaHiq L2WkUP+Wshhh+wYHeEeHRhzW7lj/pWQ5k12dNOXSlkgok3cj8xl0YCnerUJxScWR9Abku7 R4IwXfCItfx9NU91Pt3hh6hAGpR1UTM= 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 2D04C497; Wed, 18 Dec 2024 07:36:59 -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 D82623F7B4; Wed, 18 Dec 2024 07:36:28 -0800 (PST) From: Kevin Brodsky To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , kernel test robot , 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, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH] selftests/mm: Fix -Wnull-dereference on Clang Date: Wed, 18 Dec 2024 15:36:15 +0000 Message-ID: <20241218153615.2267571-1-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241209095019.1732120-5-kevin.brodsky@arm.com> References: <20241209095019.1732120-5-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Stat-Signature: yso5iuustcx5spu5yrboegnpqomonwi1 X-Rspam-User: X-Rspamd-Queue-Id: 0C2F71C0017 X-Rspamd-Server: rspam08 X-HE-Tag: 1734536130-425920 X-HE-Meta: U2FsdGVkX1+OXWnKv7nDh7/X8j7Qx7mCPVoThGyKr1Y5qEvuGk0APxch3rqYG3W1ParZnxLTnkoEByWWaNTxpMSBri5vL67S54HvRamRU2G/7VNtINqGHjb/cAK4i/fDKYyeCoITL8lUyOI/CUfUezSQobDIRr9GWET9P0PAsyZwcooWbci/gPEMX6g8KJn5nE0dx8YT10LIGW1M3a9GV5l6Go0TaNP/m1wD6n44Lr+lRekpbf+g8Ad60cy+dx6lRbCG8R7CuEOfZlktfccCALveM7aNByJMqeCEHHh8E39x3Gsf3kCkHNMNEwqZ3zNjtTIGUyTDw1gCb/NCTK7P6G7L87rYeB0bFnzIG0xnnDKTmzPfPzGyuk/hpwKfeuJ1xclhX5bxc7fz8BqDXfpLRFFxg2prACnCk5W2j7byLS+l+MU6bMmMosy/WT5fzg4wILy+hjStViuCisXiK/zHToWADVz9niFeZUOjkTetVE73fFiSiy2gjQ0FPkImk9LQx7O5kK+bIVCY5roolPbJ0YZ4dRhWcfa5xCcW3+lJXGQvFwUM3+zlvTB9XnJ6HVXFZP5JQDiGWm+xHnXSFzeKAF+kHtepkgz1ay5gpTWP8qyWB0tzbteYWR/6S7xEXe3ChWsmz7BZjSRQQMOtn2/lhjSRPbXL8xLhYdf8bX1NeWvizb+Gm0s+CKyzv7AHru+v4IT1LqJYkeLf6yB+PF3hJQn1LKRrhmW9zjD7rouO2hEwisEhFgWxVP7eKoSXadGDNzNqzmBaE7wHDbA5nlsmpa47MHVLja5q3sYHKmXkLETdDxsQA+8Ep6xFofRgXCb3cFn8FP4yjPylrOhtp8zP/JQLeQCmMedeRfUOBMsBeNi6lAOPqN9EnOI4a0xNisNiD2UNHSuYpl+Gn0OAcl87hWfRAK92sBFT9N2L8uxcuYuZ2inH2f/C9Y/3v222U5USUpCX/eMTDvVgTfdFMo3 I30ez93W 3stG8bagg4kVAWx4pI49ukSbkF3yeb07qOP783s+qsRpfH9tMB1Wv4CKsT1Hs9rnaLwDtQs+xsyq7ljbH2VcNqOCWYQNg1BL119mMjWg5CJyJfZSvD/WcR8naP1O/Ss99YtJ3lCfUEaLYvUvkMOFMbgl5up5+LwBW08Ki0WHmjYlDbOLH/DM7O2P8zeyApGxdydn6TKjyUmiXRohmkiKaDPntiLhBedn22yg54cnSUY2naMFjz28wJ2HZ+bpTy2f2/nU8NeClS4Ia9iFV6OTyMnx50a0QrBSJwNcZIk1wMgJiHXHIjX5/aqKnWfvsIler3lqV9m1TypTXIPeNf6CH1db+CW99Ih25VcaaaLYmVK15UZbzjdP4D0Fqx1/FahhucdStwQ9tON8uR9V85ZtzFBvIHKeICT56KZDwmQo0YwLr9GdeV62A8S8FLw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Dereferencing a null pointer on Clang is not a good idea - it will entirely optimise out the dereference. Make the pointer volatile to force the access (and fault). Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202412140850.4TW4YBqc-lkp@intel.com/ Signed-off-by: Kevin Brodsky --- Hi Andrew, Another fixup for an issue reported by the LKP CI (building with Clang instead of GCC). This should be squashed into the patch I'm replying to: "selftests/mm: Fix -Warray-bounds warnings in pkey_sighandler_tests" Cheers, - Kevin Cc: aruna.ramakrishna@oracle.com Cc: catalin.marinas@arm.com Cc: dave.hansen@linux.intel.com Cc: joey.gouly@arm.com Cc: keith.lucas@oracle.com Cc: ryan.roberts@arm.com Cc: shuah@kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kselftest@vger.kernel.org Cc: linux-mm@kvack.org Cc: x86@kernel.org --- tools/testing/selftests/mm/pkey_sighandler_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index 17bbfcd552c6..1ac8c8809880 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -161,7 +161,7 @@ static void *thread_segv_with_pkey0_disabled(void *ptr) __write_pkey_reg(pkey_reg_restrictive_default()); /* Segfault (with SEGV_MAPERR) */ - *(int *)NULL = 1; + *(volatile int *)NULL = 1; return NULL; } @@ -192,7 +192,7 @@ static void *thread_segv_maperr_ptr(void *ptr) __write_pkey_reg(pkey_reg); /* Segfault */ - *(int *)NULL = 1; + *(volatile int *)NULL = 1; syscall_raw(SYS_exit, 0, 0, 0, 0, 0, 0); return NULL; }