io_uring: don't touch scm_fp_list after queueing skb

[ Upstream commit a07211e300 ]

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: 6b06314c47 ("io_uring: add file set registration")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Pavel Begunkov 2022-04-06 12:43:58 +01:00 коммит произвёл Greg Kroah-Hartman
Родитель 50c981bd77
Коммит 285f5d7240
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -8126,8 +8126,12 @@ static int __io_sqe_files_scm(struct io_ring_ctx *ctx, int nr, int offset)
refcount_add(skb->truesize, &sk->sk_wmem_alloc);
skb_queue_head(&sk->sk_receive_queue, skb);
for (i = 0; i < nr_files; i++)
fput(fpl->fp[i]);
for (i = 0; i < nr; i++) {
struct file *file = io_file_from_index(ctx, i + offset);
if (file)
fput(file);
}
} else {
kfree_skb(skb);
free_uid(fpl->user);