Skip to content

Commit d785a77

Browse files
committed
io_uring: check that we have a file table when allocating update slots
If IORING_FILE_INDEX_ALLOC is set asking for an allocated slot, the helper doesn't check if we actually have a file table or not. The non alloc path does do that correctly, and returns -ENXIO if we haven't set one up. Do the same for the allocated path, avoiding a NULL pointer dereference when trying to find a free bit. Fixes: a7c41b4 ("io_uring: let IORING_OP_FILES_UPDATE support choosing fixed file slots") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent bdb2c48 commit d785a77

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/io_uring.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7973,6 +7973,9 @@ static int io_files_update_with_index_alloc(struct io_kiocb *req,
79737973
struct file *file;
79747974
int ret, fd;
79757975

7976+
if (!req->ctx->file_data)
7977+
return -ENXIO;
7978+
79767979
for (done = 0; done < req->rsrc_update.nr_args; done++) {
79777980
if (copy_from_user(&fd, &fds[done], sizeof(fd))) {
79787981
ret = -EFAULT;

0 commit comments

Comments
 (0)