🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23967

Re: [PATCH net v3] net/smc: bound the DMB-nocopy send-buffer credit by what was sent

#23967
From: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 18:17
203 lines
15556 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 3

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] The new bound in smc_cdc_msg_recv_action()
  (net/smc/smc_cdc.c:381-384) reads the live cursor conn->tx_curs_sent…
- [Low] The commit message says "smc_switch_cursor() uses the longer
  distance, but it rewinds tx_curs_sent to tx_curs_fin first and…
- [Low] The commit message says the problem "is not reachable from a
  hostile peer today" and that "this is hardening rather than a fix for…
- [Low] The new block comment in smc_cdc_msg_recv_action()
  (net/smc/smc_cdc.c:365-380) refers to "the fin <= sent <= prep order…

--

net/smc: bound the DMB-nocopy send-buffer credit by what was sent

On the SMC-D DMB-nocopy path, the send-buffer credit taken from the
peer's consumer cursor in smc_cdc_msg_recv_action() is now bounded by
the bytes sent but not yet confirmed (tx_curs_fin to tx_curs_sent).
tx_curs_fin is advanced by the bounded amount instead of being assigned
the reported cursor.

Link: https://lore.kernel.org/all/179552966151.3135.8162716126718648323@kernel.org/

> Unlike the failover path in smc_switch_cursor() this is not reachable
> from a hostile peer today.

[ ... ]

> So this is
> hardening rather than a fix for an observed attack

[Severity: Low]
The message describes this as hardening with no in-tree trigger, but it
also carries:

> Fixes: cc0ab806fc52 ("net/smc: adapt cursor update when sndbuf and peer DMB are merged")

v2 was also posted against net.

The patched branch only runs when smc_ism_support_dmb_nocopy() is true.
The only provider of support_mmapped_rdmb() is
drivers/dibs/dibs_loopback.c. The overflow was only reproduced with a
debug patch that forges the cursor.

Should this go to net-next without the Fixes: tag instead? The maintainers
will need to decide which tree it targets and whether the tag stays.

> smc_switch_cursor() uses the longer
> distance, but it rewinds tx_curs_sent to tx_curs_fin first and advances
> both, so the order holds there; here only tx_curs_fin moves.

[Severity: Low]
Is this accurate for the tree this patch lands in? In this tree,
smc_switch_cursor() applies an unbounded diff taken from the peer's
cursor:

net/smc/smc_core.c:smc_switch_cursor() {
    ...
	if (smc_curs_comp(conn->peer_rmbe_size, &cons, &fin) < 0) {
		...
		diff = smc_curs_diff(conn->peer_rmbe_size, &fin, &cons);
		smc_curs_add(conn->sndbuf_desc->len,
			     &conn->tx_curs_sent, diff);
		smc_curs_add(conn->sndbuf_desc->len,
			     &conn->tx_curs_fin, diff);

		smp_mb__before_atomic();
		atomic_add(diff, &conn->sndbuf_space);
    ...
}

It has no sndbuf_desc->len - sndbuf_space limit. That bound seems to come
from the companion patch "net/smc: drop the connection when the peer's
failover cursor is impossible". This commit neither contains that patch
nor names it as a prerequisite.

Could the sentence be dropped, or could it name the companion patch
explicitly?

> diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
> index 32d6d03df3214..ecac93023d327 100644
> --- a/net/smc/smc_cdc.c
> +++ b/net/smc/smc_cdc.c

[ ... ]

> @@ -361,13 +362,34 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
>  			diff_tx = smc_curs_diff(conn->sndbuf_desc->len,
>  						&conn->tx_curs_fin,
>  						&conn->local_rx_ctrl.cons);
> +			/* This difference comes from the cursor the peer
> +			 * reported, which is taken as it arrives.  The peer
> +			 * can only have consumed what this side actually
> +			 * sent - smc_tx_rdma_writes() advances tx_curs_sent
> +			 * together with the producer cursor the peer sees -
> +			 * so bound it by that and advance tx_curs_fin by the
> +			 * bounded amount rather than assigning the reported
> +			 * cursor.  The invariant below then holds by
> +			 * construction, tx_curs_fin stays inside the send
> +			 * buffer, and it stays at or behind tx_curs_sent:
> +			 * bounding by sndbuf_desc->len - sndbuf_space would
> +			 * also admit bytes that are only PREPARED, which
> +			 * would move tx_curs_fin past tx_curs_sent and break
> +			 * the fin <= sent <= prep order the three cursors are
> +			 * documented with.
> +			 */

[Severity: Low]
Where is this order documented? The commit message also says "the
fin <= sent <= prep order the three cursors are documented with in
smc.h".

In net/smc/smc.h, struct smc_connection describes each cursor on its own
and states no ordering between them:

	union smc_host_cursor	tx_curs_prep;	/* tx - prepared data
						 * snd_max..wmem_alloc
						 */
	union smc_host_cursor	tx_curs_sent;	/* tx - sent data
						 * snd_nxt ?
						 */
	union smc_host_cursor	tx_curs_fin;	/* tx - confirmed by peer
						 * snd-wnd-begin ?
						 */

Could the order be added to the smc.h struct comment, or stated here as
its own rule?

> +			unconfirmed = smc_curs_diff(conn->sndbuf_desc->len,
> +						    &conn->tx_curs_fin,
> +						    &conn->tx_curs_sent);
> +			diff_tx = min_t(int, diff_tx, unconfirmed);

[Severity: Medium]
Can this read of conn->tx_curs_sent tear? smc_curs_diff() loads
new->wrap and new->count separately. Nothing here takes a snapshot of
tx_curs_sent, and send_lock is not held.

The writer can run at the same time on another CPU:

smc_tx_sendmsg()                     (lock_sock() owner, slock dropped)
  smc_tx_sndbuf_nonempty()
    smcd_tx_sndbuf_nonempty()        (spin_lock_bh(&conn->send_lock))
      smc_tx_rdma_writes()
        smc_curs_copy(&conn->tx_curs_sent, &sent, conn);

The reader runs as:

smcd_cdc_rx_tsklet()
  smc_cdc_msg_recv()                 (bh_lock_sock() only)
    smc_cdc_msg_recv_action()

Take fin = {W, f}, old sent = {W, c1} and new sent = {W+1, c2}, with
c2 <= f.

If the read sees {W, c2}, unconfirmed is 0 and a valid credit is
dropped. Neither sndbuf_space nor tx_curs_fin advances, although the peer
has confirmed those bytes. The credit only comes back on a later CDC that
moves cons.

If the lost amount is more than half the buffer, the receiver's
smc_tx_consumer_update() may never send another update. Could a
unidirectional sender then block in smc_tx_wait() with
sndbuf_space == 0? This stall was not traced end to end.

If the read sees {W+1, c1}, which needs load reordering, unconfirmed is
>= len. min_t() then does not limit a forged cursor, so the overflow this
patch closes is open again inside that window.

Other readers of tx_curs_sent outside send_lock take a snapshot first.
One example is smc_tx_prepared_sends(), which this function calls a few
lines later:

net/smc/smc_tx.h:smc_tx_prepared_sends() {
    ...
	smc_curs_copy(&sent, &conn->tx_curs_sent, conn);
	smc_curs_copy(&prep, &conn->tx_curs_prep, conn);
	return smc_curs_diff(sndbuf_desc->len, &sent, &prep);
}

Would it work to take a local snapshot with
smc_curs_copy(&sent, &conn->tx_curs_sent, conn) and diff against &sent?
A stale but consistent value should be safe for this bound.

> +
>  			/* increase local sndbuf space and fin_curs */
>  			smp_mb__before_atomic();
>  			atomic_add(diff_tx, &conn->sndbuf_space);

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124180257.622064-1-piyus%40iiitd.ac.in
Technical Details
Message-ID: <179588986049.3135.2340709178320333740@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373258-linux-kernel-netdev=dewy.ru
References: <20261124180257.622064-1-piyus@iiitd.ac.in>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373258-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3] net/smc: bound the DMB-nocopy send-buffer credit
 by what was sent
