Commit 1c47c0d
committed
io_uring/rsrc: ensure compat iovecs are copied correctly
For buffer registration (or updates), a userspace iovec is copied in
and updated. If the application is within a compat syscall, then the
iovec type is compat_iovec rather than iovec. However, the type used
in __io_sqe_buffers_update() and io_sqe_buffers_register() is always
struct iovec, and hence the source is incremented by the size of a
non-compat iovec in the loop. This misses every other iovec in the
source, and will run into garbage half way through the copies and
return -EFAULT to the application.
Maintain the source address separately and assign to our user vec
pointer, so that copies always happen from the right source address.
While in there, correct a bad placement of __user which triggered
the following sparse warning prior to this fix:
io_uring/rsrc.c:981:33: warning: cast removes address space '__user' of expression
io_uring/rsrc.c:981:30: warning: incorrect type in assignment (different address spaces)
io_uring/rsrc.c:981:30: expected struct iovec const [noderef] __user *uvec
io_uring/rsrc.c:981:30: got struct iovec *[noderef] __user
Fixes: f4eaf8e ("io_uring/rsrc: Drop io_copy_iov in favor of iovec API")
Reviewed-by: Gabriel Krisman Bertazi <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>1 parent e0ee967 commit 1c47c0d
1 file changed
+15
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
398 | 397 | | |
399 | 398 | | |
400 | 399 | | |
| 400 | + | |
| 401 | + | |
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
| |||
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
413 | | - | |
| 414 | + | |
| 415 | + | |
414 | 416 | | |
415 | 417 | | |
416 | 418 | | |
| |||
443 | 445 | | |
444 | 446 | | |
445 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
446 | 452 | | |
447 | 453 | | |
448 | 454 | | |
| |||
949 | 955 | | |
950 | 956 | | |
951 | 957 | | |
952 | | - | |
| 958 | + | |
953 | 959 | | |
954 | 960 | | |
955 | 961 | | |
| |||
972 | 978 | | |
973 | 979 | | |
974 | 980 | | |
975 | | - | |
| 981 | + | |
| 982 | + | |
976 | 983 | | |
977 | 984 | | |
978 | 985 | | |
979 | 986 | | |
980 | 987 | | |
981 | 988 | | |
982 | 989 | | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
983 | 994 | | |
984 | 995 | | |
985 | 996 | | |
| |||
0 commit comments