๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13923

Re: [PATCH net-next v11 08/12] net/rds: hold a connection reference from struct rds_incoming

#13923
From: netdev-bot+sashiko
Date: Tue, 10 Nov 2026 13:57
96 lines
11566 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] With this patch, every rds_incoming holds a reference on its
  connection.

--

net/rds: hold a connection reference from struct rds_incoming

This patch makes every holder of rds_incoming->i_conn own a connection
reference. The references are taken in rds_inc_init(), rds_inc_path_init(),
rds_recv_incoming() and the three m_inc assignment sites in send.c. They
are dropped from rds_inc_put() and from a new rds_message_free() helper,
which fixes a use-after-free when a transport unload destroys a connection
that queued incs still point at.

Closes: https://lore.kernel.org/netdev/20260720184955.3008978-1-nicoyip.dev@gmail.com/

[ ... ]

> diff --git a/net/rds/recv.c b/net/rds/recv.c
> index 00ab60f2d9969..e4cae82c16818 100644
> --- a/net/rds/recv.c
> +++ b/net/rds/recv.c
> @@ -46,6 +46,7 @@ void rds_inc_init(struct rds_incoming *inc, struct rds_connection *conn,
>  {
>  	refcount_set(&inc->i_refcount, 1);
>  	INIT_LIST_HEAD(&inc->i_item);
> +	rds_conn_get(conn);	/* put in rds_inc_put() */
>  	inc->i_conn = conn;
>  	inc->i_conn_path = NULL;
>  	inc->i_saddr = *saddr;

[Severity: Medium]
With this reference, an unread inc on a socket receive queue keeps its
connection, and so the transport's t_conn_count, elevated until the
application reads the datagram or closes the socket. Can that block
rmmod of a transport forever?

rds_tcp_exit() and rds_ib_exit() both call rds_conn_wait_conns_freed().
That loop exits only when t_conn_count reaches zero:

net/rds/connection.c:rds_conn_wait_conns_freed() {
    ...
	while (!wait_event_timeout(rds_conn_freed_waitq,
				   !atomic_read(&trans->t_conn_count),
				   msecs_to_jiffies(RDS_CONN_FREE_POLL_MS))) {
    ...
}

The loop never checks for signals, so nobody can kill the rmmod task, and
the module stays in MODULE_STATE_GOING. The task wakes every 100ms, so the
hung-task detector doesn't report it either. The only sign is the pr_warn
every 10 seconds.

rds_find_bound() matches only on address, port and scope_id. It doesn't
compare rs->rs_transport with conn->c_trans. A socket bound with one
transport (through SO_RDS_TRANSPORT or rds_trans_get_preferred()) can
therefore queue incs that arrived over another transport's connection,
without holding a module reference on that transport:

  unprivileged process: binds an RDS socket using IB, never reads it
  remote peer: connects to the rds_tcp listener and sends to that port
    rds_recv_incoming()->rds_find_bound() matches the IB-bound socket
    the inc is queued on rs_recv_queue, holding a TCP conn reference
  admin: rmmod rds_tcp
    rds_tcp_exit()->rds_conn_wait_conns_freed() never returns

Before this patch, only the hash-table reference and short-lived
references pinned a connection, so the wait added earlier in the series
always finished.

The commit message says this is intended:

  "It also means the transport cannot unload while such a datagram is
   unread ... That is the intended behaviour"

However, it lets an unprivileged application decide how long a privileged
unload stays stuck. Could the unload path instead purge the departing
transport's incs from socket receive queues? Or could the wait be made
interruptible or abortable?

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261106031615.1047052-1-achender%40kernel.org
Technical Details
Message-ID: <179431907345.994134.1298028433995703002@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360278-linux-kernel-netdev=dewy.ru
References: <20261106031615.1047052-9-achender@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360278-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v11 08/12] net/rds: hold a connection reference
 from struct rds_incoming
Date: Tue, 10 Nov 2026 13:57:53 +0000
Organization: Usenet Network
Message-ID: <179431907345.994134.1298028433995703002@kernel.org>
References: <20261106031615.1047052-9-achender@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="622432"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CuC0RdrMpTYp/8FfbPxjuGdYj0w= sha256:yziYINjRY6Vcq7hl0aho4kOwaJS7a/Fv3+HuGrwp3vY=
	sha1:1nhcg9se91iLo9Pz4Br3XAgr8a8= sha256:EphwFIoGxe641Q+MKadqm3jx5SaWyKYDWALCtgnwmZQ=
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 E7C30113BBF; Tue, 10 Nov 2026 17:06:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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, URIBL_BLOCKED=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 L0ac42vjzagR;
	Tue, 10 Nov 2026 17:06:18 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-360278-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id D07B3113BB9; Tue, 10 Nov 2026 17:06:09 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 1BB821268CC; Tue, 10 Nov 2026 13:58:04 +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=1794319080;
	b=e3Cd7THhBKlWUaP0Eu3KBmfFGs/sLsWlYm61XPzaq6DxwKQhKAzsOyPcBbM+6o7r9Bh6
	 z5b/rU6PHfZQLGL6kSenQpxlXHDevLwRJWD1SxgYgjebrQ/T3bQEmszQINUfKJp2aX8AU
	 D96Nqkrp8aaM4od3YNl5S8oK0vdHzJQHl3vWf8PTtYfsBkLtjusAi93TKzp/gm+LeQPNw
	 d6riD8cXWKbAz89lxnAT5bIAeXGu8RYL+M8fviKFlkqZQPwEjhDhjth5+H63/0LZB248Q
	 GGgnMWUfP/Zl3BRiocG8Xeqpsg9xPR58arMsijCOXmVx5e/tG/qBa0YgnzTgZ8stvNA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794319080;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=YFjW35zvvJYki6kMAd/FYXGvh/Dc0hX3ITs/Jgj221g=;
	b=x7b3P6W99ApJeGmBpLOLR2cC6TMoo7THPgbWDbPTMsDlXLhzx1+45rhzJgF/4dEi/cAp
	 VbsmJfHq7RPCPo4qRSbtf+mSgPW980hV7cH4+MLra8/sQ4xSeEEGqu0C38YyBtU4jyZTX
	 Par20ZGsepUtnoSjCNaE5JwdGhWmBSAhmZv0hSvvNSWR1Q45wuaoJRI566uiwcu1NJ+b6
	 5CafOkm5vcTDQ03cqL1A4DZmSecee0trjGfbqm0Mrmae488lI0q4qgrr73WOrd2d4562T
	 JxyM9y30pcFQ4ttZlmi/IMCEy4mygHn4YMJ+H9oDhRNzOh6/kglZt6f9ofZ98xK4HFQ==
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=krAdlZcS;
	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 CFC66606A33C;
	Tue, 10 Nov 2026 13:58:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=krAdlZcS
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=1794319075;
	b=2wn1IC6xkpNw/ShxnFCppHwF5aZMp8lbbF9nQp+4ktsLAZl88YaznEqy9oG+I2R5mFE/
	 hS4P5O2ue2MhJUEDjXnKXwFwid/sgVHTyrSeqspGmRmCnj9gBVXC3+BBe8yQre1eVETzd
	 1/Pt7veSwHZqBIfOQvG/21DkL+xkr8fiw1R07HprJ0pQeiN9S5fQpTSvdXUIJOQWVZMYe
	 VMPpVdcW/+zmG5fp9kQiVzvz7WbZ7XkmYJhFzsrDq33xLnlMJZ/bglgOXEei6864qJmm+
	 uhWH7CJ2Qy4KE4BdPkKQ4OioCCkqDNH7EtXM0/mHcINXuCghuK+ydiqNVa+ZRxEcXdA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794319075;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=YFjW35zvvJYki6kMAd/FYXGvh/Dc0hX3ITs/Jgj221g=;
	b=Ht25Wj7nu/7OvYGr0UR9uiWlmdWLE5qHzhGlfrOtXovXG+bJNxAnFcjQ0jMTD89aF+UP
	 9d0wvcHd8JAaKGe36RCD6ZmlZhiDWiMXo0ha6H4IOfeD1xIXjnMTYbkUvvIWl3VNc1PZe
	 c/zLIK45juFfcEHsQXn5CrqwcwUlfzm5Vk15IjPllGyatm9wUk0xThwh5z4y3CcPKX+GI
	 vRSBk2yHduTf4VDAU6wPxoRZsClrJypoNeUxz8EGGgqg5YS3Tk2E6ISI8XNcOe0/6AY76
	 xkBMeL5O+Cf6DV0h6qkxqlAccxNIAZd5n/UGNF0gPZW2EqlqqYpjde6h4Pk3M1j3k/g==
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=krAdlZcS;
	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 AC8ED606A31C;
	Tue, 10 Nov 2026 13:57:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF6611F008BC;
	Tue, 10 Nov 2026 13:57:53 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794319074;
	bh=YFjW35zvvJYki6kMAd/FYXGvh/Dc0hX3ITs/Jgj221g=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=krAdlZcSRj0nnmM43Q8bCuQOwVZWdvkiafW4cwyjURCSVctnGpVGivC394Dj+2jnj
	 3HE6E66hnE/HFLkkj8jARceXSGMZ3HHpk/yx1ppe93IqjkAmOFnLHwwKla4B4ibukw
	 OgJgZdWP9haC41YFqXTdSOMKn1kOrksnMmHEVXLbohT2C6lvvkpnM1Lsln0RcA4dae
	 Qalx2mVlYJLap5pqvaCPWUvugpj1Wzn9jFtx4VkmeR6ksCaawUZHMmnTf4U8uDz54Z
	 3zWA4t+wvUZjobEprnJhoY9E8Vj2YeGaBviQOoj3bhu/HEvf+1FZMbBl45HWVcisJp
	 hNM5mMjnc71FQ==
X-Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, pabeni@redhat.com,
 edumazet@google.com, kuba@kernel.org, horms@kernel.org
X-In-Reply-To: <20261106031615.1047052-9-achender@kernel.org>
X-sashiko-severity: Medium
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