* [LTP] [PATCH v4 0/4] futex: Add error coverage tests for wait, wake and cmp_requeue
@ 2026-05-07 11:18 Michael Menasherov via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test Michael Menasherov via ltp
` (3 more replies)
0 siblings, 4 replies; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-07 11:18 UTC (permalink / raw)
To: ltp
Improve error handling coverage for futex syscalls by adding tests
for missing error conditions that were previously untested.
futex_wait06 verifies EFAULT is returned when uaddr or timeout
points to unmapped memory.
futex_wait07 verifies EINTR is returned when futex_wait() is
interrupted by a signal.
futex_wake05 verifies EFAULT is returned when uaddr points to
unmapped or PROT_NONE memory.
futex_cmp_requeue03 verifies EFAULT is returned when uaddr or
uaddr2 points to unmapped or inaccessible (PROT_NONE) memory.
v4:
- Add commit body and Signed-off-by to all patches
- Remove incorrect EACCES/kernel-version check from futex_cmp_requeue03;
get_futex_key() always returns EFAULT for inaccessible pages
- Fix misleading comment in futex_wake05
- Shorten overlong comment in futex_wait07
Michael Menasherov (4):
futex_wait06: Add EFAULT error coverage test
futex_wait07: Add EINTR error coverage test
futex_wake05: Add EFAULT error coverage test
futex_cmp_requeue03: Add EFAULT error coverage test
runtest/syscalls | 4 +
testcases/kernel/syscalls/futex/.gitignore | 4 +
.../syscalls/futex/futex_cmp_requeue03.c | 94 +++++++++++++++++++
.../kernel/syscalls/futex/futex_wait06.c | 73 ++++++++++++++
.../kernel/syscalls/futex/futex_wait07.c | 88 +++++++++++++++++
.../kernel/syscalls/futex/futex_wake05.c | 85 +++++++++++++++++
6 files changed, 348 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
create mode 100644 testcases/kernel/syscalls/futex/futex_wait07.c
create mode 100644 testcases/kernel/syscalls/futex/futex_wake05.c
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread* [LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test
2026-05-07 11:18 [LTP] [PATCH v4 0/4] futex: Add error coverage tests for wait, wake and cmp_requeue Michael Menasherov via ltp
@ 2026-05-07 11:18 ` Michael Menasherov via ltp
2026-05-07 12:01 ` [LTP] " linuxtestproject.agent
2026-05-19 14:44 ` [LTP] [PATCH v4 1/4] " Andrea Cervesato via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 2/4] futex_wait07: Add EINTR " Michael Menasherov via ltp
` (2 subsequent siblings)
3 siblings, 2 replies; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-07 11:18 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 73 +++++++++++++++++++
3 files changed, 75 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index df5dc02b5..621355e04 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1905,3 +1905,4 @@ io_uring03 io_uring03
# Tests below may cause kernel memory leak
perf_event_open03 perf_event_open03
+futex_wait06 futex_wait06
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..8bb563fb2
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ futex_t *uaddr;
+ void *timeout;
+} testcases[2];
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, tc->uaddr, FUTEX_WAIT, futex,
+ tc->timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ void *bad;
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP(bad, getpagesize());
+
+ testcases[0] = (struct testcase){
+ .desc = "uaddr points to unmapped memory",
+ .uaddr = bad,
+ .timeout = NULL,
+ };
+ testcases[1] = (struct testcase){
+ .desc = "timeout points to unmapped memory",
+ .uaddr = &futex,
+ .timeout = bad,
+ };
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-07 11:18 ` [LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test Michael Menasherov via ltp
@ 2026-05-07 12:01 ` linuxtestproject.agent
2026-05-13 8:35 ` Michael Menasherov via ltp
2026-05-19 14:44 ` [LTP] [PATCH v4 1/4] " Andrea Cervesato via ltp
1 sibling, 1 reply; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-07 12:01 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp, LTP AI Reviewer
Hi Michael,
On Thu, 7 May 2026, Michael Menasherov wrote:
> [PATCH 1/4] futex_wait06: Add EFAULT error coverage test
> [PATCH 2/4] futex_wait07: Add EINTR error coverage test
> [PATCH 3/4] futex_wake05: Add EFAULT error coverage test
> [PATCH 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
Reviewed-by: LTP AI Reviewer <ltp-ai@noreply.github.com>
---
Note:
Our agent completed the review of the patch. The full review can be
found at: (not available)
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-07 12:01 ` [LTP] " linuxtestproject.agent
@ 2026-05-13 8:35 ` Michael Menasherov via ltp
2026-05-18 18:23 ` Michael Menasherov via ltp
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-13 8:35 UTC (permalink / raw)
To: linuxtestproject.agent; +Cc: ltp, LTP AI Reviewer
Hi,
Just a kind reminder about this patch series sent on May 7th.
The LTP AI Reviewer has already approved all four patches.
Would appreciate it if someone could take a look when time permits.
Thanks,
Michael Menasherov
On Thu, May 7, 2026 at 3:01 PM <linuxtestproject.agent@gmail.com> wrote:
> Hi Michael,
>
> On Thu, 7 May 2026, Michael Menasherov wrote:
> > [PATCH 1/4] futex_wait06: Add EFAULT error coverage test
> > [PATCH 2/4] futex_wait07: Add EINTR error coverage test
> > [PATCH 3/4] futex_wake05: Add EFAULT error coverage test
> > [PATCH 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
>
> Reviewed-by: LTP AI Reviewer <ltp-ai@noreply.github.com>
>
> ---
> Note:
>
> Our agent completed the review of the patch. The full review can be
> found at: (not available)
>
> The agent can sometimes produce false positives although often its
> findings are genuine. If you find issues with the review, please
> comment this email or ignore the suggestions.
>
> Regards,
> LTP AI Reviewer
>
>
--
Michael Menasherov
Software Quality Engineer - Automotive Kernel
Red Hat <https://www.redhat.com/>
<https://www.redhat.com/>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-13 8:35 ` Michael Menasherov via ltp
@ 2026-05-18 18:23 ` Michael Menasherov via ltp
2026-05-19 8:25 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-18 18:23 UTC (permalink / raw)
To: linuxtestproject.agent; +Cc: ltp, LTP AI Reviewer
Hi,
Following up again on this patch series originally sent on May 7th.
The LTP AI Reviewer has already approved all four patches with no issues
found.
Patch series:
[LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test
[LTP] [PATCH v4 2/4] futex_wait07: Add EINTR error coverage test
[LTP] [PATCH v4 3/4] futex_wake05: Add EFAULT error coverage test
[LTP] [PATCH v4 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
GitHub PR: https://github.com/linux-test-project/ltp/pull/1301
Is there anything missing or anything I can improve to help move this
forward?
Thanks.
On Wed, May 13, 2026 at 11:35 AM Michael Menasherov <mmenashe@redhat.com>
wrote:
> Hi,
>
> Just a kind reminder about this patch series sent on May 7th.
> The LTP AI Reviewer has already approved all four patches.
>
> Would appreciate it if someone could take a look when time permits.
>
> Thanks,
> Michael Menasherov
>
> On Thu, May 7, 2026 at 3:01 PM <linuxtestproject.agent@gmail.com> wrote:
>
>> Hi Michael,
>>
>> On Thu, 7 May 2026, Michael Menasherov wrote:
>> > [PATCH 1/4] futex_wait06: Add EFAULT error coverage test
>> > [PATCH 2/4] futex_wait07: Add EINTR error coverage test
>> > [PATCH 3/4] futex_wake05: Add EFAULT error coverage test
>> > [PATCH 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
>>
>> Reviewed-by: LTP AI Reviewer <ltp-ai@noreply.github.com>
>>
>> ---
>> Note:
>>
>> Our agent completed the review of the patch. The full review can be
>> found at: (not available)
>>
>> The agent can sometimes produce false positives although often its
>> findings are genuine. If you find issues with the review, please
>> comment this email or ignore the suggestions.
>>
>> Regards,
>> LTP AI Reviewer
>>
>>
>
> --
>
> Michael Menasherov
>
> Software Quality Engineer - Automotive Kernel
>
> Red Hat <https://www.redhat.com/>
> <https://www.redhat.com/>
>
--
Michael Menasherov
Software Quality Engineer - Automotive Kernel
Red Hat <https://www.redhat.com/>
<https://www.redhat.com/>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-18 18:23 ` Michael Menasherov via ltp
@ 2026-05-19 8:25 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 25+ messages in thread
From: Andrea Cervesato via ltp @ 2026-05-19 8:25 UTC (permalink / raw)
To: Michael Menasherov via ltp; +Cc: LTP AI Reviewer, ltp, linuxtestproject.agent
Hi Michael,
> Hi,
>
> Following up again on this patch series originally sent on May 7th.
> The LTP AI Reviewer has already approved all four patches with no issues
> found.
Unfortunately we didn't have time to review the patch-set yet,
but keep in mind that LTP AI Reviewer approval is not a certainty
that patches will be merged. This only means that agent didn't spot
major issues :-)
At the end, one of the maintainer will need to approve the review
of the agent and sending new feedbacks.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test
2026-05-07 11:18 ` [LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test Michael Menasherov via ltp
2026-05-07 12:01 ` [LTP] " linuxtestproject.agent
@ 2026-05-19 14:44 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 25+ messages in thread
From: Andrea Cervesato via ltp @ 2026-05-19 14:44 UTC (permalink / raw)
To: Michael Menasherov via ltp; +Cc: ltp
Hi Michael,
> + SAFE_MUNMAP(bad, getpagesize());
> +
> + testcases[0] = (struct testcase){
> + .desc = "uaddr points to unmapped memory",
> + .uaddr = bad,
> + .timeout = NULL,
> + };
> + testcases[1] = (struct testcase){
> + .desc = "timeout points to unmapped memory",
> + .uaddr = &futex,
> + .timeout = bad,
> + };
This is not the standard approach. Test cases should be defined at
compile-time with a `uaddr` double pointer pointing to `&bad`.
static struct testcase {
const char *desc;
futex_t **uaddr;
void *timeout;
} testcases[] = {
{
.desc = "uaddr points to unmapped memory",
.uaddr = &bad,
.timeout = NULL,
},
..
};
And in the `setup()` we will only need to initialize `bad` memory
pointer.
Kind Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v4 2/4] futex_wait07: Add EINTR error coverage test
2026-05-07 11:18 [LTP] [PATCH v4 0/4] futex: Add error coverage tests for wait, wake and cmp_requeue Michael Menasherov via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test Michael Menasherov via ltp
@ 2026-05-07 11:18 ` Michael Menasherov via ltp
2026-05-19 14:47 ` Andrea Cervesato via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 3/4] futex_wake05: Add EFAULT " Michael Menasherov via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 4/4] futex_cmp_requeue03: " Michael Menasherov via ltp
3 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-07 11:18 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EINTR. Add coverage for
the case where the wait is interrupted by a signal before the futex
word changes.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait07.c | 88 +++++++++++++++++++
3 files changed, 90 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait07.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 621355e04..75b7754db 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1906,3 +1906,4 @@ io_uring03 io_uring03
# Tests below may cause kernel memory leak
perf_event_open03 perf_event_open03
futex_wait06 futex_wait06
+futex_wait07 futex_wait07
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 56596dcb4..74ac9a926 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -14,3 +14,4 @@
/futex_waitv02
/futex_waitv03
/futex_wait06
+/futex_wait07
diff --git a/testcases/kernel/syscalls/futex/futex_wait07.c b/testcases/kernel/syscalls/futex/futex_wait07.c
new file mode 100644
index 000000000..9bf35e506
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait07.c
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EINTR when interrupted by a signal.
+ * A child process blocks on futex_wait() with a long timeout. The parent
+ * waits for the child to enter sleep state, then sends SIGUSR1 to it.
+ * The child verifies it received EINTR and exits accordingly.
+ */
+
+#include <errno.h>
+#include <signal.h>
+
+#include "futextest.h"
+
+static futex_t *futex;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+/* Empty handler: receiving the signal is sufficient to interrupt futex_wait(). */
+static void sigusr1_handler(int sig LTP_ATTRIBUTE_UNUSED)
+{
+}
+
+static void do_child(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct sigaction sa;
+ struct tst_ts timeout;
+
+ sa.sa_handler = sigusr1_handler;
+ sa.sa_flags = 0;
+ SAFE_SIGEMPTYSET(&sa.sa_mask);
+ SAFE_SIGACTION(SIGUSR1, &sa, NULL);
+
+ timeout = tst_ts_from_ms(tv->tstype, 5000);
+ TST_EXP_FAIL(futex_wait(tv->fntype, futex, *futex, &timeout, 0), EINTR);
+ exit(0);
+}
+
+static void run(void)
+{
+ pid_t child;
+
+ child = SAFE_FORK();
+
+ if (child == 0)
+ do_child();
+
+ TST_PROCESS_STATE_WAIT(child, 'S', 0);
+ SAFE_KILL(child, SIGUSR1);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ futex = SAFE_MMAP(NULL, sizeof(*futex), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
+ *futex = FUTEX_INITIALIZER;
+}
+
+static void cleanup(void)
+{
+ if (futex) {
+ SAFE_MUNMAP((void *)futex, sizeof(*futex));
+ }
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .cleanup = cleanup,
+ .test_all = run,
+ .test_variants = ARRAY_SIZE(variants),
+ .forks_child = 1,
+};
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* [LTP] [PATCH v4 3/4] futex_wake05: Add EFAULT error coverage test
2026-05-07 11:18 [LTP] [PATCH v4 0/4] futex: Add error coverage tests for wait, wake and cmp_requeue Michael Menasherov via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test Michael Menasherov via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 2/4] futex_wait07: Add EINTR " Michael Menasherov via ltp
@ 2026-05-07 11:18 ` Michael Menasherov via ltp
2026-05-19 14:48 ` Andrea Cervesato via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 4/4] futex_cmp_requeue03: " Michael Menasherov via ltp
3 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-07 11:18 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAKE) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped or PROT_NONE memory.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wake05.c | 85 +++++++++++++++++++
3 files changed, 87 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wake05.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 75b7754db..4d85a1d26 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1907,3 +1907,4 @@ io_uring03 io_uring03
perf_event_open03 perf_event_open03
futex_wait06 futex_wait06
futex_wait07 futex_wait07
+futex_wake05 futex_wake05
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 74ac9a926..c11546e07 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -15,3 +15,4 @@
/futex_waitv03
/futex_wait06
/futex_wait07
+/futex_wake05
diff --git a/testcases/kernel/syscalls/futex/futex_wake05.c b/testcases/kernel/syscalls/futex/futex_wake05.c
new file mode 100644
index 000000000..654bf96b5
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wake05.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ */
+
+/*\
+ * Check that futex(FUTEX_WAKE) returns EFAULT when uaddr points to
+ * unmapped or PROT_NONE memory.
+ *
+ * PROT_NONE memory triggers EFAULT because the kernel cannot look up
+ * the futex key for an inaccessible page.
+ */
+
+#include <errno.h>
+#include <sys/mman.h>
+#include "futextest.h"
+
+static futex_t *prot_none_addr;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ futex_t *addr;
+ int exp_errno;
+} testcases[2];
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+
+ TST_EXP_FAIL(futex_wake(tv->fntype, tc->addr, 1, 0),
+ tc->exp_errno, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ size_t pagesize = getpagesize();
+ futex_t *unmapped;
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ unmapped = SAFE_MMAP(NULL, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP(unmapped, pagesize);
+
+ prot_none_addr = SAFE_MMAP(NULL, pagesize, PROT_NONE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+ testcases[0] = (struct testcase){
+ .desc = "uaddr unmapped",
+ .addr = unmapped,
+ .exp_errno = EFAULT,
+ };
+ testcases[1] = (struct testcase){
+ .desc = "uaddr PROT_NONE",
+ .addr = prot_none_addr,
+ .exp_errno = EFAULT,
+ };
+}
+
+static void cleanup(void)
+{
+ if (prot_none_addr)
+ SAFE_MUNMAP(prot_none_addr, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .cleanup = cleanup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* [LTP] [PATCH v4 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
2026-05-07 11:18 [LTP] [PATCH v4 0/4] futex: Add error coverage tests for wait, wake and cmp_requeue Michael Menasherov via ltp
` (2 preceding siblings ...)
2026-05-07 11:18 ` [LTP] [PATCH v4 3/4] futex_wake05: Add EFAULT " Michael Menasherov via ltp
@ 2026-05-07 11:18 ` Michael Menasherov via ltp
2026-05-18 18:25 ` Michael Menasherov via ltp
2026-05-19 14:49 ` Andrea Cervesato via ltp
3 siblings, 2 replies; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-07 11:18 UTC (permalink / raw)
To: ltp
futex(FUTEX_CMP_REQUEUE) has no existing test for EFAULT. Add coverage
for the cases where uaddr or uaddr2 points to unmapped or inaccessible
(PROT_NONE) memory.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../syscalls/futex/futex_cmp_requeue03.c | 94 +++++++++++++++++++
3 files changed, 96 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 4d85a1d26..65baa44dc 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1908,3 +1908,4 @@ perf_event_open03 perf_event_open03
futex_wait06 futex_wait06
futex_wait07 futex_wait07
futex_wake05 futex_wake05
+futex_cmp_requeue03 futex_cmp_requeue03
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index c11546e07..231b6bd25 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -16,3 +16,4 @@
/futex_wait06
/futex_wait07
/futex_wake05
+/futex_cmp_requeue03
diff --git a/testcases/kernel/syscalls/futex/futex_cmp_requeue03.c b/testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
new file mode 100644
index 000000000..4c3c6e358
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ */
+
+/*\
+ * Check that futex(FUTEX_CMP_REQUEUE) returns EFAULT when uaddr or
+ * uaddr2 points to unmapped memory, or when uaddr points to memory
+ * without read permission (PROT_NONE).
+ */
+
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex_var = FUTEX_INITIALIZER;
+static futex_t *prot_none_addr;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ futex_t *uaddr;
+ futex_t *uaddr2;
+ int exp_errno;
+} testcases[3];
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+
+ TST_EXP_FAIL(futex_cmp_requeue(tv->fntype, tc->uaddr, futex_var,
+ tc->uaddr2, 1, 1, 0), tc->exp_errno, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ size_t pagesize = getpagesize();
+ futex_t *unmapped;
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ unmapped = SAFE_MMAP(NULL, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP(unmapped, pagesize);
+
+ prot_none_addr = SAFE_MMAP(NULL, pagesize, PROT_NONE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+ testcases[0] = (struct testcase){
+ .desc = "uaddr unmapped",
+ .uaddr = unmapped,
+ .uaddr2 = &futex_var,
+ .exp_errno = EFAULT,
+ };
+ testcases[1] = (struct testcase){
+ .desc = "uaddr2 unmapped",
+ .uaddr = &futex_var,
+ .uaddr2 = unmapped,
+ .exp_errno = EFAULT,
+ };
+ testcases[2] = (struct testcase){
+ .desc = "uaddr PROT_NONE",
+ .uaddr = prot_none_addr,
+ .uaddr2 = &futex_var,
+ .exp_errno = EFAULT,
+ };
+}
+
+static void cleanup(void)
+{
+ if (prot_none_addr)
+ SAFE_MUNMAP(prot_none_addr, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .cleanup = cleanup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] [PATCH v4 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
2026-05-07 11:18 ` [LTP] [PATCH v4 4/4] futex_cmp_requeue03: " Michael Menasherov via ltp
@ 2026-05-18 18:25 ` Michael Menasherov via ltp
2026-05-19 14:49 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-18 18:25 UTC (permalink / raw)
To: ltp
Hi,
Following up again on this patch series originally sent on May 7th.
The LTP AI Reviewer has already approved all four patches with no issues
found.
Patch series:
[LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test
[LTP] [PATCH v4 2/4] futex_wait07: Add EINTR error coverage test
[LTP] [PATCH v4 3/4] futex_wake05: Add EFAULT error coverage test
[LTP] [PATCH v4 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
GitHub PR: https://github.com/linux-test-project/ltp/pull/1301
Is there anything missing or anything I can improve to help move this
forward?
Thanks. Regards.
On Thu, May 7, 2026 at 2:18 PM Michael Menasherov <mmenashe@redhat.com>
wrote:
> futex(FUTEX_CMP_REQUEUE) has no existing test for EFAULT. Add coverage
> for the cases where uaddr or uaddr2 points to unmapped or inaccessible
> (PROT_NONE) memory.
>
> Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
> ---
> runtest/syscalls | 1 +
> testcases/kernel/syscalls/futex/.gitignore | 1 +
> .../syscalls/futex/futex_cmp_requeue03.c | 94 +++++++++++++++++++
> 3 files changed, 96 insertions(+)
> create mode 100644 testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 4d85a1d26..65baa44dc 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -1908,3 +1908,4 @@ perf_event_open03 perf_event_open03
> futex_wait06 futex_wait06
> futex_wait07 futex_wait07
> futex_wake05 futex_wake05
> +futex_cmp_requeue03 futex_cmp_requeue03
> diff --git a/testcases/kernel/syscalls/futex/.gitignore
> b/testcases/kernel/syscalls/futex/.gitignore
> index c11546e07..231b6bd25 100644
> --- a/testcases/kernel/syscalls/futex/.gitignore
> +++ b/testcases/kernel/syscalls/futex/.gitignore
> @@ -16,3 +16,4 @@
> /futex_wait06
> /futex_wait07
> /futex_wake05
> +/futex_cmp_requeue03
> diff --git a/testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
> b/testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
> new file mode 100644
> index 000000000..4c3c6e358
> --- /dev/null
> +++ b/testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
> @@ -0,0 +1,94 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2026 Red Hat, Inc.
> + */
> +
> +/*\
> + * Check that futex(FUTEX_CMP_REQUEUE) returns EFAULT when uaddr or
> + * uaddr2 points to unmapped memory, or when uaddr points to memory
> + * without read permission (PROT_NONE).
> + */
> +
> +#include <errno.h>
> +#include <sys/mman.h>
> +
> +#include "futextest.h"
> +
> +static futex_t futex_var = FUTEX_INITIALIZER;
> +static futex_t *prot_none_addr;
> +
> +static struct futex_test_variants variants[] = {
> +#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
> + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with old kernel
> spec"},
> +#endif
> +
> +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
> + { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernel
> spec"},
> +#endif
> +};
> +
> +static struct testcase {
> + const char *desc;
> + futex_t *uaddr;
> + futex_t *uaddr2;
> + int exp_errno;
> +} testcases[3];
> +
> +static void run(unsigned int n)
> +{
> + struct futex_test_variants *tv = &variants[tst_variant];
> + struct testcase *tc = &testcases[n];
> +
> + TST_EXP_FAIL(futex_cmp_requeue(tv->fntype, tc->uaddr, futex_var,
> + tc->uaddr2, 1, 1, 0), tc->exp_errno, "%s", tc->desc);
> +}
> +
> +static void setup(void)
> +{
> + struct futex_test_variants *tv = &variants[tst_variant];
> + size_t pagesize = getpagesize();
> + futex_t *unmapped;
> +
> + tst_res(TINFO, "Testing variant: %s", tv->desc);
> + futex_supported_by_kernel(tv->fntype);
> +
> + unmapped = SAFE_MMAP(NULL, pagesize, PROT_READ | PROT_WRITE,
> + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
> + SAFE_MUNMAP(unmapped, pagesize);
> +
> + prot_none_addr = SAFE_MMAP(NULL, pagesize, PROT_NONE,
> + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
> +
> + testcases[0] = (struct testcase){
> + .desc = "uaddr unmapped",
> + .uaddr = unmapped,
> + .uaddr2 = &futex_var,
> + .exp_errno = EFAULT,
> + };
> + testcases[1] = (struct testcase){
> + .desc = "uaddr2 unmapped",
> + .uaddr = &futex_var,
> + .uaddr2 = unmapped,
> + .exp_errno = EFAULT,
> + };
> + testcases[2] = (struct testcase){
> + .desc = "uaddr PROT_NONE",
> + .uaddr = prot_none_addr,
> + .uaddr2 = &futex_var,
> + .exp_errno = EFAULT,
> + };
> +}
> +
> +static void cleanup(void)
> +{
> + if (prot_none_addr)
> + SAFE_MUNMAP(prot_none_addr, getpagesize());
> +}
> +
> +static struct tst_test test = {
> + .setup = setup,
> + .cleanup = cleanup,
> + .test = run,
> + .tcnt = ARRAY_SIZE(testcases),
> + .test_variants = ARRAY_SIZE(variants),
> +};
> --
> 2.53.0
>
>
--
Michael Menasherov
Software Quality Engineer - Automotive Kernel
Red Hat <https://www.redhat.com/>
<https://www.redhat.com/>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [LTP] [PATCH v4 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
2026-05-07 11:18 ` [LTP] [PATCH v4 4/4] futex_cmp_requeue03: " Michael Menasherov via ltp
2026-05-18 18:25 ` Michael Menasherov via ltp
@ 2026-05-19 14:49 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 25+ messages in thread
From: Andrea Cervesato via ltp @ 2026-05-19 14:49 UTC (permalink / raw)
To: Michael Menasherov via ltp; +Cc: ltp
Hi Michael,
same comments of 1/4
Kind regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v14 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-27 9:26 Michael Menasherov via ltp
2026-05-27 9:56 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-27 9:26 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 75 +++++++++++++++++++
3 files changed, 77 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..7d5ea849e 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1868,6 +1868,7 @@ futex_wait02 futex_wait02
futex_wait03 futex_wait03
futex_wait04 futex_wait04
futex_wait05 futex_wait05
+futex_wait06 futex_wait06
futex_waitv01 futex_waitv01
futex_waitv02 futex_waitv02
futex_waitv03 futex_waitv03
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..a54c0a3c5
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ * Copyright (C) 2026 Michael Menasherov <mmenashe@redhat.com>
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ int bad_uaddr;
+ int bad_timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .bad_uaddr = 1,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .bad_timeout = 1,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ struct tst_ts ts = tst_ts_from_ms(tv->tstype, 5000);
+ futex_t *uaddr = tc->bad_uaddr ? bad : &futex;
+ void *timeout = tc->bad_timeout ? (void *)bad : tst_ts_get(&ts);
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-27 9:26 [LTP] [PATCH v14 1/4] futex_wait06: " Michael Menasherov via ltp
@ 2026-05-27 9:56 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-27 9:56 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
On Wed, 27 May 2026 12:26:15 +0300, Michael Menasherov wrote:
> futex_wait06: Add EFAULT error coverage test
> futex_wait07: Add EINTR error coverage test
> futex_wake05: Add EFAULT error coverage test
> futex_cmp_requeue03: Add EFAULT error coverage test
All good. Reviewed.
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v13 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-26 21:49 Michael Menasherov via ltp
2026-05-26 22:30 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-26 21:49 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 75 +++++++++++++++++++
3 files changed, 77 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..7d5ea849e 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1868,6 +1868,7 @@ futex_wait02 futex_wait02
futex_wait03 futex_wait03
futex_wait04 futex_wait04
futex_wait05 futex_wait05
+futex_wait06 futex_wait06
futex_waitv01 futex_waitv01
futex_waitv02 futex_waitv02
futex_waitv03 futex_waitv03
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..a54c0a3c5
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ * Copyright (C) 2026 Michael Menasherov <mmenashe@redhat.com>
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ int bad_uaddr;
+ int bad_timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .bad_uaddr = 1,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .bad_timeout = 1,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ struct tst_ts ts = tst_ts_from_ms(tv->tstype, 5000);
+ futex_t *uaddr = tc->bad_uaddr ? bad : &futex;
+ void *timeout = tc->bad_timeout ? (void *)bad : tst_ts_get(&ts);
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-26 21:49 [LTP] [PATCH v13 1/4] " Michael Menasherov via ltp
@ 2026-05-26 22:30 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-26 22:30 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
On Wed, 27 May 2026 00:49:24 +0300, Michael Menasherov wrote:
> futex_wait06: Add EFAULT error coverage test
[...]
Patches 1-3 look good to me. One comment issue in patch 4 below.
--- [PATCH 4/4] ---
On Wed, 27 May 2026 00:49:27 +0300, Michael Menasherov wrote:
> futex_cmp_requeue03: Add EFAULT error coverage test
> +/*\
> + * Check that futex(FUTEX_CMP_REQUEUE) returns EFAULT when uaddr or
> + * uaddr2 points to unmapped memory, or when uaddr points to memory
> + * without read permission (PROT_NONE).
> + *
> + * get_futex_key() is called for both uaddr and uaddr2 before the
> + * *uaddr == val check; futex_var and val are both FUTEX_INITIALIZER.
> + */
The comment explains the key-ordering for the uaddr2 case but omits why
opflags=0 (no FUTEX_PRIVATE_FLAG) is required. With FUTEX_PRIVATE_FLAG,
get_futex_key(uaddr2) succeeds using a virtual-address key with no
physical page resolution, so the call returns 0 (no waiters) rather than
EFAULT for the "uaddr2 unmapped" and "uaddr PROT_NONE" cases. Please
add a note similar to the one in futex_wake05, e.g.:
The test uses opflags=0 (no FUTEX_PRIVATE_FLAG) so get_futex_key()
takes the shared-futex path and resolves the physical page; this
lookup fails with EFAULT for unmapped and PROT_NONE addresses.
The code itself (opflags=0 in the call) is correct; the comment just
needs to explain why.
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v12 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-26 19:04 Michael Menasherov via ltp
2026-05-26 21:00 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-26 19:04 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 4 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 75 +++++++++++++++++++
3 files changed, 80 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..87bd5aeac 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1863,11 +1863,14 @@ perf_event_open02 perf_event_open02
futex_cmp_requeue01 futex_cmp_requeue01
futex_cmp_requeue02 futex_cmp_requeue02
+futex_cmp_requeue03 futex_cmp_requeue03
futex_wait01 futex_wait01
futex_wait02 futex_wait02
futex_wait03 futex_wait03
futex_wait04 futex_wait04
futex_wait05 futex_wait05
+futex_wait06 futex_wait06
+futex_wait07 futex_wait07
futex_waitv01 futex_waitv01
futex_waitv02 futex_waitv02
futex_waitv03 futex_waitv03
@@ -1875,6 +1878,7 @@ futex_wake01 futex_wake01
futex_wake02 futex_wake02
futex_wake03 futex_wake03
futex_wake04 futex_wake04
+futex_wake05 futex_wake05
futex_wait_bitset01 futex_wait_bitset01
memfd_create01 memfd_create01
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..a54c0a3c5
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ * Copyright (C) 2026 Michael Menasherov <mmenashe@redhat.com>
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ int bad_uaddr;
+ int bad_timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .bad_uaddr = 1,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .bad_timeout = 1,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ struct tst_ts ts = tst_ts_from_ms(tv->tstype, 5000);
+ futex_t *uaddr = tc->bad_uaddr ? bad : &futex;
+ void *timeout = tc->bad_timeout ? (void *)bad : tst_ts_get(&ts);
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-26 19:04 [LTP] [PATCH v12 1/4] " Michael Menasherov via ltp
@ 2026-05-26 21:00 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-26 21:00 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
On Tue, 26 May 2026 22:04:27 +0300, Michael Menasherov wrote:
> futex_wait06: Add EFAULT error coverage test
--- [PATCH 1/4] futex_wait06: Add EFAULT error coverage test ---
> diff --git a/runtest/syscalls b/runtest/syscalls
> [...]
> +futex_cmp_requeue03 futex_cmp_requeue03
> [...]
> +futex_wait07 futex_wait07
> [...]
> +futex_wake05 futex_wake05
The runtest entries for futex_wait07, futex_wake05, and
futex_cmp_requeue03 belong in the commits that introduce those tests,
not here. As-is, if the first commit is applied alone (e.g. during
bisect) the runtest file references binaries that don't exist yet.
--- [PATCH 3/4] futex_wake05: Add EFAULT error coverage test ---
> +#include <sys/mman.h>
> +#include "futextest.h"
Missing blank line between system and local includes.
--- [PATCH 4/4] futex_cmp_requeue03: Add EFAULT error coverage test ---
> + * uaddr2 is only reached after *uaddr == val passes; both are
> + * FUTEX_INITIALIZER so the comparison succeeds.
This is inaccurate. The kernel calls get_futex_key() for both uaddr
and uaddr2 before performing the *uaddr == val comparison, so uaddr2
is validated regardless of the comparison outcome. The test still
works correctly since futex_var == FUTEX_INITIALIZER == val, but the
comment should be fixed.
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v11 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-26 15:26 Michael Menasherov via ltp
2026-05-26 18:36 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-26 15:26 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 74 +++++++++++++++++++
3 files changed, 76 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..7d5ea849e 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1868,6 +1868,7 @@ futex_wait02 futex_wait02
futex_wait03 futex_wait03
futex_wait04 futex_wait04
futex_wait05 futex_wait05
+futex_wait06 futex_wait06
futex_waitv01 futex_waitv01
futex_waitv02 futex_waitv02
futex_waitv03 futex_waitv03
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..b57e8a99b
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc. Michael Menasherov <mmenashe@redhat.com>
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ int bad_uaddr;
+ int bad_timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .bad_uaddr = 1,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .bad_timeout = 1,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ struct tst_ts ts = tst_ts_from_ms(tv->tstype, 5000);
+ futex_t *uaddr = tc->bad_uaddr ? bad : &futex;
+ void *timeout = tc->bad_timeout ? (void *)bad : tst_ts_get(&ts);
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-26 15:26 [LTP] [PATCH v11 1/4] " Michael Menasherov via ltp
@ 2026-05-26 18:36 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-26 18:36 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
On Tue, 26 May 2026, Michael Menasherov wrote:
> [PATCH 1/4] futex_wait06: Add EFAULT error coverage test
--- [PATCH 1/4] ---
> + * Copyright (C) 2026 Red Hat, Inc. Michael Menasherov <mmenashe@redhat.com>
Non-standard copyright format — company name and author are concatenated.
Use one or the other: either "Red Hat, Inc." or "Michael Menasherov
<mmenashe@redhat.com>". Same issue in patches 2–4.
--- [PATCH 2/4] ---
> [PATCH 2/4] futex_wait07: Add EINTR error coverage test
> + TST_PROCESS_STATE_WAIT(child, 'S', 0);
> + SAFE_KILL(child, SIGUSR1);
> +}
run() returns without waiting for the child. Add SAFE_WAITPID(child, NULL, 0)
after SAFE_KILL to ensure the child has exited and its result is collected
before cleanup() runs.
[...]
Patches 3/4 and 4/4 look good.
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v10 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-26 9:07 Michael Menasherov via ltp
2026-05-26 15:29 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-26 9:07 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 74 +++++++++++++++++++
3 files changed, 76 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..7d5ea849e 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1868,6 +1868,7 @@ futex_wait02 futex_wait02
futex_wait03 futex_wait03
futex_wait04 futex_wait04
futex_wait05 futex_wait05
+futex_wait06 futex_wait06
futex_waitv01 futex_waitv01
futex_waitv02 futex_waitv02
futex_waitv03 futex_waitv03
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..0d0880443
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc. Michael Menasherov <mmenashe@redhat.com>
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ int bad_uaddr;
+ int bad_timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .bad_uaddr = 1,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .bad_timeout = 1,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ struct tst_ts ts = tst_ts_from_ms(tv->tstype, 5000);
+ futex_t *uaddr = tc->bad_uaddr ? bad : &futex;
+ void *timeout = tc->bad_timeout ? (void *)bad : tst_ts_get(&ts);
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-26 9:07 [LTP] [PATCH v10 1/4] " Michael Menasherov via ltp
@ 2026-05-26 15:29 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-26 15:29 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
On Tue May 26 2026, Michael Menasherov wrote:
> futex_wait06: Add EFAULT error coverage test
All good. Approved.
--- [PATCH 2/4] ---
> futex_wait07: Add EINTR error coverage test
All good. Approved.
--- [PATCH 3/4] ---
> futex_wake05: Add EFAULT error coverage test
All good. Approved.
--- [PATCH 4/4] ---
> futex_cmp_requeue03: Add EFAULT error coverage test
All good. Approved.
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v9 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-25 19:03 Michael Menasherov via ltp
2026-05-25 19:45 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-25 19:03 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 74 +++++++++++++++++++
3 files changed, 76 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..8d93c0e40 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1876,6 +1876,7 @@ futex_wake02 futex_wake02
futex_wake03 futex_wake03
futex_wake04 futex_wake04
futex_wait_bitset01 futex_wait_bitset01
+futex_wait06 futex_wait06
memfd_create01 memfd_create01
memfd_create02 memfd_create02
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..0d0880443
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc. Michael Menasherov <mmenashe@redhat.com>
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ int bad_uaddr;
+ int bad_timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .bad_uaddr = 1,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .bad_timeout = 1,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ struct tst_ts ts = tst_ts_from_ms(tv->tstype, 5000);
+ futex_t *uaddr = tc->bad_uaddr ? bad : &futex;
+ void *timeout = tc->bad_timeout ? (void *)bad : tst_ts_get(&ts);
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-25 19:03 [LTP] [PATCH v9 1/4] " Michael Menasherov via ltp
@ 2026-05-25 19:45 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-25 19:45 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
On Mon, 25 May 2026, Michael Menasherov wrote:
> futex_wait06: Add EFAULT error coverage test
[...]
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -1876,6 +1877,9 @@ futex_wake04 futex_wake04
> futex_wait_bitset01 futex_wait_bitset01
> +futex_wait06 futex_wait06
> +futex_wait07 futex_wait07
> +futex_wake05 futex_wake05
futex_wait06 and futex_wait07 should be inserted after futex_wait05
(before futex_waitv01), and futex_wake05 should follow futex_wake04
(before futex_wait_bitset01). All three are currently appended at the
wrong position.
[...]
--- [PATCH 4/4] futex_cmp_requeue03 ---
> +futex_cmp_requeue03 futex_cmp_requeue03
Placement is correct here.
> +static futex_t futex_var = FUTEX_INITIALIZER;
> +static futex_t *futex_ptr = &futex_var;
> + TST_EXP_FAIL(futex_cmp_requeue(tv->fntype, *tc->uaddr, futex_var,
> + *tc->uaddr2, 1, 1, 0), tc->exp_errno, "%s", tc->desc);
For the "uaddr2 unmapped" case the call path reaches the uaddr2 key
lookup only after verifying *uaddr == val. Since both futex_var and val
are FUTEX_INITIALIZER (0), the comparison passes and EFAULT is returned
on the uaddr2 page resolution — as intended. No issue, just noting the
dependency for readers.
---
Summary: fix the runtest insertion points for futex_wait06, futex_wait07,
and futex_wake05 before resubmitting.
---
Note:
Our agent completed the review of the patch. The full review can be
found at: (REVIEW_URL not set)
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v8 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-25 14:44 Michael Menasherov via ltp
2026-05-25 17:13 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-25 14:44 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 75 +++++++++++++++++++
3 files changed, 77 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..8d93c0e40 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1876,6 +1876,7 @@ futex_wake02 futex_wake02
futex_wake03 futex_wake03
futex_wake04 futex_wake04
futex_wait_bitset01 futex_wait_bitset01
+futex_wait06 futex_wait06
memfd_create01 memfd_create01
memfd_create02 memfd_create02
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..2cf509ee1
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc. Michael Menasherov <mmenashe@redhat.com>
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ futex_t **uaddr;
+ void **timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .uaddr = &bad,
+ .timeout = NULL,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .uaddr = NULL,
+ .timeout = (void **)&bad,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ futex_t *uaddr = tc->uaddr ? *tc->uaddr : &futex;
+ void *timeout = tc->timeout ? *tc->timeout : NULL;
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-25 14:44 [LTP] [PATCH v8 1/4] " Michael Menasherov via ltp
@ 2026-05-25 17:13 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-25 17:13 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
On Mon, 25 May 2026 17:44:14 +0300, Michael Menasherov wrote:
> [PATCH 1/4] futex_wait06: Add EFAULT error coverage test
--- [PATCH 1/4] ---
> +static struct futex_test_variants variants[] = {
> +#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
> + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
> +#endif
> +
> +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
> + { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
> +#endif
> +};
`.tstype` is set here but `run()` calls `futex_syscall()` directly without
ever reading `tv->tstype`. Since the test passes the raw bad pointer as
timeout (bypassing `tst_ts_*`), drop the `.tstype` assignments from
both variants — they are dead and misleading.
[...]
--- [PATCH 4/4] ---
> +futex_cmp_requeue03 futex_cmp_requeue03
This entry is placed after `futex_wake05` rather than near the other
`futex_cmp_requeue` entries. It should follow `futex_cmp_requeue02`
at line 1865.
[...]
---
Note:
Our agent completed the review of the patch. The full review can be
found at: https://github.com/linux-test-project/ltp-agent/actions/runs/26411600640
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v7 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-25 10:04 Michael Menasherov via ltp
2026-05-25 14:15 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-25 10:04 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 75 +++++++++++++++++++
3 files changed, 77 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..e8ef890f3 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1907,3 +1907,4 @@ io_uring03 io_uring03
# Tests below may cause kernel memory leak
perf_event_open03 perf_event_open03
+futex_wait06 futex_wait06
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..2cf509ee1
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc. Michael Menasherov <mmenashe@redhat.com>
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ futex_t **uaddr;
+ void **timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .uaddr = &bad,
+ .timeout = NULL,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .uaddr = NULL,
+ .timeout = (void **)&bad,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ futex_t *uaddr = tc->uaddr ? *tc->uaddr : &futex;
+ void *timeout = tc->timeout ? *tc->timeout : NULL;
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-25 10:04 [LTP] [PATCH v7 1/4] " Michael Menasherov via ltp
@ 2026-05-25 14:15 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-25 14:15 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
On Mon, 25 May 2026, Michael Menasherov wrote:
> [PATCH 1/4] futex_wait06: Add EFAULT error coverage test
> diff --git a/runtest/syscalls b/runtest/syscalls
> @@ -1907,3 +1907,4 @@ io_uring03 io_uring03
> # Tests below may cause kernel memory leak
> perf_event_open03 perf_event_open03
> +futex_wait06 futex_wait06
This test doesn't cause a kernel memory leak. Same issue applies to
futex_wait07, futex_wake05, and futex_cmp_requeue03 in patches 2-4.
All four entries should be placed alongside the existing futex tests
(after futex_wait_bitset01, ~line 1878), not under this comment.
[...]
--- [PATCH 3/4] futex_wake05: Add EFAULT error coverage test ---
> + * PROT_NONE memory triggers EFAULT because the kernel cannot look up
> + * the futex key for an inaccessible page.
This warrants a note: the test calls futex_wake() without
FUTEX_PRIVATE_FLAG (opflags=0), which takes the shared-futex path in
get_futex_key() and requires resolving the physical page — hence EFAULT
for PROT_NONE. That reasoning is correct for MAP_PRIVATE|MAP_ANONYMOUS
today, but the comment doesn't explain the dependency on the absence of
FUTEX_PRIVATE_FLAG. A reader might wonder why FUTEX_WAKE (which never
reads *uaddr) can return EFAULT at all. Worth a brief clarification.
[...]
The rest of the code looks correct: mmap/munmap patterns, signal
handling in futex_wait07, MAP_SHARED for the cross-process futex, and
TST_PROCESS_STATE_WAIT before SAFE_KILL are all fine. Makefile uses
wildcards so no explicit entries needed.
---
Note:
Our agent completed the review of the patch. The full review can be
found at: <review_url>
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
```
---
**Verdict: Needs revision**
Two items:
1. **All 4 patches** — runtest/syscalls entries must move out from under `# Tests below may cause kernel memory leak` and be placed with the other futex tests (~line 1878).
2. **futex_wake05** — the comment about PROT_NONE triggering EFAULT should clarify that this relies on using the shared-futex path (no `FUTEX_PRIVATE_FLAG`), since FUTEX_WAKE doesn't read `*uaddr` and the reason for EFAULT is non-obvious.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v6 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-20 7:44 Michael Menasherov via ltp
2026-05-20 9:45 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-20 7:44 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 75 +++++++++++++++++++
3 files changed, 77 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..e8ef890f3 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1907,3 +1907,4 @@ io_uring03 io_uring03
# Tests below may cause kernel memory leak
perf_event_open03 perf_event_open03
+futex_wait06 futex_wait06
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..44f2f7acd
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ futex_t **uaddr;
+ void **timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .uaddr = &bad,
+ .timeout = NULL,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .uaddr = NULL,
+ .timeout = (void **)&bad,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ futex_t *uaddr = tc->uaddr ? *tc->uaddr : &futex;
+ void *timeout = tc->timeout ? *tc->timeout : NULL;
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-20 7:44 [LTP] [PATCH v6 1/4] " Michael Menasherov via ltp
@ 2026-05-20 9:45 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-20 9:45 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp, LTP AI Reviewer
Hi Michael,
On Wed, 20 May 2026, Michael Menasherov wrote:
> [PATCH 1/4] futex_wait06: Add EFAULT error coverage test
> [PATCH 2/4] futex_wait07: Add EINTR error coverage test
> [PATCH 3/4] futex_wake05: Add EFAULT error coverage test
> [PATCH 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
Reviewed-by: LTP AI Reviewer <ltp-ai@noreply.github.com>
---
Note:
Our agent completed the review of the patch.
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [PATCH v5 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-19 18:30 Michael Menasherov via ltp
2026-05-19 19:10 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-19 18:30 UTC (permalink / raw)
To: ltp
futex(FUTEX_WAIT) has no existing test for EFAULT. Add coverage for
the cases where uaddr points to unmapped memory and where the timeout
pointer is invalid.
Signed-off-by: Michael Menasherov <mmenashe@redhat.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 75 +++++++++++++++++++
3 files changed, 77 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index f790e8f84..e8ef890f3 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1907,3 +1907,4 @@ io_uring03 io_uring03
# Tests below may cause kernel memory leak
perf_event_open03 perf_event_open03
+futex_wait06 futex_wait06
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..44f2f7acd
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+static futex_t *bad;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ futex_t **uaddr;
+ void **timeout;
+} testcases[] = {
+ {
+ .desc = "uaddr points to unmapped memory",
+ .uaddr = &bad,
+ .timeout = NULL,
+ },
+ {
+ .desc = "timeout points to unmapped memory",
+ .uaddr = NULL,
+ .timeout = (void **)&bad,
+ },
+};
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+ futex_t *uaddr = tc->uaddr ? *tc->uaddr : &futex;
+ void *timeout = tc->timeout ? *tc->timeout : NULL;
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, uaddr, FUTEX_WAIT, futex,
+ timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP((void *)bad, getpagesize());
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-19 18:30 [LTP] [PATCH v5 1/4] " Michael Menasherov via ltp
@ 2026-05-19 19:10 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-19 19:10 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
--- [PATCH 4/4] ---
On Tue, 19 May 2026 21:30:31 +0300, Michael Menasherov wrote:
> futex_cmp_requeue03: Add EFAULT error coverage test
> +/*\
> + * Check that futex(FUTEX_CMP_REQUEUE) returns EFAULT when uaddr or
> + * uaddr2 points to unmapped memory, or when uaddr points to memory
> + * without read permission (PROT_NONE).
> + *
> + * The EACCES behavior for PROT_NONE was introduced in kernel 5.9.
> + */
The doc comment says "returns EFAULT ... when uaddr points to memory
without read permission (PROT_NONE)", but the test correctly expects
EACCES for that case on kernels >= 5.9. Please update the comment to
reflect both outcomes, e.g.:
"returns EFAULT when uaddr or uaddr2 points to unmapped memory, or
EACCES (EFAULT on kernels < 5.9) when uaddr points to PROT_NONE
memory."
Patches 1–3 look good.
---
Note:
Our agent completed the review of the patch. The agent can sometimes
produce false positives although often its findings are genuine. If you
find issues with the review, please comment this email or ignore the
suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
* [LTP] [ltp v2 1/4] futex_wait06: Add EFAULT error coverage test
@ 2026-05-06 15:17 Michael Menasherov via ltp
2026-05-06 16:39 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 25+ messages in thread
From: Michael Menasherov via ltp @ 2026-05-06 15:17 UTC (permalink / raw)
To: ltp
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/futex/.gitignore | 1 +
.../kernel/syscalls/futex/futex_wait06.c | 73 +++++++++++++++++++
3 files changed, 75 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
diff --git a/runtest/syscalls b/runtest/syscalls
index df5dc02b5..621355e04 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1905,3 +1905,4 @@ io_uring03 io_uring03
# Tests below may cause kernel memory leak
perf_event_open03 perf_event_open03
+futex_wait06 futex_wait06
diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..56596dcb4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
/futex_waitv01
/futex_waitv02
/futex_waitv03
+/futex_wait06
diff --git a/testcases/kernel/syscalls/futex/futex_wait06.c b/testcases/kernel/syscalls/futex/futex_wait06.c
new file mode 100644
index 000000000..8bb563fb2
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_wait06.c
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ */
+
+/*\
+ * Check that futex(FUTEX_WAIT) returns EFAULT when:
+ *
+ * 1) uaddr points to unmapped memory
+ * 2) timeout points to unmapped memory
+ */
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "futextest.h"
+
+static futex_t futex = FUTEX_INITIALIZER;
+
+static struct futex_test_variants variants[] = {
+#if (__NR_futex != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
+#endif
+
+#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL)
+ { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
+#endif
+};
+
+static struct testcase {
+ const char *desc;
+ futex_t *uaddr;
+ void *timeout;
+} testcases[2];
+
+static void run(unsigned int n)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ struct testcase *tc = &testcases[n];
+
+ TST_EXP_FAIL(futex_syscall(tv->fntype, tc->uaddr, FUTEX_WAIT, futex,
+ tc->timeout, NULL, 0, 0), EFAULT, "%s", tc->desc);
+}
+
+static void setup(void)
+{
+ struct futex_test_variants *tv = &variants[tst_variant];
+ void *bad;
+
+ tst_res(TINFO, "Testing variant: %s", tv->desc);
+ futex_supported_by_kernel(tv->fntype);
+
+ bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ SAFE_MUNMAP(bad, getpagesize());
+
+ testcases[0] = (struct testcase){
+ .desc = "uaddr points to unmapped memory",
+ .uaddr = bad,
+ .timeout = NULL,
+ };
+ testcases[1] = (struct testcase){
+ .desc = "timeout points to unmapped memory",
+ .uaddr = &futex,
+ .timeout = bad,
+ };
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .test = run,
+ .tcnt = ARRAY_SIZE(testcases),
+ .test_variants = ARRAY_SIZE(variants),
+};
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [LTP] futex_wait06: Add EFAULT error coverage test
2026-05-06 15:17 [LTP] [ltp v2 1/4] " Michael Menasherov via ltp
@ 2026-05-06 16:39 ` linuxtestproject.agent
0 siblings, 0 replies; 25+ messages in thread
From: linuxtestproject.agent @ 2026-05-06 16:39 UTC (permalink / raw)
To: Michael Menasherov; +Cc: ltp
Hi Michael,
All four patches are missing a commit body and Signed-off-by tag.
Please add at least one sentence explaining why each test is being added
(gap in coverage, related kernel change, regression, etc.), and add
your Signed-off-by trailer to each commit.
--- [PATCH 4/4] ---
On Wed, 6 May 2026 18:18:01 +0300, Michael Menasherov wrote:
> futex_cmp_requeue03: Add EFAULT and EACCES error coverage test
> + * The EACCES behavior for PROT_NONE was introduced in kernel 5.9.
> + .exp_errno = tst_kvercmp(5, 9, 0) >= 0 ? EACCES : EFAULT,
I cannot find a kernel code path that returns -EACCES for a PROT_NONE
futex address. get_futex_key() in kernel/futex/core.c returns -EFAULT
when get_user_pages_fast() fails on an inaccessible page, regardless of
whether the failure is due to unmapped or PROT_NONE memory. Please cite
the specific kernel commit that introduced this behaviour, or replace the
conditional with unconditional EFAULT.
[...]
---
Note:
Our agent completed the review of the patch. The agent can sometimes
produce false positives although often its findings are genuine. If you
find issues with the review, please comment this email or ignore the
suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2026-05-27 9:56 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 11:18 [LTP] [PATCH v4 0/4] futex: Add error coverage tests for wait, wake and cmp_requeue Michael Menasherov via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test Michael Menasherov via ltp
2026-05-07 12:01 ` [LTP] " linuxtestproject.agent
2026-05-13 8:35 ` Michael Menasherov via ltp
2026-05-18 18:23 ` Michael Menasherov via ltp
2026-05-19 8:25 ` Andrea Cervesato via ltp
2026-05-19 14:44 ` [LTP] [PATCH v4 1/4] " Andrea Cervesato via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 2/4] futex_wait07: Add EINTR " Michael Menasherov via ltp
2026-05-19 14:47 ` Andrea Cervesato via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 3/4] futex_wake05: Add EFAULT " Michael Menasherov via ltp
2026-05-19 14:48 ` Andrea Cervesato via ltp
2026-05-07 11:18 ` [LTP] [PATCH v4 4/4] futex_cmp_requeue03: " Michael Menasherov via ltp
2026-05-18 18:25 ` Michael Menasherov via ltp
2026-05-19 14:49 ` Andrea Cervesato via ltp
-- strict thread matches above, loose matches on Subject: below --
2026-05-27 9:26 [LTP] [PATCH v14 1/4] futex_wait06: " Michael Menasherov via ltp
2026-05-27 9:56 ` [LTP] " linuxtestproject.agent
2026-05-26 21:49 [LTP] [PATCH v13 1/4] " Michael Menasherov via ltp
2026-05-26 22:30 ` [LTP] " linuxtestproject.agent
2026-05-26 19:04 [LTP] [PATCH v12 1/4] " Michael Menasherov via ltp
2026-05-26 21:00 ` [LTP] " linuxtestproject.agent
2026-05-26 15:26 [LTP] [PATCH v11 1/4] " Michael Menasherov via ltp
2026-05-26 18:36 ` [LTP] " linuxtestproject.agent
2026-05-26 9:07 [LTP] [PATCH v10 1/4] " Michael Menasherov via ltp
2026-05-26 15:29 ` [LTP] " linuxtestproject.agent
2026-05-25 19:03 [LTP] [PATCH v9 1/4] " Michael Menasherov via ltp
2026-05-25 19:45 ` [LTP] " linuxtestproject.agent
2026-05-25 14:44 [LTP] [PATCH v8 1/4] " Michael Menasherov via ltp
2026-05-25 17:13 ` [LTP] " linuxtestproject.agent
2026-05-25 10:04 [LTP] [PATCH v7 1/4] " Michael Menasherov via ltp
2026-05-25 14:15 ` [LTP] " linuxtestproject.agent
2026-05-20 7:44 [LTP] [PATCH v6 1/4] " Michael Menasherov via ltp
2026-05-20 9:45 ` [LTP] " linuxtestproject.agent
2026-05-19 18:30 [LTP] [PATCH v5 1/4] " Michael Menasherov via ltp
2026-05-19 19:10 ` [LTP] " linuxtestproject.agent
2026-05-06 15:17 [LTP] [ltp v2 1/4] " Michael Menasherov via ltp
2026-05-06 16:39 ` [LTP] " linuxtestproject.agent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox