[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <whgf74jjaztowr36aivxcufbxdivfr6j3ef5u2yns5tdv73wmh@6ibbldmnuwbw>
Date: Mon, 10 Nov 2025 12:07:35 +0100
From: Jan Kara <jack@...e.cz>
To: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
Darren Hart <dvhart@...radead.org>, Davidlohr Bueso <dave@...olabs.net>,
André Almeida <andrealmeid@...lia.com>, Anna-Maria Behnsen <anna-maria@...utronix.de>,
Frederic Weisbecker <frederic@...nel.org>, linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] select: store end_time as timespec64 in restart block
On Mon 10-11-25 10:38:51, Thomas Weißschuh wrote:
> Storing the end time seconds as 'unsigned long' can lead to truncation
> on 32-bit architectures if assigned from the 64-bit timespec64::tv_sec.
> As the select() core uses timespec64 consistently, also use that in the
> restart block.
>
> This also allows the simplification of the accessors.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
Honza
> ---
> fs/select.c | 12 ++++--------
> include/linux/restart_block.h | 4 ++--
> 2 files changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/fs/select.c b/fs/select.c
> index 082cf60c7e2357dfd419c2128e38da95e3ef2ef3..5c3ce16bd251df9dfeaa562620483a257d7fd5d8 100644
> --- a/fs/select.c
> +++ b/fs/select.c
> @@ -1042,14 +1042,11 @@ static long do_restart_poll(struct restart_block *restart_block)
> {
> struct pollfd __user *ufds = restart_block->poll.ufds;
> int nfds = restart_block->poll.nfds;
> - struct timespec64 *to = NULL, end_time;
> + struct timespec64 *to = NULL;
> int ret;
>
> - if (restart_block->poll.has_timeout) {
> - end_time.tv_sec = restart_block->poll.tv_sec;
> - end_time.tv_nsec = restart_block->poll.tv_nsec;
> - to = &end_time;
> - }
> + if (restart_block->poll.has_timeout)
> + to = &restart_block->poll.end_time;
>
> ret = do_sys_poll(ufds, nfds, to);
>
> @@ -1081,8 +1078,7 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,
> restart_block->poll.nfds = nfds;
>
> if (timeout_msecs >= 0) {
> - restart_block->poll.tv_sec = end_time.tv_sec;
> - restart_block->poll.tv_nsec = end_time.tv_nsec;
> + restart_block->poll.end_time = end_time;
> restart_block->poll.has_timeout = 1;
> } else
> restart_block->poll.has_timeout = 0;
> diff --git a/include/linux/restart_block.h b/include/linux/restart_block.h
> index 7e50bbc94e476c599eb1185e02b6e87854fc3eb8..0798a4ae67c6c75749c38c4673ab8ea012261319 100644
> --- a/include/linux/restart_block.h
> +++ b/include/linux/restart_block.h
> @@ -6,6 +6,7 @@
> #define __LINUX_RESTART_BLOCK_H
>
> #include <linux/compiler.h>
> +#include <linux/time64.h>
> #include <linux/types.h>
>
> struct __kernel_timespec;
> @@ -50,8 +51,7 @@ struct restart_block {
> struct pollfd __user *ufds;
> int nfds;
> int has_timeout;
> - unsigned long tv_sec;
> - unsigned long tv_nsec;
> + struct timespec64 end_time;
> } poll;
> };
> };
>
> --
> 2.51.0
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists