@@ -2384,13 +2384,18 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
2384
2384
return ret ;
2385
2385
}
2386
2386
2387
+ struct ext_arg {
2388
+ size_t argsz ;
2389
+ struct __kernel_timespec __user * ts ;
2390
+ const sigset_t __user * sig ;
2391
+ };
2392
+
2387
2393
/*
2388
2394
* Wait until events become available, if we don't already have some. The
2389
2395
* application must reap them itself, as they reside on the shared cq ring.
2390
2396
*/
2391
2397
static int io_cqring_wait (struct io_ring_ctx * ctx , int min_events , u32 flags ,
2392
- const sigset_t __user * sig , size_t sigsz ,
2393
- struct __kernel_timespec __user * uts )
2398
+ struct ext_arg * ext_arg )
2394
2399
{
2395
2400
struct io_wait_queue iowq ;
2396
2401
struct io_rings * rings = ctx -> rings ;
@@ -2415,25 +2420,25 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, u32 flags,
2415
2420
iowq .cq_tail = READ_ONCE (ctx -> rings -> cq .head ) + min_events ;
2416
2421
iowq .timeout = KTIME_MAX ;
2417
2422
2418
- if (uts ) {
2423
+ if (ext_arg -> ts ) {
2419
2424
struct timespec64 ts ;
2420
2425
2421
- if (get_timespec64 (& ts , uts ))
2426
+ if (get_timespec64 (& ts , ext_arg -> ts ))
2422
2427
return - EFAULT ;
2423
2428
2424
2429
iowq .timeout = timespec64_to_ktime (ts );
2425
2430
if (!(flags & IORING_ENTER_ABS_TIMER ))
2426
2431
iowq .timeout = ktime_add (iowq .timeout , io_get_time (ctx ));
2427
2432
}
2428
2433
2429
- if (sig ) {
2434
+ if (ext_arg -> sig ) {
2430
2435
#ifdef CONFIG_COMPAT
2431
2436
if (in_compat_syscall ())
2432
- ret = set_compat_user_sigmask ((const compat_sigset_t __user * )sig ,
2433
- sigsz );
2437
+ ret = set_compat_user_sigmask ((const compat_sigset_t __user * )ext_arg -> sig ,
2438
+ ext_arg -> argsz );
2434
2439
else
2435
2440
#endif
2436
- ret = set_user_sigmask (sig , sigsz );
2441
+ ret = set_user_sigmask (ext_arg -> sig , ext_arg -> argsz );
2437
2442
2438
2443
if (ret )
2439
2444
return ret ;
@@ -3112,9 +3117,8 @@ static int io_validate_ext_arg(unsigned flags, const void __user *argp, size_t a
3112
3117
return 0 ;
3113
3118
}
3114
3119
3115
- static int io_get_ext_arg (unsigned flags , const void __user * argp , size_t * argsz ,
3116
- struct __kernel_timespec __user * * ts ,
3117
- const sigset_t __user * * sig )
3120
+ static int io_get_ext_arg (unsigned flags , const void __user * argp ,
3121
+ struct ext_arg * ext_arg )
3118
3122
{
3119
3123
struct io_uring_getevents_arg arg ;
3120
3124
@@ -3123,24 +3127,24 @@ static int io_get_ext_arg(unsigned flags, const void __user *argp, size_t *argsz
3123
3127
* is just a pointer to the sigset_t.
3124
3128
*/
3125
3129
if (!(flags & IORING_ENTER_EXT_ARG )) {
3126
- * sig = (const sigset_t __user * ) argp ;
3127
- * ts = NULL ;
3130
+ ext_arg -> sig = (const sigset_t __user * ) argp ;
3131
+ ext_arg -> ts = NULL ;
3128
3132
return 0 ;
3129
3133
}
3130
3134
3131
3135
/*
3132
3136
* EXT_ARG is set - ensure we agree on the size of it and copy in our
3133
3137
* timespec and sigset_t pointers if good.
3134
3138
*/
3135
- if (* argsz != sizeof (arg ))
3139
+ if (ext_arg -> argsz != sizeof (arg ))
3136
3140
return - EINVAL ;
3137
3141
if (copy_from_user (& arg , argp , sizeof (arg )))
3138
3142
return - EFAULT ;
3139
3143
if (arg .pad )
3140
3144
return - EINVAL ;
3141
- * sig = u64_to_user_ptr (arg .sigmask );
3142
- * argsz = arg .sigmask_sz ;
3143
- * ts = u64_to_user_ptr (arg .ts );
3145
+ ext_arg -> sig = u64_to_user_ptr (arg .sigmask );
3146
+ ext_arg -> argsz = arg .sigmask_sz ;
3147
+ ext_arg -> ts = u64_to_user_ptr (arg .ts );
3144
3148
return 0 ;
3145
3149
}
3146
3150
@@ -3246,15 +3250,14 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
3246
3250
}
3247
3251
mutex_unlock (& ctx -> uring_lock );
3248
3252
} else {
3249
- const sigset_t __user * sig ;
3250
- struct __kernel_timespec __user * ts ;
3253
+ struct ext_arg ext_arg = { .argsz = argsz };
3251
3254
3252
- ret2 = io_get_ext_arg (flags , argp , & argsz , & ts , & sig );
3255
+ ret2 = io_get_ext_arg (flags , argp , & ext_arg );
3253
3256
if (likely (!ret2 )) {
3254
3257
min_complete = min (min_complete ,
3255
3258
ctx -> cq_entries );
3256
3259
ret2 = io_cqring_wait (ctx , min_complete , flags ,
3257
- sig , argsz , ts );
3260
+ & ext_arg );
3258
3261
}
3259
3262
}
3260
3263
0 commit comments