io_uring: fix double free in the deferred/cancelled path
Subsystems (2)
PATCH 1/1 io_uring: fix double free in the deferred/cancelled path
792bb6eb86233 ("io_uring: don't take uring_lock during iowq cancel") inadvertently fixed this issue in v5.12. This patch cherry-picks the hunk of commit which does so.
Syzbot vomit (snipped):
==================================================================
BUG: KASAN: double-free or invalid-free in slab_free mm/slub.c:3195 [inline] BUG: KASAN: double-free or invalid-free in kfree+0xca/0x310 mm/slub.c:4183 CPU: 1 PID: 431 Comm: syz-executor823 Not tainted 5.10.75-syzkaller-01082-g234d53d2bb60 #0 Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233 kasan_report_invalid_free+0x58/0x130 mm/kasan/report.c:358 ____kasan_slab_free+0x14b/0x170 mm/kasan/common.c:362 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1596 [inline] slab_free_freelist_hook+0xb2/0x180 mm/slub.c:1621 slab_free mm/slub.c:3195 [inline] kfree+0xca/0x310 mm/slub.c:4183 __io_queue_deferred fs/io_uring.c:1541 [inline] io_commit_cqring+0x76a/0xa00 fs/io_uring.c:1587 io_iopoll_complete fs/io_uring.c:2378 [inline] io_do_iopoll+0x1e18/0x23f0 fs/io_uring.c:2431 io_iopoll_try_reap_events+0x116/0x290 fs/io_uring.c:2470 io_ring_ctx_wait_and_kill+0x295/0x670 fs/io_uring.c:8575 io_uring_release+0x5b/0x70 fs/io_uring.c:8602 __fput+0x348/0x7d0 fs/file_table.c:281 ____fput+0x15/0x20 fs/file_table.c:314 task_work_run+0x147/0x1b0 kernel/task_work.c:154 exit_task_work include/linux/task_work.h:30 [inline] do_exit+0x70e/0x23a0 kernel/exit.c:813 do_group_exit+0x16a/0x2d0 kernel/exit.c:910 __do_sys_exit_group+0x17/0x20 kernel/exit.c:921 __se_sys_exit_group+0x14/0x20 kernel/exit.c:919 __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:919 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- fs/io_uring.c | 2 ++ 1 file changed, 2 insertions(+)
fs/io_uring.c +2 -0
@@ -2075,7 +2075,9 @@ static void io_req_task_cancel(struct callback_head *cb) struct io_kiocb *req = container_of(cb, struct io_kiocb, task_work);struct io_ring_ctx *ctx = req->ctx; +mutex_lock (&ctx->uring_lock);__io_req_task_cancel (req, -ECANCELED ); +mutex_unlock (&ctx->uring_lock);percpu_ref_put (&ctx->refs); }
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Quoted 3 lines · Lee Jones
792bb6eb86233("io_uring: don't takeuring_lockduring iowq cancel") inadvertently fixed this issue in v5.12. This patch cherry-picks the hunk of commit which does so.
Why can't we take all of that commit? Why only part of it?
thanks,
greg k-h
Quoted 6 lines · Greg KH
Quoted 3 lines · Lee Jones
792bb6eb86233("io_uring: don't takeuring_lockduring iowq cancel") inadvertently fixed this issue in v5.12. This patch cherry-picks the hunk of commit which does so.Why can't we take all of that commit? Why only part of it?
I don't know.
Why didn't the Stable team take it further than v5.11.y?
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 7 lines · Lee Jones
Quoted 5 lines · Greg KH
Quoted 3 lines · Lee Jones
792bb6eb86233("io_uring: don't takeuring_lockduring iowq cancel") inadvertently fixed this issue in v5.12. This patch cherry-picks the hunk of commit which does so.
Quoted 5 lines
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
I don't know.
Why didn't the Stable team take it further than v5.11.y?
Look in the archives? Did it not apply cleanly?
/me goes off and looks...
Looks like I asked for a backport, but no one did it, I only received a 5.11 version:
https://lore.kernel.org/r/1839646480a26a2461eccc38a75e98998d2d6e11.1615375332.git.asml.silence@gmail.com
so a 5.10 version would be nice, as I said it failed as-is:
https://lore.kernel.org/all/[email protected]/
lore archives are your friend :)
thanks,
greg k-h
Quoted 16 lines · Greg KH
Quoted 7 lines · Lee Jones
Quoted 5 lines · Greg KH
Quoted 3 lines · Lee Jones
792bb6eb86233("io_uring: don't takeuring_lockduring iowq cancel") inadvertently fixed this issue in v5.12. This patch cherry-picks the hunk of commit which does so.Quoted 5 lines
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
I don't know.
Why didn't the Stable team take it further than v5.11.y?
Look in the archives? Did it not apply cleanly?
Quoted 8 lines
/me goes off and looks...
Looks like I asked for a backport, but no one did it, I only received a 5.11 version:
https://lore.kernel.org/r/1839646480a26a2461eccc38a75e98998d2d6e11.1615375332.git.asml.silence@gmail.comso a 5.10 version would be nice, as I said it failed as-is:
https://lore.kernel.org/all/[email protected]/
Precisely. This is the answer to your question:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
Same reason the Stable team didn't back-port it - it doesn't apply.
The second hunk is only relevant to v5.11+.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 27 lines · Lee Jones
Quoted 16 lines · Greg KH
Quoted 7 lines · Lee Jones
Quoted 5 lines · Greg KH
Quoted 3 lines · Lee Jones
792bb6eb86233("io_uring: don't takeuring_lockduring iowq cancel") inadvertently fixed this issue in v5.12. This patch cherry-picks the hunk of commit which does so.Quoted 5 lines
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
I don't know.
Why didn't the Stable team take it further than v5.11.y?
Look in the archives? Did it not apply cleanly?
Quoted 8 lines
/me goes off and looks...
Looks like I asked for a backport, but no one did it, I only received a 5.11 version:
https://lore.kernel.org/r/1839646480a26a2461eccc38a75e98998d2d6e11.1615375332.git.asml.silence@gmail.comso a 5.10 version would be nice, as I said it failed as-is:
https://lore.kernel.org/all/[email protected]/
Quoted 7 lines
Precisely. This is the answer to your question:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
Same reason the Stable team didn't back-port it - it doesn't apply.
The second hunk is only relevant to v5.11+.
Great, then use the "normal" stable style, but down in the s-o-b area say "dropped second chunk as it is not relevant to 5.10.y".
thanks,
greg k-h
Quoted 30 lines · Greg KH
Quoted 29 lines · Lee Jones
Quoted 16 lines · Greg KH
Quoted 7 lines · Lee Jones
Quoted 5 lines · Greg KH
Quoted 3 lines · Lee Jones
792bb6eb86233("io_uring: don't takeuring_lockduring iowq cancel") inadvertently fixed this issue in v5.12. This patch cherry-picks the hunk of commit which does so.Quoted 5 lines
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
I don't know.
Why didn't the Stable team take it further than v5.11.y?
Look in the archives? Did it not apply cleanly?
Quoted 8 lines
/me goes off and looks...
Looks like I asked for a backport, but no one did it, I only received a 5.11 version:
https://lore.kernel.org/r/1839646480a26a2461eccc38a75e98998d2d6e11.1615375332.git.asml.silence@gmail.comso a 5.10 version would be nice, as I said it failed as-is:
https://lore.kernel.org/all/[email protected]/Precisely. This is the answer to your question:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
Same reason the Stable team didn't back-port it - it doesn't apply.
The second hunk is only relevant to v5.11+.
Great, then use the "normal" stable style, but down in the s-o-b area say "dropped second chunk as it is not relevant to 5.10.y".
Just to clarify, by "normal", you mean:
- Take the original patch
- Apply an "[ Upstream commit <id> ]" tag (or similar)
- Remove the hunk that doesn't apply
- Make a note of the aforementioned action
- Submit to Stable
Rather than submitting a bespoke patch. Right?
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 41 lines · Lee Jones
Quoted 30 lines · Greg KH
Quoted 29 lines · Lee Jones
Quoted 16 lines · Greg KH
Quoted 7 lines · Lee Jones
Quoted 5 lines · Greg KH
Quoted 3 lines · Lee Jones
792bb6eb86233("io_uring: don't takeuring_lockduring iowq cancel") inadvertently fixed this issue in v5.12. This patch cherry-picks the hunk of commit which does so.Quoted 5 lines
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
I don't know.
Why didn't the Stable team take it further than v5.11.y?
Look in the archives? Did it not apply cleanly?
Quoted 8 lines
/me goes off and looks...
Looks like I asked for a backport, but no one did it, I only received a 5.11 version:
https://lore.kernel.org/r/1839646480a26a2461eccc38a75e98998d2d6e11.1615375332.git.asml.silence@gmail.comso a 5.10 version would be nice, as I said it failed as-is:
https://lore.kernel.org/all/[email protected]/Precisely. This is the answer to your question:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
Same reason the Stable team didn't back-port it - it doesn't apply.
The second hunk is only relevant to v5.11+.
Great, then use the "normal" stable style, but down in the s-o-b area say "dropped second chunk as it is not relevant to 5.10.y".
Quoted 7 lines
Just to clarify, by "normal", you mean:
- Take the original patch
- Apply an "[ Upstream commit <id> ]" tag (or similar)
- Remove the hunk that doesn't apply
- Make a note of the aforementioned action
- Submit to Stable
Yes.
Quoted 1 line
Rather than submitting a bespoke patch. Right?
Correct.
thanks,
greg k-h
Quoted 50 lines · Greg KH
Quoted 41 lines · Lee Jones
Quoted 30 lines · Greg KH
Quoted 29 lines · Lee Jones
Quoted 16 lines · Greg KH
Quoted 7 lines · Lee Jones
Quoted 5 lines · Greg KH
Quoted 3 lines · Lee Jones
792bb6eb86233("io_uring: don't takeuring_lockduring iowq cancel") inadvertently fixed this issue in v5.12. This patch cherry-picks the hunk of commit which does so.Quoted 5 lines
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
I don't know.
Why didn't the Stable team take it further than v5.11.y?
Look in the archives? Did it not apply cleanly?
Quoted 8 lines
/me goes off and looks...
Looks like I asked for a backport, but no one did it, I only received a 5.11 version:
https://lore.kernel.org/r/1839646480a26a2461eccc38a75e98998d2d6e11.1615375332.git.asml.silence@gmail.comso a 5.10 version would be nice, as I said it failed as-is:
https://lore.kernel.org/all/[email protected]/Precisely. This is the answer to your question:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Why can't we take all of that commit? Why only part of it?
Same reason the Stable team didn't back-port it - it doesn't apply.
The second hunk is only relevant to v5.11+.
Great, then use the "normal" stable style, but down in the s-o-b area say "dropped second chunk as it is not relevant to 5.10.y".
Quoted 7 lines
Just to clarify, by "normal", you mean:
- Take the original patch
- Apply an "[ Upstream commit <id> ]" tag (or similar)
- Remove the hunk that doesn't apply
- Make a note of the aforementioned action
- Submit to Stable
Quoted 5 lines
Yes.
Quoted 1 line
Rather than submitting a bespoke patch. Right?
Correct.
Got it, thanks. Wilco.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog