futex: Add EFAULT coverage for wake and cmp_requeue
v15 cover futex: Add EFAULT coverage for wake and cmp_requeue
futex_wait06 and futex_wait07 were already merged. This series contains the two remaining patches.
Patch 1/2 (futex_wake05) is v15 — updated based on review feedback to add a kernel-space address test case and clarify the comment explaining the different code paths in get_futex_key().
Patch 2/2 (futex_cmp_requeue03) has not yet received a human review. It was part of the previous series and addresses EFAULT coverage for FUTEX_CMP_REQUEUE. Would appreciate a review of this patch as well.
GitHub PR: https://github.com/linux-test-project/ltp/pull/1301
Michael Menasherov (2):
futex_wake05: Add EFAULT error coverage test
futex_cmp_requeue03: Add EFAULT error coverage test
runtest/syscalls | 2 + testcases/kernel/syscalls/futex/.gitignore | 2 + .../syscalls/futex/futex_cmp_requeue03.c | 102 ++++++++++++++++++ .../kernel/syscalls/futex/futex_wake05.c | 101 +++++++++++++++++ 4 files changed, 207 insertions(+) create mode 100644 testcases/kernel/syscalls/futex/futex_cmp_requeue03.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
PATCH v15 1/2 futex_wake05: Add EFAULT error coverage test
futex(FUTEX_WAKE) has no existing test for EFAULT. Add coverage for unmapped, PROT_NONE, and kernel-space uaddr, each exercising a different code path in the kernel's address validation.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/futex/.gitignore | 1 + .../kernel/syscalls/futex/futex_wake05.c | 101 ++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 testcases/kernel/syscalls/futex/futex_wake05.c
runtest/syscalls +1 -0
@@ -1878,6 +1878,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
@@ -15,3 +15,4 @@ /futex_waitv03 /futex_wait06 /futex_wait07 +/futex_wake05
testcases/kernel/syscalls/futex/futex_wake05.c new file +101 -0
101 lines not on this page · raw message
Signature · 5 lines
2.54.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] futex_wake05: Add EFAULT error coverage test
Hi Michael,
Quoted 1 line · Michael Menasherov
futex_cmp_requeue03: Add EFAULT error coverage test
--- [PATCH 2/2] ---
Quoted 3 lines
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.
The commit message says "uaddr or uaddr2 points to ... inaccessible (PROT_NONE) memory", but the test only covers uaddr with PROT_NONE. There is no "uaddr2 PROT_NONE" test case. Since get_futex_key() is called independently for uaddr2, it would be consistent to add coverage for that case too, or alternatively narrow the commit message to match what is actually tested.
Verdict - Needs revision
---
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
Re: [LTP] [PATCH v15 1/2] futex_wake05: Add EFAULT error coverage test
In reply to Michael Menasherov via ltp--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v15 1/2] futex_wake05: Add EFAULT error coverage test
In reply to Michael Menasherov via ltpHi!
Quoted 6 lines
+/*\
+ * Check thatfutex(FUTEX_WAKE)returns EFAULT when uaddr points to
+ * unmapped,PROT_NONE, or kernel-space memory.
+ *
+ * For the unmapped andPROT_NONEcases, opflags=0 (noFUTEX_PRIVATE_FLAG)
+ * ensuresfutex_wake()takes the shared-futex path inget_futex_key()
Quoted 8 lines
+ * which must resolve the physical page. For
PROT_NONEmemory this page
+ * lookup fails with EFAULT, even thoughfutex_wake()never reads *uaddr.
+ *
+ * The three cases exercise different code paths: a kernel-space address
+ * is rejected by the kernel's user-space address check before physical
+ * page resolution; unmapped memory fails atfind_vma()(no VMA exists);
+ *PROT_NONEmemory fails atget_user_pages_fast()(VMA exists but page
+ * is inaccessible).
Now we have to paragraphs here with some amount of duplicit information, I would simplify it as:
...
* For opflags=0 (no FUTEX_PRIVATE_FLAG) futex_wake() takes the
* shared-futex path in get_futex_key() which must resolve the physical
* page.
*
* The three cases exercise different code paths: a kernel-space address
* is rejected by the kernel's user-space address check before physical
* page resolution; unmapped memory fails at find_vma() (no VMA exists);
* PROT_NONE memory fails at get_user_pages_fast() (VMA exists but page
* is inaccessible).
...
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v15 2/2 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 | 102 ++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
runtest/syscalls +1 -0
@@ -1864,6 +1864,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
@@ -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
Re: [LTP] [PATCH v15 2/2] futex_cmp_requeue03: Add EFAULT error coverage test
Hi Michael,
the patch LGTM, but agent is right: we are missing a unaccessible memory test for addr2.
{
.desc = "uaddr2 PROT_NONE",
.uaddr = &futex_ptr,
.uaddr2 = &prot_none_addr,
.exp_errno = EFAULT,
},The test description is mentioning this check but there's no trace of it inside test code.
Please send a follow-up patch, then we can merge it if no issues will pop up.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp