From: Avi Weiss <thnkslprpt@gmail.com>
To: Christian Brauner <brauner@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
Breno Leitao <leitao@debian.org>,
Arjan van de Ven <arjan@linux.intel.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] fs/select: reject negative timeval components in do_compat_select()
Date: Sat, 31 Oct 2026 10:31:00 +0200 [thread overview]
Message-ID: <20261031083059.3245047-2-thnkslprpt@gmail.com> (raw)
do_compat_select() normalizes old_timeval32 before validating the
timeout. Negative seconds and microseconds can cancel each other,
causing compat select() and old_select() to accept invalid timeouts.
Reject negative components before normalization (as kern_select()
already does) - and preserve the handling of oversized positive
tv_usec values.
A 32-bit syscall reproducer confirmed four incorrect results on the
unpatched kernel. With the fix applied, all my test cases passed on
both compat select interfaces.
Fixes: 4d36a9e65d49 ("select: deal with math overflow from borderline valid userland data")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
fs/select.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/select.c b/fs/select.c
index 95d76531015aa..8b6d1dd2977c6 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -1265,6 +1265,8 @@ static int do_compat_select(int n, compat_ulong_t __user *inp,
if (copy_from_user(&tv, tvp, sizeof(tv)))
return -EFAULT;
+ if (tv.tv_sec < 0 || tv.tv_usec < 0)
+ return -EINVAL;
to = &end_time;
if (poll_select_set_timeout(to,
tv.tv_sec + (tv.tv_usec / USEC_PER_SEC),
base-commit: 36aad21d50d1af3f6954bb0c988257a908202477
--
2.43.0
reply other threads:[~2026-10-31 8:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261031083059.3245047-2-thnkslprpt@gmail.com \
--to=thnkslprpt@gmail.com \
--cc=arjan@linux.intel.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=leitao@debian.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®