Date: Sat, 28 Nov 2026 18:17:40 +0000
Organization: Usenet Network
Message-ID: <179588986049.3135.2340709178320333740@kernel.org>
References: <20261124180257.622064-1-piyus@iiitd.ac.in>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1004446"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WOl6MkLLSDZhvobPPyzuSVrhGk4= sha256:kgi6Hi7rEue0WvU7fpiao4HxSy40qAlx/YDSZjTtKN8=
	sha1:WgKgiGCGuwS1GSHTUhDUR3llVnY= sha256:hIq+TSUmwfWZVw3fSWSP/mHE5Hmwl8znIgMaVNRlDtc=
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 12D15125F87; Sat, 28 Nov 2026 21:18:06 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 gDOmnCJ0VRgF;
	Sat, 28 Nov 2026 21:18:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-373258-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id A6AAE125F86; Sat, 28 Nov 2026 21:17:52 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 0539E2410C; Sat, 28 Nov 2026 18:17:50 +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=1795889868;
	b=I3MXXhgwaPJ9dxRdVLUQUDtcHsbSMmyS5/+QA+cu6XzUWFJRPoJO/0jh699U9nhSnGp+
	 8ygNaGtbXWcOngj4l7ebsk+/IpEFRHXhLpSXFFbJ3iuKI2mzssXHSegw9hOMIUuee279j
	 jNPQqDjJ9mP3KA7d+63VU4FzzbWxP38aMpJSc/PA4oC0sQ/J51Ql3UEeGqyFnYojefC9d
	 O26OxEFjs8Fw7grIwdCTfRtbzWcRFmGdoFmPT8QJgQa3ehfPwRgrfVK3fP4KKOjfuQWLd
	 Hrk/DSaUSAmPgzLzwbpF5J4Qn4lDoEdYl3tjsN/9b5cKe4GymFUprHyz2kF9D0xhaEQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795889868;
	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=ZdRFz1P+O2wUOFarXzrOPnFL0+E/BJQ0reSXyFaBVtI=;
	b=xKjVKSc9qpldPqZdbRjRauCf/7jvAjkjqjAlqZLO/78JBwGa+L++k2W9lOhLYR65yaNb
	 4uHTfL/3Fp8I5xQWCu00Lw4jkPhcGWuXU5WuzZ8cioTLiVnt0zeh4qM6tcCsj9wrM0dDi
	 1ZBIOcr+4zLNz9kaoWLeNAdfNAx/IOYLgZxOmgBev4M6d4+elBSs1LzIWs8r61F9Nonpi
	 hc3ZFracW+5yzwpQleSbs+1/H9zhrBmeqrlJ7Jj4ITQU630jXx2xp+mHiBjPzQ1IVGs5U
	 JmWnkWBc9W7L9GvC6OKzynyeWyk+MGA5VZXVh4+WSXGdtnVa8pIbkxDmbg0umtCb++w==
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=QPPOsXkS;
	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 76502606A324;
	Sat, 28 Nov 2026 18:17:48 +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=QPPOsXkS
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=1795889862;
	b=SwFkJ0WUfPiFhWLWyKjHl0v/hr0f1MIW4H7YLj4uJ2j+hjIqkfEPdTmzXsYL0Zwlpavv
	 GdLzSn+5C7t9tIHFSKQO2MVj3IgU2nlqM8cFTIJ93VF3ubIrmfvB29zoLq+h/s+FVcAHM
	 1IYX8lY2t1n+wEgu4bP09HtoWBLktnGWJAXQo7v3ftEmolYhNtStm33XRmIFP+AaZc8+Z
	 2E/hcjm/bX5zjhiKUlqrfyH0a0ZMMjjOt7ioenVXEIJK0tjyLxm8rQbfJYU8k8xo9LypD
	 pQKvbdNKXiBa6ImOekUtUiwx9fMjMZvPfzp/QPZcoyM9+Xlioh6oPh/ySTshE7LRpcw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795889862;
	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=ZdRFz1P+O2wUOFarXzrOPnFL0+E/BJQ0reSXyFaBVtI=;
	b=y83U6wp0T89fHGCgOfUGlV9UHetZ29ofSWFE4cRAmMe9lpTVPCSe6Cd4YwpesIVxpl4u
	 rvN7UcaRZzdb8VczSlFoykpI+0oKMFipm9C3vLublXvy0XYT7KpJ7Ndf0JU6/5BSZU/+F
	 NmCx/rimoQ9ixYORmuRv9wfeS34UUoZV5ouxSRpnat+eHSl1eBSQ3gREO3fLfLmfFugBr
	 NV6hSReBY6xUEljKebQL0mU8HrDGoWf6W/Cr4w3EMZMbrhB4j6KmKZAZsh2+Wlpnxmfyu
	 RIKFuGNZxqj+SPWEAL2gGBwtkis/KCN9mEpassbdtomcDaq27CY3+4X2/ZGjvjo/xCA==
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=QPPOsXkS;
	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 90E47606A31C;
	Sat, 28 Nov 2026 18:17:42 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFF461F00897;
	Sat, 28 Nov 2026 18:17:40 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795889861;
	bh=ZdRFz1P+O2wUOFarXzrOPnFL0+E/BJQ0reSXyFaBVtI=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=QPPOsXkSK7ugcz0Fu71I9XF37uIkWIs5HzufIFmcmOMq4/27XFFN95o47G8YSWTaA
	 xQC6Km6ErfPsjr8XX7zIvyT9zyc9jtJ9Sb4P6ThRMLyKZ0Q6E5OXfG2FDNqmxBaNXA
	 8/+TVKgdpRJdQolucSbw95cIL8DfOetZfX5U1XWI1E6/fnx0AbvmCTBRqG2GR02k65
	 UOnxKTYERLb6OACKFCooCBoc5mtJn9hNNArprCl/GGooOmNa7LaKRXOkJVd9fCI0iQ
	 R8yHx3XIRQE+WR0xAmGfx0Wuxt4SnAkE7qurjCkzKdRMUPXtcZc4GpV99YNGrXrEKE
	 tMnEgbFmHFf/Q==
X-Cc: wenjia@linux.ibm.com, jaka@linux.ibm.com, alibuda@linux.alibaba.com,
 tonylu@linux.alibaba.com, guwen@linux.alibaba.com, netdev@vger.kernel.org,
 linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net,
 edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 kapil@presceralabs.ai, stable@vger.kernel.org
X-In-Reply-To: <20261124180257.622064-1-piyus@iiitd.ac.in>
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