Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

select: store end_time as timespec64 in restart block

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@linutronix.de>
Link: https://patch.msgid.link/20251223-restart-block-expiration-v2-1-8e33e5df7359@linutronix.de
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Thomas Weißschuh and committed by
Christian Brauner
0f166bf1 3685744a

+6 -10
+4 -8
fs/select.c
··· 1038 1038 { 1039 1039 struct pollfd __user *ufds = restart_block->poll.ufds; 1040 1040 int nfds = restart_block->poll.nfds; 1041 - struct timespec64 *to = NULL, end_time; 1041 + struct timespec64 *to = NULL; 1042 1042 int ret; 1043 1043 1044 - if (restart_block->poll.has_timeout) { 1045 - end_time.tv_sec = restart_block->poll.tv_sec; 1046 - end_time.tv_nsec = restart_block->poll.tv_nsec; 1047 - to = &end_time; 1048 - } 1044 + if (restart_block->poll.has_timeout) 1045 + to = &restart_block->poll.end_time; 1049 1046 1050 1047 ret = do_sys_poll(ufds, nfds, to); 1051 1048 ··· 1074 1077 restart_block->poll.nfds = nfds; 1075 1078 1076 1079 if (timeout_msecs >= 0) { 1077 - restart_block->poll.tv_sec = end_time.tv_sec; 1078 - restart_block->poll.tv_nsec = end_time.tv_nsec; 1080 + restart_block->poll.end_time = end_time; 1079 1081 restart_block->poll.has_timeout = 1; 1080 1082 } else 1081 1083 restart_block->poll.has_timeout = 0;
+2 -2
include/linux/restart_block.h
··· 6 6 #define __LINUX_RESTART_BLOCK_H 7 7 8 8 #include <linux/compiler.h> 9 + #include <linux/time64.h> 9 10 #include <linux/types.h> 10 11 11 12 struct __kernel_timespec; ··· 51 50 struct pollfd __user *ufds; 52 51 int nfds; 53 52 int has_timeout; 54 - unsigned long tv_sec; 55 - unsigned long tv_nsec; 53 + struct timespec64 end_time; 56 54 } poll; 57 55 }; 58 56 };