| Message ID | 20260507111809.28934-5-mmenashe@redhat.com |
|---|---|
| State | Changes Requested |
| Headers | show |
| Series | futex: Add error coverage tests for wait, wake and cmp_requeue | expand |
| Context | Check | Description |
|---|---|---|
| ltpci/github-build-doc | success | success |
| ltpci/github-build-debian_stable_aarch64-linux-gnu-gcc_arm64 | success | success |
| ltpci/github-build-debian_stable_powerpc64le-linux-gnu-gcc_ppc64el | success | success |
| ltpci/github-build-debian_testing_gcc | success | success |
| ltpci/github-build-debian_stable_s390x-linux-gnu-gcc_s390x | success | success |
| ltpci/github-build-ubuntu_jammy_gcc | success | success |
| ltpci/github-build-debian_stable_gcc | success | success |
| ltpci/github-build-fedora_latest_clang | success | success |
| ltpci/github-build-alpine_latest_gcc | success | success |
| ltpci/github-build-quay-io-centos-centos_stream9_gcc | success | success |
| ltpci/github-build-debian_testing_clang | success | success |
| ltpci/github-build-debian_stable_gcc | success | success |
| ltpci/github-build-debian_oldstable_gcc | success | success |
| ltpci/github-build-opensuse-leap_latest_gcc | success | success |
| ltpci/github-build-debian_oldstable_clang | success | success |
| ltpci/github-build-opensuse-archive_42-2_gcc | success | success |
| ltpci/copilot-review | success | Approved |
| ltpci/github-build-ubuntu_noble_gcc | success | success |
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
>
>
Hi Michael, same comments of 1/4 Kind regards, -- Andrea Cervesato SUSE QE Automation Engineer Linux andrea.cervesato@suse.com
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), +};
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