futex: Add error coverage tests for wait, wake and cmp_requeue
v4 cover futex: Add error coverage tests for wait, wake and cmp_requeue
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
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 1/4 futex_wait06: Add EFAULT error coverage test
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.
--- 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
runtest/syscalls +1 -0
@@ -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
testcases/kernel/syscalls/futex/.gitignore +1 -0
@@ -13,3 +13,4 @@ /futex_waitv01 /futex_waitv02 /futex_waitv03 +/futex_wait06
testcases/kernel/syscalls/futex/futex_wait06.c new file +73 -0
73 lines not on this page · raw message
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] futex_wait06: Add EFAULT error coverage test
Hi Michael,
Quoted 4 lines · Michael Menasherov
[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
---
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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] futex_wait06: Add EFAULT error coverage test
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
Quoted 24 lines · On Thu, May 7, 2026 at 3:01 PM <[email protected]> wrote:
Hi Michael,
Quoted 4 lines · Michael Menasherov
[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 testReviewed-by LTP AI Reviewer <[email protected]>---
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
Signature · 9 lines
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
Re: [LTP] futex_wait06: Add EFAULT error coverage test
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.
Quoted 46 lines · Michael Menasherov
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 MenasherovQuoted 16 lines · On Thu, May 7, 2026 at 3:01 PM <[email protected]> wrote:
Hi Michael,
Quoted 4 lines · Michael Menasherov
[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 testReviewed-by LTP AI Reviewer <[email protected]>---
Note:Our agent completed the review of the patch. The full review can be found at: (not available)
Quoted 8 lines
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/>
Signature · 9 lines
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
Re: [LTP] futex_wait06: Add EFAULT error coverage test
Hi Michael,
Quoted 5 lines
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
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 1/4] futex_wait06: Add EFAULT error coverage test
In reply to Michael Menasherov via ltpHi Michael,
testcases/kernel/syscalls/futex/futex_wait06.c line 65
Quoted 12 lines
testcases/kernel/syscalls/futex/futex_wait06.c new file +12
-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, + };
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
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 2/4 futex_wait07: Add EINTR error coverage test
In reply to Michael Menasherov via ltpfutex(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.
--- 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
runtest/syscalls +1 -0
@@ -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
testcases/kernel/syscalls/futex/.gitignore +1 -0
@@ -14,3 +14,4 @@ /futex_waitv02 /futex_waitv03 /futex_wait06 +/futex_wait07
testcases/kernel/syscalls/futex/futex_wait07.c new file +88 -0
88 lines not on this page · raw message
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 2/4] futex_wait07: Add EINTR error coverage test
Hi Michael,
testcases/kernel/syscalls/futex/futex_wait07.c line 80
Quoted 5 lines
testcases/kernel/syscalls/futex/futex_wait07.c new file +5
-0+{ +if (futex) { +SAFE_MUNMAP ((void *)futex,sizeof (*futex)); + } +}
Please run make check on patches because this is supposed to be an error: 1 line statement doesn't require parenthesis.
Kind regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 3/4 futex_wake05: Add EFAULT error coverage test
In reply to Michael Menasherov via ltpfutex(FUTEX_WAKE) has no existing test for EFAULT. Add coverage for the cases where uaddr points to unmapped or PROT_NONE memory.
--- 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
runtest/syscalls +1 -0
@@ -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
testcases/kernel/syscalls/futex/.gitignore +1 -0
@@ -15,3 +15,4 @@ /futex_waitv03 /futex_wait06 /futex_wait07 +/futex_wake05
testcases/kernel/syscalls/futex/futex_wake05.c new file +85 -0
85 lines not on this page · raw message
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 3/4] futex_wake05: Add EFAULT error coverage test
Hi Michael,
Same comments of 1/4
Kind Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 4/4 futex_cmp_requeue03: Add EFAULT error coverage test
In reply to Michael Menasherov via ltpfutex(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.
--- 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
runtest/syscalls +1 -0
@@ -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
testcases/kernel/syscalls/futex/.gitignore +1 -0
@@ -16,3 +16,4 @@ /futex_wait06 /futex_wait07 /futex_wake05 +/futex_cmp_requeue03
testcases/kernel/syscalls/futex/futex_cmp_requeue03.c new file +94 -0
94 lines not on this page · raw message
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v4 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
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.
Quoted 138 lines · Michael Menasherov
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 <[email protected]>--- 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.cruntest/syscalls +1
-0@@ -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_requeue03testcases/kernel/syscalls/futex/.gitignore +1
-0@@ -16,3 +16,4 @@ /futex_wait06 /futex_wait07 /futex_wake05 +/futex_cmp_requeue03testcases/kernel/syscalls/futex/futex_cmp_requeue03.c new file +22
-0@@ -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 kernelspec"},
testcases/kernel/syscalls/futex/futex_cmp_requeue03.c new file +4
-0+#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernelspec"},
testcases/kernel/syscalls/futex/futex_cmp_requeue03.c new file +68
-1+#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
Signature · 9 lines
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
Re: [LTP] [PATCH v4 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
In reply to Michael Menasherov via ltpHi Michael,
same comments of 1/4
Kind regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp