Skip to contentSkip to conversation

futex: Add error coverage tests for wait, wake and cmp_requeue

PATCH Superseded Michael Menasherov via ltp 3 participants 13 messages May 27 – Jun 12

v14 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
#0 lore raw

v14 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.

v14:
- futex_cmp_requeue03: add note explaining why opflags=0 (no FUTEX_PRIVATE_FLAG) is required for EFAULT to be returned

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      | 102 ++++++++++++++++++
 .../kernel/syscalls/futex/futex_wait06.c      |  75 +++++++++++++
 .../kernel/syscalls/futex/futex_wait07.c      |  89 +++++++++++++++
 .../kernel/syscalls/futex/futex_wake05.c      |  89 +++++++++++++++
 6 files changed, 363 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.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH v14 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      | 75 +++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 testcases/kernel/syscalls/futex/futex_wait06.c
runtest/syscalls +1 -0
index f790e8f84..7d5ea849e 100644
@@ -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
testcases/kernel/syscalls/futex/.gitignore +1 -0
index 9d08ba7d3..56596dcb4 100644
@@ -13,3 +13,4 @@
 /futex_waitv01
 /futex_waitv02
 /futex_waitv03
+/futex_wait06
testcases/kernel/syscalls/futex/futex_wait06.c new file +75 -0

75 lines not on this page · raw message

Signature · 5 lines
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] futex_wait06: Add EFAULT error coverage test

Hi Michael,

Quoted 4 lines · Michael Menasherov

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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH v14 1/4] futex_wait06: Add EFAULT error coverage test

In reply to Michael Menasherov via ltp

Hi!

testcases/kernel/syscalls/futex/futex_wait06.c line 68

Quoted 4 lines
testcases/kernel/syscalls/futex/futex_wait06.c new file +4 -0
+	bad = SAFE_MMAP(NULL, getpagesize(), PROT_READ | PROT_WRITE,
+			MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+	SAFE_MUNMAP((void *)bad, getpagesize());
+}

I've changed the test to use the tst_get_bad_addr() library function isntead and pushed, thanks.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

PATCH v14 2/4 futex_wait07: Add EINTR error coverage test

In reply to Michael Menasherov via 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.

---
 runtest/syscalls                              |  1 +
 testcases/kernel/syscalls/futex/.gitignore    |  1 +
 .../kernel/syscalls/futex/futex_wait07.c      | 89 +++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 testcases/kernel/syscalls/futex/futex_wait07.c
runtest/syscalls +1 -0
index 7d5ea849e..e6c5d5112 100644
@@ -1869,6 +1869,7 @@ 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
testcases/kernel/syscalls/futex/.gitignore +1 -0
index 56596dcb4..74ac9a926 100644
@@ -14,3 +14,4 @@
 /futex_waitv02
 /futex_waitv03
 /futex_wait06
+/futex_wait07
testcases/kernel/syscalls/futex/futex_wait07.c new file +89 -0

89 lines not on this page · raw message

Signature · 5 lines
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Re: [LTP] [PATCH v14 2/4] futex_wait07: Add EINTR error coverage test

Hi!
Pushed, thanks.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

PATCH v14 3/4 futex_wake05: Add EFAULT error coverage test

In reply to Michael Menasherov via ltp

futex(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      | 89 +++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 testcases/kernel/syscalls/futex/futex_wake05.c
runtest/syscalls +1 -0
index e6c5d5112..8c4d9be6c 100644
@@ -1877,6 +1877,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
testcases/kernel/syscalls/futex/.gitignore +1 -0
index 74ac9a926..c11546e07 100644
@@ -15,3 +15,4 @@
 /futex_waitv03
 /futex_wait06
 /futex_wait07
+/futex_wake05
testcases/kernel/syscalls/futex/futex_wake05.c new file +89 -0

89 lines not on this page · raw message

Signature · 5 lines
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Re: [LTP] [PATCH v14 3/4] futex_wake05: Add EFAULT error coverage test

Hi!

Quoted 4 lines
testcases/kernel/syscalls/futex/futex_wake05.c new file +4 -0
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Red Hat, Inc.
+ * Copyright (C) 2026 Michael Menasherov <[email protected]>

testcases/kernel/syscalls/futex/futex_wake05.c line 14

Quoted 10 lines
testcases/kernel/syscalls/futex/futex_wake05.c new file +10 -0
+ */
+
+/*\
+ * Check that futex(FUTEX_WAKE) returns EFAULT when uaddr points to
+ * unmapped or PROT_NONE memory.
+ *
+ * The test uses opflags=0 (no FUTEX_PRIVATE_FLAG), so futex_wake() takes
+ * the shared-futex path in get_futex_key() which must resolve the physical
+ * page. For PROT_NONE memory this page lookup fails with EFAULT, even though
+ * futex_wake() never reads *uaddr.

Maybe this should be more explicit and say that the unmapped address takes different codepath than the PROT_NONE one. I had to check the get_futex_key() to realize that this is one of the syscalls where different types of EFAULT memory actually matters.

Also we have specific EFAULT handling for kernel addresses at the start of the futex, so figuring out a kernel address and passing it to the syscall would be a good idea as well.

Also there is a lot of NUMA specific code in there, so adding one more test that requires NUMA and tries to hit the NUMA specific codepaths would make sense as well.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

PATCH v14 4/4 futex_cmp_requeue03: Add EFAULT error coverage test

In reply to Michael Menasherov via 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.

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/futex/.gitignore    |   1 +
 .../syscalls/futex/futex_cmp_requeue03.c      | 102 ++++++++++++++++++
 3 files changed, 104 insertions(+)
 create mode 100644 testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
runtest/syscalls +1 -0
index 8c4d9be6c..87bd5aeac 100644
@@ -1863,6 +1863,7 @@ 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
testcases/kernel/syscalls/futex/.gitignore +1 -0
index c11546e07..231b6bd25 100644
@@ -16,3 +16,4 @@
 /futex_wait06
 /futex_wait07
 /futex_wake05
+/futex_cmp_requeue03
testcases/kernel/syscalls/futex/futex_cmp_requeue03.c new file +102 -0

102 lines not on this page · raw message

Signature · 5 lines
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw
In reply to Michael Menasherov via ltp

Hi,

Just following up on this patch series which has been in review since April 12th. We are now on v14 and all previous review comments have been fully addressed. The LTP AI Reviewer has approved all four patches with no issues found.

I understand maintainers are busy, but would really appreciate someone taking a look at this when time permits.

GitHub PR: https://github.com/linux-test-project/ltp/pull/1301

Thanks,
Michael Menasherov

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw
In reply to Michael Menasherov via ltp

Hi,

Following up on this patch series (v14) sent on May 27th. The LTP AI Reviewer has approved all four patches with no issues found, and all previous review comments have been fully addressed.

I noticed master hasn't had merges since May 13th — is there a freeze or quiet period I should be aware of? Happy to wait if so, just want to make sure the series isn't lost in the queue.

GitHub PR: https://github.com/linux-test-project/ltp/pull/1301

Thanks,
Michael Menasherov

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw

Hi!

Quoted 7 lines

Following up on this patch series (v14) sent on May 27th. The LTP AI Reviewer has approved all four patches with no issues found, and all previous review comments have been fully addressed.

I noticed master hasn't had merges since May 13th — is there a freeze or quiet period I should be aware of? Happy to wait if so, just want to make sure the series isn't lost in the queue.

Sorry for not replying earlier, we were mostly working on May stable release during May, hence no new features were reviewed and it took some time to get back to the backlog that accumulated during the release.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp