From: Jens Axboe <[email protected]>
To: Pavel Begunkov <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCH] io_uring: double freeing req caches
Date: Mon, 22 Feb 2021 06:32:08 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <756158e9db165fcb380f1f60c347b1d70bc65491.1613994305.git.asml.silence@gmail.com>
On 2/22/21 4:45 AM, Pavel Begunkov wrote:
> BUG: KASAN: double-free or invalid-free in io_req_caches_free.constprop.0+0x3ce/0x530 fs/io_uring.c:8709
>
> Workqueue: events_unbound io_ring_exit_work
> Call Trace:
> [...]
> __cache_free mm/slab.c:3424 [inline]
> kmem_cache_free_bulk+0x4b/0x1b0 mm/slab.c:3744
> io_req_caches_free.constprop.0+0x3ce/0x530 fs/io_uring.c:8709
> io_ring_ctx_free fs/io_uring.c:8764 [inline]
> io_ring_exit_work+0x518/0x6b0 fs/io_uring.c:8846
> process_one_work+0x98d/0x1600 kernel/workqueue.c:2275
> worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
> kthread+0x3b1/0x4a0 kernel/kthread.c:292
> ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
>
> Freed by task 11900:
> [...]
> kmem_cache_free_bulk+0x4b/0x1b0 mm/slab.c:3744
> io_req_caches_free.constprop.0+0x3ce/0x530 fs/io_uring.c:8709
> io_uring_flush+0x483/0x6e0 fs/io_uring.c:9237
> filp_close+0xb4/0x170 fs/open.c:1286
> close_files fs/file.c:403 [inline]
> put_files_struct fs/file.c:418 [inline]
> put_files_struct+0x1d0/0x350 fs/file.c:415
> exit_files+0x7e/0xa0 fs/file.c:435
> do_exit+0xc27/0x2ae0 kernel/exit.c:820
> do_group_exit+0x125/0x310 kernel/exit.c:922
> [...]
>
> io_req_caches_free() doesn't zero submit_state->free_reqs, so io_uring
> considers just freed requests to be good and sound and will reuse or
> double free them. Zero the counter.
Oops indeed, thanks! Applied.
--
Jens Axboe
prev parent reply other threads:[~2021-02-22 13:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 11:45 [PATCH] io_uring: double freeing req caches Pavel Begunkov
2021-02-22 13:32 ` Jens Axboe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox