From nobody Sun Oct 5 03:35:58 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 F20011F4E34 for ; Sun, 10 Aug 2025 22:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754864881; cv=none; b=VSDtkJcJA67ZvB8N7qFwc708wUT+DnI72h5oZEfHzRyr03btqzzOJKREMBLzeR9A8FXwvhf4jmb8IC3AStJn2u4PdbyKqp5TEsOkmTaims4CUvK37s8taSXvHuWxglyyr+nGT76MuRXiA+SJ4hp9IszeGlVFSDMq4EBSgfid2ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754864881; c=relaxed/simple; bh=wIrlwbnuKnkPYVbgME8ikSpgK/+Ts/tGiac5ibXXP7I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=m0O95Y6FmMPW+vYHvt44csI/XdK0JngXtGFPL2jOh919zKOV2s6C5/sQ3G98fBmc18H93XOazqWFlBY4WqOtd6tnIra0hUKIxmLQI+cV5vP+tNfmBqxS2Vgfar9GQc2OmSKsMt2mZN9thi1hfIb9TfetD2bwv6aolseFcN7w0hU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OoMmZRHY; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OoMmZRHY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754864878; 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; bh=1q12txHUQPg0R1RQNr4oGF8yA7IDYgf7jDtfYZA93xY=; b=OoMmZRHYAyfbi463+3W78HCgiC9AqiZiqt+oQjyXrkNt82Sp+f6tAR/ewrwONCMKr7C0v6 AwWO9KMhtI7K4gtjU+rBn7ed7JQgJ4Hs1GBCvWYIjXg4Wc2KwKQ0KhXoNYkwx0qXMMDI7l xElUUOglFp6ySPfbyGyNlaNhox+pCaw= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-250-bYpDTESUNLapYYdAG5EtPQ-1; Sun, 10 Aug 2025 18:27:53 -0400 X-MC-Unique: bYpDTESUNLapYYdAG5EtPQ-1 X-Mimecast-MFC-AGG-ID: bYpDTESUNLapYYdAG5EtPQ_1754864871 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CDDA419560AD; Sun, 10 Aug 2025 22:27:49 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.80.59]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B844D1800280; Sun, 10 Aug 2025 22:27:46 +0000 (UTC) From: Waiman Long To: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Sebastian Andrzej Siewior , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Colin Ian King , Waiman Long Subject: [PATCH] selftests/futex: Fix some futex_numa_mpol subtests Date: Sun, 10 Aug 2025 18:27:42 -0400 Message-ID: <20250810222742.290485-1-longman@redhat.com> 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" The "Memory out of range" subtest of futex_numa_mpol assumes that memory access outside of the mmap'ed area is invalid. That may not be the case depending on the actual memory layout of the test application. When that subtest was run on an x86-64 system with latest upstream kernel, the test passed as an error was returned from futex_wake(). On another powerpc system, the same subtest failed because futex_wake() returned 0. Bail out! futex2_wake(64, 0x86) should fail, but didn't Looking further into the passed subtest on x86-64, it was found that an -EINVAL was returned instead of -EFAULT. The -EINVAL error was returned because the node value test with FLAGS_NUMA set failed with a node value of 0x7f7f. IOW, the futex memory was accessible and futex_wake() failed because the supposed node number wasn't valid. If that memory location happens to have a very small value (e.g. 0), the test will pass and no error will be returned. Since this subtest is non-deterministic, it is dropped unless we explicitly set a guard page beyond the mmap region. The other problematic test is the "Memory too small" test. The futex_wake() function returns the -EINVAL error code because the given futex address isn't 8-byte aligned, not because only 4 of the 8 bytes are valid and the other 4 bytes are not. So proper name of this subtest is changed to "Mis-aligned futex" to reflect the reality. Fixes: 3163369407ba ("selftests/futex: Add futex_numa_mpol") Signed-off-by: Waiman Long Reviewed-by: Sebastian Andrzej Siewior --- tools/testing/selftests/futex/functional/futex_numa_mpol.c | 6 ++---- 1 file changed, 2 insertions(+), 4 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 a9ecfb2d3932..802c15c82190 100644 --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c @@ -182,12 +182,10 @@ int main(int argc, char *argv[]) if (futex_numa->numa =3D=3D FUTEX_NO_NODE) ksft_exit_fail_msg("NUMA node is left uninitialized\n"); =20 - ksft_print_msg("Memory too small\n"); + /* FUTEX2_NUMA futex must be 8-byte aligned */ + ksft_print_msg("Mis-aligned futex\n"); test_futex(futex_ptr + mem_size - 4, 1); =20 - ksft_print_msg("Memory out of range\n"); - test_futex(futex_ptr + mem_size, 1); - futex_numa->numa =3D FUTEX_NO_NODE; mprotect(futex_ptr, mem_size, PROT_READ); ksft_print_msg("Memory, RO\n"); --=20 2.50.1