From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 1/2] selftests/futex: run futex_waitv argument checks with a valid waitv
Date: Mon, 2 Nov 2026 22:04:37 +0200 [thread overview]
Message-ID: <20261102200610.2414832-2-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261102200610.2414832-1-eva.kurchatova@virtuozzo.com>
The argument checks reuse the waitv[] the shared subtest leaves behind,
whose entries point into detached memory, and the invalid clockid
check passes NULL waiters. So the kernel can reject a call for a
reason other than the one tested. This goes unnoticed while the checks
accept any result.
Reset waitv[] to valid private futexes before the checks and pass it to
the clockid check.
Fixes: 5e59c1d1c78c ("selftests: futex: Add sys_futex_waitv() test")
https://virtuozzo.atlassian.net/browse/VSTOR-152660
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
.../selftests/futex/functional/futex_waitv.c | 26 ++++++++++++++-----
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/futex/functional/futex_waitv.c b/tools/testing/selftests/futex/functional/futex_waitv.c
index 3706a32102c6..98edb25690d9 100644
--- a/tools/testing/selftests/futex/functional/futex_waitv.c
+++ b/tools/testing/selftests/futex/functional/futex_waitv.c
@@ -69,6 +69,18 @@ static int join_waiter(pthread_t waiter)
return failed != NULL;
}
+static void set_private_waitv(void)
+{
+ int i;
+
+ for (i = 0; i < NR_FUTEXES; i++) {
+ waitv[i].uaddr = (uintptr_t)&futexes[i];
+ waitv[i].flags = FUTEX_32 | FUTEX_PRIVATE_FLAG;
+ waitv[i].val = 0;
+ waitv[i].__reserved = 0;
+ }
+}
+
int main(int argc, char *argv[])
{
pthread_t waiter;
@@ -98,12 +110,7 @@ int main(int argc, char *argv[])
ksft_print_msg("%s: Test FUTEX_WAITV\n",
basename(argv[0]));
- for (i = 0; i < NR_FUTEXES; i++) {
- waitv[i].uaddr = (uintptr_t)&futexes[i];
- waitv[i].flags = FUTEX_32 | FUTEX_PRIVATE_FLAG;
- waitv[i].val = 0;
- waitv[i].__reserved = 0;
- }
+ set_private_waitv();
/* Private waitv */
if (pthread_create(&waiter, NULL, waiterfn, NULL))
@@ -165,6 +172,9 @@ int main(int argc, char *argv[])
for (i = 0; i < NR_FUTEXES; i++)
shmdt(u64_to_ptr(waitv[i].uaddr));
+ /* Each check below breaks one argument of an otherwise valid call */
+ set_private_waitv();
+
/* Testing a waiter without FUTEX_32 flag */
waitv[0].flags = FUTEX_PRIVATE_FLAG;
@@ -237,12 +247,14 @@ int main(int argc, char *argv[])
}
/* Testing an invalid clockid */
+ waitv[0].uaddr = (uintptr_t)&futexes[0];
+
if (clock_gettime(CLOCK_MONOTONIC, &to))
error("gettime64 failed\n", errno);
to.tv_sec++;
- res = futex_waitv(NULL, NR_FUTEXES, 0, &to, CLOCK_TAI);
+ res = futex_waitv(waitv, NR_FUTEXES, 0, &to, CLOCK_TAI);
if (res == EINVAL) {
ksft_test_result_fail("futex_waitv private returned: %d %s\n",
res ? errno : res,
--
2.56.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-02 20:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 20:04 [Devel] [PATCH hci-8.1 0/2] selftests/futex: correct validation logic in waitv Eva Kurchatova
2026-11-02 20:04 ` Eva Kurchatova [this message]
2026-11-02 20:09 ` [Devel] [PATCH hci-8.1 1/2] selftests/futex: run futex_waitv argument checks with a valid waitv no-reply
2026-11-03 15:13 ` Konstantin Khorenko
2026-11-02 20:04 ` [Devel] [PATCH hci-8.1 2/2] ms/selftests/futex: Correct validation logic in waitv Eva Kurchatova
2026-11-02 20:10 ` no-reply
2026-11-03 15:13 ` [Devel] [PATCH hci-8.1 0/2] selftests/futex: correct " Konstantin Khorenko
2026-11-03 15:14 ` Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261102200610.2414832-2-eva.kurchatova@virtuozzo.com \
--to=eva.kurchatova@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox