Skip to content

Commit 1292e97

Browse files
esyr-rhaxboe
authored andcommitted
io_uring: fix compat for IORING_REGISTER_FILES_UPDATE
fds field of struct io_uring_files_update is problematic with regards to compat user space, as pointer size is different in 32-bit, 32-on-64-bit, and 64-bit user space. In order to avoid custom handling of compat in the syscall implementation, make fds __u64 and use u64_to_user_ptr in order to retrieve it. Also, align the field naturally and check that no garbage is passed there. Fixes: c3a31e6 ("io_uring: add support for IORING_REGISTER_FILES_UPDATE") Signed-off-by: Eugene Syromiatnikov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 44d2827 commit 1292e97

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

fs/io_uring.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4463,13 +4463,15 @@ static int io_sqe_files_update(struct io_ring_ctx *ctx, void __user *arg,
44634463
return -EINVAL;
44644464
if (copy_from_user(&up, arg, sizeof(up)))
44654465
return -EFAULT;
4466+
if (up.resv)
4467+
return -EINVAL;
44664468
if (check_add_overflow(up.offset, nr_args, &done))
44674469
return -EOVERFLOW;
44684470
if (done > ctx->nr_user_files)
44694471
return -EINVAL;
44704472

44714473
done = 0;
4472-
fds = (__s32 __user *) up.fds;
4474+
fds = u64_to_user_ptr(up.fds);
44734475
while (nr_args) {
44744476
struct fixed_file_table *table;
44754477
unsigned index;

include/uapi/linux/io_uring.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ struct io_uring_params {
178178

179179
struct io_uring_files_update {
180180
__u32 offset;
181-
__s32 *fds;
181+
__u32 resv;
182+
__aligned_u64 /* __s32 * */ fds;
182183
};
183184

184185
#endif

0 commit comments

Comments
 (0)