io_uring resource handling fixes
PATCH 1/2 io_uring: nospec index for tags on files update
In reply to Pavel BegunkovDon't forget to array_index_nospec() for indexes before updating rsrc tags in __io_sqe_files_update(), just use already safe and precalculated index @i.
--- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
@@ -9294,7 +9294,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx, err = -EBADF ;break ; } - *io_get_tag_slot (data, up->offset + done) = tag; + *io_get_tag_slot (data, i) = tag;io_fixed_file_set (file_slot, file); err =io_sqe_file_register (ctx, file, i);if (err) {
Signature · 1 line
2.35.1
cover io_uring resource handling fixes
Two small fixes for rsrc infrastructure
Pavel Begunkov (2):
io_uring: nospec index for tags on files update
io_uring: don't touch scm_fp_list after queueing skb
fs/io_uring.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Signature · 1 line
2.35.1
PATCH 2/2 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.
--- fs/io_uring.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/io_uring.c +6 -2
@@ -8831,8 +8831,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);
Signature · 1 line
2.35.1
Quoted 8 lines · Pavel Begunkov
Two small fixes for rsrc infrastructure
Pavel Begunkov (2):
io_uring: nospec index for tags on files update
io_uring: don't touchscm_fp_listafter queueing skbfs/io_uring.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Thanks, applied.
Signature · 1 line
Jens Axboe