[LTP] [PATCH v4 4/4] futex_cmp_requeue03: Add EFAULT error coverage test
Michael Menasherov
mmenashe@redhat.com
Mon May 18 20:25:01 CEST 2026
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/>
More information about the ltp
mailing list