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.

io_uring: switch struct ext_arg from __kernel_timespec to timespec64

This avoids intermediate storage for turning a __kernel_timespec
user pointer into an on-stack struct timespec64, only then to turn it
into a ktime_t.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+9 -10
+9 -10
io_uring/io_uring.c
··· 2495 2495 2496 2496 struct ext_arg { 2497 2497 size_t argsz; 2498 - struct __kernel_timespec __user *ts; 2498 + struct timespec64 ts; 2499 2499 const sigset_t __user *sig; 2500 2500 ktime_t min_time; 2501 + bool ts_set; 2501 2502 }; 2502 2503 2503 2504 /* ··· 2536 2535 iowq.timeout = KTIME_MAX; 2537 2536 start_time = io_get_time(ctx); 2538 2537 2539 - if (ext_arg->ts) { 2540 - struct timespec64 ts; 2541 - 2542 - if (get_timespec64(&ts, ext_arg->ts)) 2543 - return -EFAULT; 2544 - 2545 - iowq.timeout = timespec64_to_ktime(ts); 2538 + if (ext_arg->ts_set) { 2539 + iowq.timeout = timespec64_to_ktime(ext_arg->ts); 2546 2540 if (!(flags & IORING_ENTER_ABS_TIMER)) 2547 2541 iowq.timeout = ktime_add(iowq.timeout, start_time); 2548 2542 } ··· 3248 3252 */ 3249 3253 if (!(flags & IORING_ENTER_EXT_ARG)) { 3250 3254 ext_arg->sig = (const sigset_t __user *) argp; 3251 - ext_arg->ts = NULL; 3252 3255 return 0; 3253 3256 } 3254 3257 ··· 3262 3267 ext_arg->min_time = arg.min_wait_usec * NSEC_PER_USEC; 3263 3268 ext_arg->sig = u64_to_user_ptr(arg.sigmask); 3264 3269 ext_arg->argsz = arg.sigmask_sz; 3265 - ext_arg->ts = u64_to_user_ptr(arg.ts); 3270 + if (arg.ts) { 3271 + if (get_timespec64(&ext_arg->ts, u64_to_user_ptr(arg.ts))) 3272 + return -EFAULT; 3273 + ext_arg->ts_set = true; 3274 + } 3266 3275 return 0; 3267 3276 } 3268 3277