From patchwork Mon Dec 9 09:50:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13899187 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 D24A1E77181 for ; Mon, 9 Dec 2024 09:50:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 657318D0033; Mon, 9 Dec 2024 04:50:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B6DD8D0029; Mon, 9 Dec 2024 04:50:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E1778D0033; Mon, 9 Dec 2024 04:50:51 -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 0FB118D0029 for ; Mon, 9 Dec 2024 04:50:51 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B98BDA03AB for ; Mon, 9 Dec 2024 09:50:50 +0000 (UTC) X-FDA: 82874951292.14.4FD265E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id 1B9A980007 for ; Mon, 9 Dec 2024 09:50:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.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=1733737833; 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=aabiX5NnKb1HgBUNA27QTjCuXgUs5Hva7boPFb+v/xc=; b=Ur0CZdgfQJ+qRo5Cvkx+BY/U/voZo8DRoBYCbUCojkq4iZUJ8xjWK6vcLfL4yH9Q2Sk+8S 4KV5ZDvNZMy2OOHIrV21WAhzxnH+zDvntd15xU01mwB6CHGOjKJtFWglk9x64DwxlIbXsB R8K8ZT6DhqdWudJ5P5DF/wOo0Jz17Ow= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.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=1733737833; a=rsa-sha256; cv=none; b=LHL21HGtTCL+zbRdU4Mg1g2gMFXKMfzFGDYQXhLdeBBbJe19PezsZKpoh5O9KnIstU6wLR mGysyKgK9k+wSIsNZE4P5nk1qJ4+UOqD9A9kxGzbQY/OLqzk5el2ueyxs6gtitwjOMx8sA x32SWFEMkArCJVlrhVpS50jKTbcHHpc= 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 89FB5113E; Mon, 9 Dec 2024 01:51:16 -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 80A133F720; Mon, 9 Dec 2024 01:50:46 -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 04/14] selftests/mm: Fix -Warray-bounds warnings in pkey_sighandler_tests Date: Mon, 9 Dec 2024 09:50:09 +0000 Message-ID: <20241209095019.1732120-5-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-Rspamd-Queue-Id: 1B9A980007 X-Rspamd-Server: rspam12 X-Stat-Signature: z5gc19m953wz4mapmbbi6f1qjmbcc69a X-Rspam-User: X-HE-Tag: 1733737809-754200 X-HE-Meta: U2FsdGVkX18ztI4o8kCMpjDxxBghLl8lpiu+spBXOIVr+iBDQQLdeIKi7ZYXaQU5mHoXMEnvAQt2npfmtUA9VDLMMyclNxhX5FcT/KohcUQwxTHIxOkm9zZTcRNM+itmJRzBwusjG7NxEvwzpcslvbZQgMrabDnn6ghDgknT/ChukQEb/tD1KpSoeLoW5vPH0Zqn7QWTdiRTgexBQrNj7kYdmL/T+wjRH/xmTNLORfa4iXjAa8x4oNK2v/Qq+P3bCk8ayPX3JSot5MZw8fTOqQUdir1ysa6YVPhxHqbIifB7+N/lumKjP4xr+j5QW2Zp2khkyseKM8TWr3uaDk7ZBsTOcQnH7588JtCoyXAJPEX7YixMHHHsd1DCI7vL6iOo5/LkXoJMUTAdoV7/nBEv9GrVTXtMkgUKkndHUXVLsmwwvU+f7yu9ST750N48BZXzQtHQEd1iSgNil/nqcXtmyW1tlvXn8+GKBbiwvgAgZxDPCFv/a+L067Di/+yni90+KzEoOo0+K4kL72J+9WhFHQmjHIhzSIk0Wq8T2mrDSgG4yJRQPz77EX64NZuoiuvWq5T+jxErwmUUKMAMQYafREnDKTnm9ZDgAqqIRg35dHRU+RVlLKp0gZ8zB2MnQAKV9W9CDuypi9scGQBjAahUg/+rzsdY4HWljjtKcFhx2GB6lST4m3He651b5+YQwP+owhG4nlio8/BGcysGuZmC+KqhHcQru5rFcCjfT7WBBGK6CDJUx8w8OvVK/Dqk/voUa2grgfQf44qCaWgrRaJ0vVBMlMrXxTD7lOHBvNp/9lR+8H8W5vREuGucL2F2ZC9SZ+SEPvVDDXx4fT2iTPL9FRJLfkSs4b642nD7AZ6Yj5tqBQy5cVheXjoBfOt5iQQphICp7swOok8P7hjtx8qBIrDRFwg3NC1sWCoC0DA+tvIxCq+a/eU5kmutVWzXGimgQ5Jb6zMY2o3AJBufxJK DrF9oN5R PEEXdcYrmVRelr+QQKT+v/41MIB3dGCHWdblqYunXQR8EXUoPK5CXlEhMHj12PH4T6DE6j5QT7lqVF9bKFdeU5POMzeZpe4EAhUCde3j0vV7dyUv0ks2YfaX3xuSnsw8w9WGx3JZZBwjD0WJ79RQS645EmhoIzr0Iqxd2N7dap29nA6Ln4UPzW5ZPgf7F9t51ryybhICC5WW8odnSlsnb01oCXjCNQV2uR8qNEIZkh2kzbcq0o9aX27Q9CIl2dHAD7KhwMCtdMa+fZ4ip0IDctv0dj4axiiUKzPXbN0TfZiseTfOJfICBmHu04KLaZOwVX4T4 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: GCC doesn't like dereferencing a pointer set to 0x1 (when building at -O2): pkey_sighandler_tests.c:166:9: warning: array subscript 0 is outside array bounds of 'int[0]' [-Warray-bounds=] 166 | *(int *) (0x1) = 1; | ^~~~~~~~~~~~~~ cc1: note: source object is likely at address zero Using NULL instead seems to make it happy. This should make no difference in practice (SIGSEGV with SEGV_MAPERR will be the outcome regardless), we just need to update the expected si_addr. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pkey_sighandler_tests.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index c593a426341c..e7b91794f184 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -163,7 +163,7 @@ static void *thread_segv_with_pkey0_disabled(void *ptr) __write_pkey_reg(pkey_reg_restrictive_default()); /* Segfault (with SEGV_MAPERR) */ - *(int *) (0x1) = 1; + *(int *)NULL = 1; return NULL; } @@ -179,7 +179,6 @@ static void *thread_segv_pkuerr_stack(void *ptr) static void *thread_segv_maperr_ptr(void *ptr) { stack_t *stack = ptr; - int *bad = (int *)1; u64 pkey_reg; /* @@ -195,7 +194,7 @@ static void *thread_segv_maperr_ptr(void *ptr) __write_pkey_reg(pkey_reg); /* Segfault */ - *bad = 1; + *(int *)NULL = 1; syscall_raw(SYS_exit, 0, 0, 0, 0, 0, 0); return NULL; } @@ -234,7 +233,7 @@ static void test_sigsegv_handler_with_pkey0_disabled(void) ksft_test_result(siginfo.si_signo == SIGSEGV && siginfo.si_code == SEGV_MAPERR && - siginfo.si_addr == (void *)1, + siginfo.si_addr == NULL, "%s\n", __func__); } @@ -349,7 +348,7 @@ static void test_sigsegv_handler_with_different_pkey_for_stack(void) ksft_test_result(siginfo.si_signo == SIGSEGV && siginfo.si_code == SEGV_MAPERR && - siginfo.si_addr == (void *)1, + siginfo.si_addr == NULL, "%s\n", __func__); }