From nobody Mon Feb 9 15:31:23 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A67CB2741DF for ; Wed, 28 May 2025 08:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748422529; cv=none; b=Ii9Au380rhCAAlzAb6WxmQY2+GK7pOWA57XPFzilXCS+/WgIcwj4HXOOdKsG26tuotltr3luVRV07W2CUHSH+O0i6KLoyLd7pFlJVnhdYr+4sFzTCowl9txqvqejneYQIKLhVb3XU8xjKMOtfb7JCwt4rHHeayoxKZYg3FXRqBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748422529; c=relaxed/simple; bh=1il/dB19ylyruXfeVF0bzVE5iRhTAf5MNLxEdiYkhO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VDcTsl9inCkeueBD1DkyRP4Hm349vI3O0+iPGXD3LDbp5BI6Ios5zxsKsmREXwvGD/7UckiinSDt7NVQR/rkc8d7DyGgmvL3qaF7AyLY7Any3H9fUMlVty1oHDia5NoQDZ0GPpNKR1DZOsjXdS5K5YYsi5H9cUXR2Tp7D39ihVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4vZp7oAz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VRsyKGyV; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4vZp7oAz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VRsyKGyV" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1748422525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bq4F0YaCcYiesX5BYOqiqK340+o2Iuxu8rVBteNA9h0=; b=4vZp7oAzVnXmjXpcr6iL1OVQMKK6Q+C58VcAKmbiu5SsRp+vB3ke/G7S9JazUK1pmvqM6K HZ6yy2Cgdc2zJoz4ihIXHMQeSe80fcp+ms7wTJyexOJK884JUBJvsXfhBofyIqzjgmgOKg L/JsWDsOIcSuZ8Ji2fnrqszXW22USQ/R/0tLXOaszCopBpQTKNKlbGVICL1bP90vei1Bk/ yamGXjMBY5No4BSHOXO1U2mmWHZck8Ud6oMqOcPNIO2HACts+jtMRYVOjmS/DKl1TMAfW/ EQWIdE+k2oiRwZ2GDhBkXUw1YvvkHRJcJKI8HLP/apkLuKLBr0GMDYNexahX+g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1748422525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bq4F0YaCcYiesX5BYOqiqK340+o2Iuxu8rVBteNA9h0=; b=VRsyKGyVUpUFH2kDQrww8HjCXWjyTP/KE2Bp6Cj6RqbKPzmMJxwhWtUxS/dOkDPd3wxW6K dIikHcOdrxHCDoCA== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , Sebastian Andrzej Siewior , Mark Brown Subject: [PATCH 1/3] selftests/futex: getopt() requires int as return value. Date: Wed, 28 May 2025 10:55:19 +0200 Message-ID: <20250528085521.1938355-2-bigeasy@linutronix.de> In-Reply-To: <20250528085521.1938355-1-bigeasy@linutronix.de> References: <20250528085521.1938355-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Mark reported that futex_priv_hash fails on ARM64. It turns out that the command line parsing does not terminate properly and ends in the default case assuming an invalid option was passed. Use an int as the return type for getopt(). Reported-by: Mark Brown Closes: https://lore.kernel.org/all/31869a69-063f-44a3-a079-ba71b2506cce@si= rena.org.uk/ Fixes: 3163369407baf ("selftests/futex: Add futex_numa_mpol") Fixes: cda95faef7bcf ("selftests/futex: Add futex_priv_hash") Signed-off-by: Sebastian Andrzej Siewior --- tools/testing/selftests/futex/functional/futex_numa_mpol.c | 2 +- tools/testing/selftests/futex/functional/futex_priv_hash.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/t= ools/testing/selftests/futex/functional/futex_numa_mpol.c index 20a9d3ecf7433..564dbd02d2f46 100644 --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) struct futex32_numa *futex_numa; int mem_size, i; void *futex_ptr; - char c; + int c; =20 while ((c =3D getopt(argc, argv, "chv:")) !=3D -1) { switch (c) { diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/t= ools/testing/selftests/futex/functional/futex_priv_hash.c index 2dca18fefedcd..24a92dc94eb86 100644 --- a/tools/testing/selftests/futex/functional/futex_priv_hash.c +++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c @@ -130,7 +130,7 @@ int main(int argc, char *argv[]) pthread_mutexattr_t mutex_attr_pi; int use_global_hash =3D 0; int ret; - char c; + int c; =20 while ((c =3D getopt(argc, argv, "cghv:")) !=3D -1) { switch (c) { --=20 2.49.0 From nobody Mon Feb 9 15:31:23 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7DA9274648 for ; Wed, 28 May 2025 08:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748422529; cv=none; b=YsKTKeeKDB3cJc+KAyyQmO9ALx4a+t9ho6ZRzIqk22criAWy41isqCHSj9OoUhohbPoM+ucsORzQGBZL4HbfkO8YoM3NH9DEiCF52bHtPuoob2G9nOnWwlPOQ/3aTlJ/ZhHTwJStoVNje4rI8wdG/TS37tt6KkDJV0dXciLt2Kg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748422529; c=relaxed/simple; bh=ZgnsrQ43S4L70fg/UsiHrN3kFf5lABAXCfemPqc403o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ri4g1W6Kz2tcERIkX4noSsAvLybQ22GzViqu4jthFM0c/2uTYwNy3hDou9r5AKSg7rwhIejXyyotpHxF/emRAxUxcwKb3P/Bg/Hxd2vi6Y58jKitKuWQIoMvxvCwK1332FeNf0K+1+NAmkutrBsXv6qx/fQwc82KTsAugDR8pJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=XTjDeBrk; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=V65f/+4y; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XTjDeBrk"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="V65f/+4y" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1748422526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tnE55vTMy7qpHVnuymQd+6282kdfSCrwu3U5LR8Xz3c=; b=XTjDeBrkSC95AMhoeYnAh4im6U9OAULZbAKMktELr4DBL4wey2Lc0M4t/elFwakqblHh48 /eX25P9bY9o6pg+7QoAncRmJ2ePkQJCW8NbX6qAzLtJkmNo7t3EB4fAc8BpCiBjp6tbM/d O6SrSIEwq4tx0I2/vMvEzaZ7+Ou47+JOQ5a3KNGqV41wy0WTD2q590MU1iIPhVKNaNeQtD iidXatTFtZXHwZ8UIHYAZ5O5pMsH4rg2atLOmzEQBbVwZ5SFzqRWm/tUhbcT7PipxXuh9C G1gfiuoRL5VD/ky73D4geVk0vj73WOs7T16aSggpPXfZtLWW09KhrdogVnVUFg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1748422526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tnE55vTMy7qpHVnuymQd+6282kdfSCrwu3U5LR8Xz3c=; b=V65f/+4ysIjvk+ceIFgmE0vMjHEH94Z6H29I2fIsE3gWa7UaXXOJGL3Ru0+e5TYcdK/mRe XoraH6rGoIHhsZBg== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , Sebastian Andrzej Siewior , Vlastimil Babka Subject: [PATCH 2/3] selftests/futex: Set the home_node in futex_numa_mpol Date: Wed, 28 May 2025 10:55:20 +0200 Message-ID: <20250528085521.1938355-3-bigeasy@linutronix.de> In-Reply-To: <20250528085521.1938355-1-bigeasy@linutronix.de> References: <20250528085521.1938355-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The test fails at the MPOL step if multiple nodes are available. The reason is that mbind() sets the policy but the home_node, which is retrieved by the futex code, is not set. This causes to retrieve the current node and with multiple nodes it fails on one of the iterations. Use numa_set_mempolicy_home_node() to set the expected node. Use ksft_exit_fail_msg() to fail and exit in order not to confuse ktap. Fixes: 3163369407baf ("selftests/futex: Add futex_numa_mpol") Suggested-by: Vlastimil Babka Signed-off-by: Sebastian Andrzej Siewior --- .../testing/selftests/futex/functional/futex_numa_mpol.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/t= ools/testing/selftests/futex/functional/futex_numa_mpol.c index 564dbd02d2f46..a9ecfb2d3932a 100644 --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c @@ -210,6 +210,10 @@ int main(int argc, char *argv[]) ret =3D mbind(futex_ptr, mem_size, MPOL_BIND, &nodemask, sizeof(nodemask) * 8, 0); if (ret =3D=3D 0) { + ret =3D numa_set_mempolicy_home_node(futex_ptr, mem_size, i, 0); + if (ret !=3D 0) + ksft_exit_fail_msg("Failed to set home node: %m, %d\n", errno); + ksft_print_msg("Node %d test\n", i); futex_numa->futex =3D 0; futex_numa->numa =3D FUTEX_NO_NODE; @@ -220,8 +224,8 @@ int main(int argc, char *argv[]) if (0) test_futex_mpol(futex_numa, 0); if (futex_numa->numa !=3D i) { - ksft_test_result_fail("Returned NUMA node is %d expected %d\n", - futex_numa->numa, i); + ksft_exit_fail_msg("Returned NUMA node is %d expected %d\n", + futex_numa->numa, i); } } } --=20 2.49.0 From nobody Mon Feb 9 15:31:23 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 203DE274650 for ; Wed, 28 May 2025 08:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748422529; cv=none; b=pLAoFG/kayRJfi6st3t5M0Dx6HGl4Qm5N+b9uxqQfasO9s8Wgnkv423SXo+EokKdiX+godqw2LlBFvLIdSObhPVgyuJvRryCAJZLhvguSvpyxASy5i3Yy4AO3P+5V+OlH/h6O71DWWgZzKZna8Xo6+X+sME3kx6Bd19F2fBsjsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748422529; c=relaxed/simple; bh=gG92xEH34NEWfZ8s9BqsyAZsrJjNEhovX+4zgItkEco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hdGuS9eINHoJlZqjS8Dm4zToKsejN++XRDIpX/NFQHjNPNQgsLWcub5i5mLurMZmEQhkRgiw/u5KyCwSrGyx0kuQaQvy6CIPyYNesChJdb9QFA/lKkPS8ASfIXq51QE/m+In7sPuiGu6Ub6P7tk1DBDBnxVpyClgfSZ8Xqsh0IM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=XmuaOal6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VmKWr++m; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XmuaOal6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VmKWr++m" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1748422526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KP9HvpgVHgWnTIXnNHgTJzo+gF4B7NnJsWc70Z9S1Pc=; b=XmuaOal6nFti4ocGc4QJbLpdSuuQkmCKbLmyT1+lIYs2D0VC/VTP7oDnZFCg9EJzfT4Go6 0mU1628otu8MNHmi4r3Z+7TW+vOj1k4wVQ6Xuob+QlKycUk1GimAUcY9imn3IKupMfBo6u piogVWRNTU7f1dH/JWh3qN7+t/SMZi79BXwRkb2S2+3xo91gbwXPE2qyFOxnIBCoQlwctl 5XH84JL2j6HuIFIa/N3QbkLrgJaQGfqDGCh0n/VobOo8sAXFqENoIbgyMc1PgZcJqsGR4K dTsFrhVyOcdU6BhSZ6Jgt19RMYvp6wnt6urUkhGs2wGW5RQZX1oUKyHBkCR6kA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1748422526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KP9HvpgVHgWnTIXnNHgTJzo+gF4B7NnJsWc70Z9S1Pc=; b=VmKWr++mLJ84NxOefqHyQSXBxmTzn7gUnWGglZfxR1seI0rDmBj/y3kBCXbU1YY7Aplt5b BEAhhHlqLQGd3dCQ== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , syzbot+9afaf6749e3a7aa1bdf3@syzkaller.appspotmail.com, Sebastian Andrzej Siewior Subject: [PATCH 3/3] futex: Handle invalid node numbers supplied by user Date: Wed, 28 May 2025 10:55:21 +0200 Message-ID: <20250528085521.1938355-4-bigeasy@linutronix.de> In-Reply-To: <20250528085521.1938355-1-bigeasy@linutronix.de> References: <20250528085521.1938355-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Zijlstra syzbot used a negative node number which was not rejected early and led to invalid memory access in node_possible(). Reject negative node numbers except for FUTEX_NO_NODE. [bigeasy: Keep the FUTEX_NO_NODE check] Reported-by: syzbot+9afaf6749e3a7aa1bdf3@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/6835bfe3.a70a0220.253bc2.00b5.GAE@googl= e.com/ Fixes: cec199c5e39bd ("futex: Implement FUTEX2_NUMA") Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Sebastian Andrzej Siewior --- kernel/futex/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/futex/core.c b/kernel/futex/core.c index 19a2c65f3d373..1cd3a646c91fd 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -583,8 +583,8 @@ int get_futex_key(u32 __user *uaddr, unsigned int flags= , union futex_key *key, if (futex_get_value(&node, naddr)) return -EFAULT; =20 - if (node !=3D FUTEX_NO_NODE && - (node >=3D MAX_NUMNODES || !node_possible(node))) + if ((node !=3D FUTEX_NO_NODE) && + ((unsigned int)node >=3D MAX_NUMNODES || !node_possible(node))) return -EINVAL; } =20 --=20 2.49.0