Skip to content

Commit a07211e

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't touch scm_fp_list after queueing skb
It's safer to not touch scm_fp_list after we queued an skb to which it was assigned, there might be races lurking if we screw subtle sync guarantees on the io_uring side. Fixes: 6b06314 ("io_uring: add file set registration") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 34bb771 commit a07211e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/io_uring.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8631,8 +8631,12 @@ static int __io_sqe_files_scm(struct io_ring_ctx *ctx, int nr, int offset)
86318631
refcount_add(skb->truesize, &sk->sk_wmem_alloc);
86328632
skb_queue_head(&sk->sk_receive_queue, skb);
86338633

8634-
for (i = 0; i < nr_files; i++)
8635-
fput(fpl->fp[i]);
8634+
for (i = 0; i < nr; i++) {
8635+
struct file *file = io_file_from_index(ctx, i + offset);
8636+
8637+
if (file)
8638+
fput(file);
8639+
}
86368640
} else {
86378641
kfree_skb(skb);
86388642
free_uid(fpl->user);

0 commit comments

Comments
 (0)