From: Allison Henderson <achender@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Joel Granados <joel.granados@kernel.org>,
kernel test robot <yi1.lai@intel.com>,
oe-lkp@lists.linux.dev, lkp@intel.com,
linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org,
netdev@vger.kernel.org, wireguard@lists.zx2c4.com,
rds-devel@oss.oracle.com
Subject: Re: rds_wq UAF
Date: Wed, 21 Oct 2026 01:36:36 -0700 [thread overview]
Message-ID: <e7888169bdc76ea40fcfe782c2bc9b70e037dfc6.camel@kernel.org> (raw)
In-Reply-To: <atdoGiW_sHlWgOwt@redhat.com>
On Tue, 2026-10-20 at 15:09 +0200, Oleg Nesterov wrote:
> (change subject)
>
> On 10/19, Allison Henderson wrote:
> >
> > On Mon, 2026-10-19 at 17:35 +0200, Oleg Nesterov wrote:
> > > >
> > > > But. rds_init() can also fail even if CONFIG_SYSCTL=y, after
> > > > rds_sysctl_init(), so to me this looks like a bug in net/rds/.
> > > >
> >
> > Yes that's a separate bug, so I'll send a separate fix for that.
>
> Let me try to summarize.
>
> If rds_init() fails after rds_threads_init() for any reason,
> rds_threads_exit() will destroy/free rds_wq.
>
> If rds_rdma_init() is called after that, and rds_ib_init() fails
> after rds_ib_mr_init(), rds_ib_unregister_client() will try to
> flush the already freed rds_wq.
>
> But we have
>
> module_init(rds_init); // net/rds/af_rds.c
> module_init(rds_rdma_init); // net/rds/rdma_transport.c
>
> and IIUC the order of these initcalls is not defined. So if
> rds_rdma_init() -> rds_ib_init() is called before rds_init(), it
> can do flush_workqueue(rds_wq) when rds_wq == NULL on failure.
It is sort of defined. When built as modules the order is enforced by
symbol dependencies. rds_rdma and rds_tcp need symbols exported by rds
(rds_wq itself is one of them), so they can't be loaded unless rds_init()
succeeded. So the rds_wq == NULL case can't happen.
What can happen is what was reported: built in, rds_init() fails,
do_initcalls() keeps going, and rds_rdma_init()/rds_tcp_init() run against
a core that has already been torn down.
>
> With or without CONFIG_SYSCTL. Right?
>
> But it seems that rds_ib_init() doesn't need to flush rds_wq on failure,
> so how about the patch below? Of course, I have no idea if net/rds has
> more similar issues with rds_wq.
>
> Oleg.
> ---
>
> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 786f39169bc1..cde2d1bfabbd 100644
> --- a/net/rds/ib.c
> +++ b/net/rds/ib.c
> @@ -619,7 +619,7 @@ int rds_ib_init(void)
> out_sysctl:
> rds_ib_sysctl_exit();
> out_ibreg:
> - rds_ib_unregister_client();
> + ib_unregister_client(&rds_ib_client);
This works for when there are no IB devices, as in the report, but the flush
is what ensures rds_ib_dev_free() has finished before rds_rdma.ko's text goes away.
If there is a device, ib_register_client() has already called rds_ib_add_one().
Then ib_unregister_client() calls rds_ib_remove_one(), which drops the last
reference. And then rds_ib_dev_put() does queue_work(rds_wq, ...) on the
freed workqueue anyway.
So I think the fix belongs at the transport init: if the core didn't
come up, rds_rdma_init() and rds_tcp_init() should return early,
before they register anything. I can send that along with the
sysctl change tomorrow.
Thanks for working on this!
Allison
> out_mr_exit:
> rds_ib_mr_exit();
> out:
>
next prev parent reply other threads:[~2026-10-21 8:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 1:46 [linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map kernel test robot
2026-10-19 11:41 ` Oleg Nesterov
2026-10-19 13:30 ` Joel Granados
2026-10-19 14:49 ` Oleg Nesterov
2026-10-19 15:35 ` Oleg Nesterov
2026-10-19 19:52 ` Allison Henderson
2026-10-20 9:12 ` Oleg Nesterov
2026-10-20 10:51 ` Joel Granados
2026-10-20 10:43 ` Joel Granados
2026-10-20 11:05 ` Oleg Nesterov
2026-10-21 8:57 ` Joel Granados
2026-10-20 13:09 ` rds_wq UAF Oleg Nesterov
2026-10-21 8:36 ` Allison Henderson [this message]
2026-10-21 9:37 ` Oleg Nesterov
2026-10-21 13:10 ` sashiko-bot
2026-10-20 9:06 ` [linus:master] [sysctl] 8d75c338f0: BUG:KASAN:slab-use-after-free_in_touch_wq_lockdep_map Joel Granados
2026-10-20 9:24 ` Oleg Nesterov
2026-10-20 7:55 ` Joel Granados
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 \
--in-reply-to=e7888169bdc76ea40fcfe782c2bc9b70e037dfc6.camel@kernel.org \
--to=achender@kernel.org \
--cc=joel.granados@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-s390@vger.kernel.org \
--cc=lkp@intel.com \
--cc=netdev@vger.kernel.org \
--cc=oe-lkp@lists.linux.dev \
--cc=oleg@redhat.com \
--cc=rds-devel@oss.oracle.com \
--cc=wireguard@lists.zx2c4.com \
--cc=yi1.lai@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.