diff mbox series

[v4,1/4] futex_wait06: Add EFAULT error coverage test

Message ID 20260507111809.28934-2-mmenashe@redhat.com
State Changes Requested
Headers show
Series futex: Add error coverage tests for wait, wake and cmp_requeue | expand

Checks

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

Commit Message

Michael Menasherov May 7, 2026, 11:18 a.m. UTC
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

Comments

linuxtestproject.agent@gmail.com May 7, 2026, 12:01 p.m. UTC | #1
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 May 13, 2026, 8:35 a.m. UTC | #2
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 May 18, 2026, 6:23 p.m. UTC | #3
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/>
>
Andrea Cervesato May 19, 2026, 8:25 a.m. UTC | #4
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
Andrea Cervesato May 19, 2026, 2:44 p.m. UTC | #5
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
diff mbox series

Patch

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),
+};