🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5920

Re: rds_wq UAF

#5920
From: Allison Henderson
Date: Wed, 21 Oct 2026 08:36
87 lines
10891 bytes
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:
> 
Technical Details
Message-ID: <e7888169bdc76ea40fcfe782c2bc9b70e037dfc6.camel@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349891-linux-kernel-netdev=dewy.ru
References: <202610190310.9737b2e3-lkp@intel.com> <atYB0bm9eEXp8A2g@redhat.com> <atYW0K3t57puHeLW@hobbes> <atYuE1xnVYe0BDG4@redhat.com> <atY42k00k0Waj6o4@redhat.com> <42964fa071bd8dcafd418c89be6d66856def4dc5.camel@kernel.org> <atdoGiW_sHlWgOwt@redhat.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349891-linux-kernel-netdev=dewy.ru
From: achender@kernel.org (Allison Henderson)
Newsgroups: linux.kernel.netdev
Subject: Re: rds_wq UAF
Date: Wed, 21 Oct 2026 01:36:36 -0700
Organization: Usenet Network
Message-ID: <e7888169bdc76ea40fcfe782c2bc9b70e037dfc6.camel@kernel.org>
References: <202610190310.9737b2e3-lkp@intel.com>
	 <atYB0bm9eEXp8A2g@redhat.com> <atYW0K3t57puHeLW@hobbes>
	 <atYuE1xnVYe0BDG4@redhat.com> <atY42k00k0Waj6o4@redhat.com>
	 <42964fa071bd8dcafd418c89be6d66856def4dc5.camel@kernel.org>
	 <atdoGiW_sHlWgOwt@redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="4077436"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:QPDClpGAmbVgT/gqxPvDyPE9kaM= sha256:56IIy6BuDwC6IxHvr7W9aaeoVQGOAAPp9k9wN3iN1ug=
	sha1:xAz0IBLa1C3uGmDpUq3zpkrSJx8= sha256:3s599cJ84TSObx9ntvHiUcdrJAlf5kFlapkuEYRdHag=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 543AA110F7C; Wed, 21 Oct 2026 11:37:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.829
X-Spam-Status: No, score=-3.829 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.329, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id tBEzkgOVpsCg;
	Wed, 21 Oct 2026 11:37:22 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-349891-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id BA0E9110F48; Wed, 21 Oct 2026 11:37:13 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 7099E614846; Wed, 21 Oct 2026 08:36:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792571809;
	b=BovDgBz3k7fLZIShENcXXJ4MDXZFrlDQFu1eYr8osXXzxVunePBkId8YTqpo/giVh0Wc
	 /K/tx0eUQI8G8mffb8Z/oc/+fA4brMnZg+vzNNQglmR9MXIQtcH0xlYRYAaiAmwm9x+M6
	 Ea27WiG3K8nubFdeoTbFoxTPTk1H0euolkCetHdqAsCDQ9R9Afta38d1YTodWnG4xzKhl
	 QiaQAcWnr+NfPqvjKLMsD/8BvqVV92JAa3Lw9hFD87C5EsXI9nohzqIkC/zLnE08Bsk3s
	 QtGAmYZsjkDgmgV7wVJfEn4qL4ip8H6z4tlhh9lI9Zp8hdtYfbjr9yumM7czEE4W7qw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792571809;
	h=X-Original-To:Received:Received:DKIM-Signature:Message-ID:Subject:
	 From:To:Cc:Date:In-Reply-To:References:Content-Type:
	 Content-Transfer-Encoding:User-Agent:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version;
	bh=9K9KRsEaxoM/l89/G7N6lVBzd9yD1GfxwhXMyc+Mzdk=;
	b=bu6hHAbX5MaaGAkLw/c5TiNRtBt4y86POc2VQd+zZg1TIjW5lqWQbeXWxKebC0y6F+Tw
	 Ur++VsZd/2Z/zug+NQojny/edSlAU6JdpLkHXYuavz9+GLbyjaQUi8bd+Ats+/SE66B7I
	 a5k43WOfO7RB+zsbjn8ZNTNb9r6Kdjcpg4p1fjeRXCLdFase54veFcee7W4LaLLX1LTaZ
	 1asDLb0PGegJhZcndmDpQcY67MGl1Y1Nh5NJaVrref+aCUpITa98dP4YsZbKjmWI3BGoi
	 P9rmLYA9BMxuKFkcLU3IgaPqF0hxit3B6V1OMpnYnl8wsASMcIswDQdeDqlfx9eMnCQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hyTAEOUl;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BE31606A327;
	Wed, 21 Oct 2026 08:36:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hyTAEOUl
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792571798;
	b=rlwSVO0ZCnRePMieEXUqgR5pGvrQ7rfXYALufTREtpVJWAHwAJHPLWumOx61EC8KuJM3
	 AoCP15RKP7j9mVOY8uB0gGNYa/VhDnFBmnrclRnBSh7d1VwmkX/syLxiogT5sPTRzBIiK
	 EANOsB8qOBHs9Y4JgOOh6mMGLl0SoNBqd2z7tjIkCik7PnLsg+sl7NrEhyJxWgAaF5eiC
	 fWKKuwYF37PMWa3D01Lcn1d+dkuIF3T8+mITIMnOHQnG2O10dfbSc/YE0mykzGQ/tCHqT
	 jobo765VekWNAk60iOe6ZmXVrbS9HI4sBprPh8abmxfe54ckez084U+s+Y/8jXatGCg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792571798;
	h=Received:DKIM-Signature:Message-ID:Subject:From:To:Cc:Date:
	 In-Reply-To:References:Content-Type:Content-Transfer-Encoding:
	 User-Agent:MIME-Version;
	bh=9K9KRsEaxoM/l89/G7N6lVBzd9yD1GfxwhXMyc+Mzdk=;
	b=Zsbao67LUzrULRszENB5/1leF/ODU47xKmH0dKXzBpaprVqdvJ0b4mXMyA+/9Q+6tbe1
	 6G2uZAY6LovoHRMwGNtUbUUT6WMNnrlL3dxGgJhA1MCRYgopvaDNE18KmZdZMmd0BrGw3
	 IxQcTZ34G9peyJwXxiQkM0SndHTZAkRYVeIV9x0H6IQyGb7bgWC/D03A4G/KNS9F9DX+3
	 y3Gj/U3yXjBtwPbWZDLKFqCAS0er863G3rayxLCuU/XlrLRf1wrOtnUdCL5tJS7Jr3mrv
	 8ctMV5vLL5TdclczNvOn8IeKXAEFP0CJ42OVj4XZGW3g8iENIoVWsiI//N2j3Xys+Ag==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hyTAEOUl;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16D1C606A319;
	Wed, 21 Oct 2026 08:36:37 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D01C1F000C9;
	Wed, 21 Oct 2026 08:36:37 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792571797;
	bh=9K9KRsEaxoM/l89/G7N6lVBzd9yD1GfxwhXMyc+Mzdk=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=hyTAEOUlLJ/6crVLQzgFPw5YC+r+R5PbTBPw29STrIIYl2Cjfj+WPZsT/QLY5NUnu
	 urFfRgJEQfsgwZnOQV8u9PGNchT8igPnjOfz/w1Qy3Jgyn9HJlpVMrYXSeOONeklbH
	 Xj0kS2H2acSMiVJxLoxAqpEjUET8LaUL8UWCyPLd+GEsBSskNh8w/7I+TvaQwmPyri
	 APQ0zQgHqoFxXSLTeJX48AWyUagcUZaiu8Zsaip8tMiG89VE/eNmTLqXAnng4UZWx7
	 b/FDAEwBv0KglNmnfNdQkXU/MrQUO9sZQALThtBUm45H9CCpcRKzX+ZiFHLvlOEdFB
	 GIxBg8zxlrUCw==
X-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
X-In-Reply-To: <atdoGiW_sHlWgOwt@redhat.com>
X-User-Agent: Evolution 3.52.3-0ubuntu1.1 
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list