[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b816920b-a211-80c0-ceca-f716954b9f96@kernel.dk>
Date: Fri, 6 Mar 2020 07:57:07 -0700
From: Jens Axboe <axboe@...nel.dk>
To: Dan Carpenter <dan.carpenter@...cle.com>
Cc: Dmitry Vyukov <dvyukov@...gle.com>,
syzbot <syzbot+e017e49c39ab484ac87a@...kaller.appspotmail.com>,
Al Viro <viro@...iv.linux.org.uk>, io-uring@...r.kernel.org,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>,
LKML <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
syzkaller-bugs <syzkaller-bugs@...glegroups.com>,
Thomas Gleixner <tglx@...utronix.de>, tony.luck@...el.com,
the arch/x86 maintainers <x86@...nel.org>
Subject: Re: KASAN: use-after-free Read in percpu_ref_switch_to_atomic_rcu
On 3/6/20 7:35 AM, Dan Carpenter wrote:
>
> There a bunch of similar bugs. It's seems a common anti-pattern.
>
> block/blk-cgroup.c:85 blkg_free() warn: freeing 'blkg' which has percpu_ref_exit()
> block/blk-core.c:558 blk_alloc_queue_node() warn: freeing 'q' which has percpu_ref_exit()
> drivers/md/md.c:5528 md_free() warn: freeing 'mddev' which has percpu_ref_exit()
> drivers/target/target_core_transport.c:583 transport_free_session() warn: freeing 'se_sess' which has percpu_ref_exit()
> fs/aio.c:592 free_ioctx() warn: freeing 'ctx' which has percpu_ref_exit()
> fs/aio.c:806 ioctx_alloc() warn: freeing 'ctx' which has percpu_ref_exit()
> fs/io_uring.c:6115 io_sqe_files_unregister() warn: freeing 'data' which has percpu_ref_exit()
> fs/io_uring.c:6431 io_sqe_files_register() warn: freeing 'ctx->file_data' which has percpu_ref_exit()
> fs/io_uring.c:7134 io_ring_ctx_free() warn: freeing 'ctx' which has percpu_ref_exit()
> kernel/cgroup/cgroup.c:4948 css_free_rwork_fn() warn: freeing 'css' which has percpu_ref_exit()
> mm/backing-dev.c:615 cgwb_create() warn: freeing 'wb' which has percpu_ref_exit()
The file table io_uring issue is using the ref in a funky way, switching
in and out of atomic if we need to quiesce it. That's different from
other use cases, that just use it as a "normal" reference. Hence for the
funky use case, you can potentially have a switch in progress when you
exit the ref. You really want to wait for that, the easiest solution is
to punt the exit + free to an RCU callback, if there's nothing else you
need to handle once the switch is done.
So I would not be so quick to assume that similar patterns (exit + free)
have similar issues.
--
Jens Axboe
Powered by blists - more mailing lists