Article View: linux.kernel.netdev
Article #17551Re: [PATCH net v6 3/3] net/smc: skip the DMB nocopy accounting until the send buffer is set
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 01:06
Date: Tue, 17 Nov 2026 01:06
210 lines
16030 bytes
16030 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · 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).
- [High] The new NULL check only covers the time before
smcd_buf_attach().
- [Medium] The patch stops the NULL dereference, but it keeps processing
a CDC that, by the patch's own new comment, can come from the old peer…
--
net/smc: skip the DMB nocopy accounting until the send buffer is set
This patch changes smcd_buf_attach() to publish conn->sndbuf_desc with a
release store once sndbuf_space has been set. While sndbuf_desc is still
NULL, smc_cdc_msg_recv_action() now skips the SMC-D DMB nocopy accounting.
The aim is to avoid a NULL dereference when the old peer of a reused DMB
sends a consumer update before the new connection has attached its send
buffer.
> diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
> index b3bcc206efe3e..4a4a279b405b1 100644
> --- a/net/smc/smc_cdc.c
> +++ b/net/smc/smc_cdc.c
[ ... ]
> @@ -357,12 +358,19 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
> * peer RMB, then update tx_curs_fin and sndbuf_space
> * here since peer has already consumed the data.
> */
> + sndbuf_desc = NULL;
> if (conn->lgr->is_smcd &&
> smc_ism_support_dmb_nocopy(conn->lgr->smcd)) {
> + /* NULL until smcd_buf_attach(), but the old peer of
> + * a reused DMB can already signal us.
> + */
> + sndbuf_desc = smp_load_acquire(&conn->sndbuf_desc);
> + }
> + if (sndbuf_desc) {
[Severity: Medium]
The NULL dereference is gone. But the new comment says this CDC can come
from the old peer of a reused DMB, so should it be processed at all?
smcd_cdc_rx_tsklet() passes the CDC here without checking its seqno, token
or source. smcd_cdc_msg_to_host() then overwrites local_rx_ctrl.prod, cons,
prod_flags and conn_state_flags unconditionally:
net/smc/smc_cdc.h:smcd_cdc_msg_to_host() {
...
smc_curs_copy(&local->cons, &temp, conn);
local->prod_flags = peer->cons.prod_flags;
local->conn_state_flags = peer->cons.conn_state_flags;
}
Only the tx_curs_fin/sndbuf_space sync is skipped here. The connection may
still be in its CLC handshake, and the rest of smc_cdc_msg_recv_action()
still runs on the stale data:
- diff_cons is added to peer_rmbe_space
- diff_prod is added to bytes_to_rcv, and sk_data_ready() is called
- stale peer_conn_abort, peer_conn_closed or peer_done_writing flags set
sk_err = ECONNRESET, RCV_SHUTDOWN and SOCK_DONE, and queue close_work
For an abort, smc_close_passive_abort_received() then moves the socket
from SMC_INIT to SMC_PROCESSABORT.
Can stale flags from an unrelated connection reset or close a connection
that is still in its handshake?
This also leaves a cursor mismatch behind. local_rx_ctrl.cons ends up at
the stale value X, while tx_curs_fin stays at {0,0}.
smcd_conn_save_peer_info() resets peer_rmbe_space but not
local_rx_ctrl.cons:
net/smc/af_smc.c:smcd_conn_save_peer_info() {
...
atomic_set(&smc->conn.peer_rmbe_space, smc->conn.peer_rmbe_size);
...
}
The first real CDC from the new peer (cons Y) is then diffed against X:
- Same wrap and Y.count <= X.count: diff_cons is 0, and peer_rmbe_space
stays below its real value from then on.
- Different wraps: peer_rmbe_space is credited past peer_rmbe_size, which
breaks 0 <= peer_rmbe_space <= peer_rmbe_size.
In both cases peer_rmbe_space can no longer equal peer_rmbe_size. So this
check later in the function never fires:
if (diff_cons && conn->urg_tx_pend &&
atomic_read(&conn->peer_rmbe_space) == conn->peer_rmbe_size) {
Would a MSG_OOB sender then block in smc_tx_sendmsg()->smc_tx_wait() until
a timeout or a signal?
The commit message says:
The update's cursors and flags are still applied to the new
connection, as those of a CDC that leaves the consumer cursor alone
already are.
Is that comparison accurate? A CDC that leaves the consumer cursor alone
does not create a cons/tx_curs_fin mismatch.
A CDC that moves the consumer cursor before smcd_buf_attach() cannot come
from the real peer. That is the reasoning behind "Nothing of ours can have
been consumed before the attach".
Would it be better to drop such a CDC, or to stop reusing a DMB that a
previous peer can still signal, instead of applying part of it?
> /* Calculate consumed data and
> * increment free send buffer space.
> */
> - diff_tx = smc_curs_diff(conn->sndbuf_desc->len,
> + diff_tx = smc_curs_diff(sndbuf_desc->len,
> &conn->tx_curs_fin,
> &conn->local_rx_ctrl.cons);
> /* increase local sndbuf space and fin_curs */
> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
> index 9ef9019bc4974..982cfc79ee1cc 100644
> --- a/net/smc/smc_core.c
> +++ b/net/smc/smc_core.c
> @@ -2654,9 +2654,10 @@ int smcd_buf_attach(struct smc_sock *smc)
> buf_desc->cpu_addr =
> (u8 *)buf_desc->cpu_addr + sizeof(struct smcd_cdc_msg);
> buf_desc->len -= sizeof(struct smcd_cdc_msg);
> - conn->sndbuf_desc = buf_desc;
> - conn->sndbuf_desc->used = 1;
> - atomic_set(&conn->sndbuf_space, conn->sndbuf_desc->len);
> + buf_desc->used = 1;
> + atomic_set(&conn->sndbuf_space, buf_desc->len);
> + /* Set last; pairs with the acquire in smc_cdc_msg_recv_action() */
> + smp_store_release(&conn->sndbuf_desc, buf_desc);
[Severity: High]
Does this only close the window before attach? The old peer that still
holds the reused DMB token can keep signalling after this store.
Once sndbuf_desc is published, the new "if (sndbuf_desc)" branch in
smc_cdc_msg_recv_action() runs on the foreign consumer cursor:
diff_tx = smc_curs_diff(sndbuf_desc->len,
&conn->tx_curs_fin,
&conn->local_rx_ctrl.cons);
...
atomic_add(diff_tx, &conn->sndbuf_space);
Right after attach, tx_curs_fin is {0,0} and sndbuf_space is len. A stale
cons X with X.wrap != 0 gives diff_tx = len + X.count, so sndbuf_space
becomes 2 * len + X.count.
Can sndbuf_space grow past sndbuf_desc->len this way? peer_rmbe_space
would be over-credited in the same way.
smc_tx_sendmsg() sizes its copy only from sndbuf_space:
net/smc/smc_tx.c:smc_tx_sendmsg() {
...
copylen = min_t(size_t, send_remaining, writespace);
...
chunk_len = copylen - chunk_len; /* remainder */
...
}
With prep.count == 0, the second chunk is len + X.count bytes, written at
offset 0.
Would memcpy_from_msg() then write X.count bytes of user data past the end
of the attached peer DMB? With CONFIG_HARDENED_USERCOPY this would hit a
usercopy_abort() BUG instead.
Smaller inflations would overwrite data that has not been consumed yet, and
tx_curs_fin would be left at the foreign baseline.
The underlying problem seems to be that a DMB is handed to a new
connection while a previous peer is still attached. smc_buf_unuse() only
does this:
WRITE_ONCE(conn->rmb_desc->used, 0);
The token stays registered. __smc_buf_create()->smc_ism_set_conn() maps the
sba_idx to the new connection, so dibs_lo_move_data() delivers the old
peer's signals there.
One way to reach this: smc_listen_decline() calls smc_conn_abort() after
the client has already run smcd_buf_attach() and moved to SMC_ACTIVE.
Would it be better to stop reusing the DMB while a peer is attached, or to
drop signals that do not come from the current peer, instead of making the
receive path tolerate a NULL sndbuf_desc?
> return 0;
>
> free:
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-b4-disp-1c8d3a53-v6-0-36a38ae35021%40proton.me
Technical Details
Message-ID:
<179487758596.3136.12928828467382443502@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.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-364868-linux-kernel-netdev=dewy.ruReferences:
<20261112-b4-disp-1c8d3a53-v6-3-36a38ae35021@proton.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.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-364868-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v6 3/3] net/smc: skip the DMB nocopy accounting until the send buffer is set Date: Tue, 17 Nov 2026 01:06:25 +0000 Organization: Usenet Network Message-ID: <179487758596.3136.12928828467382443502@kernel.org> References: <20261112-b4-disp-1c8d3a53-v6-3-36a38ae35021@proton.me> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2208775"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:1PE5xiu3gxDmJqBi1G0tkeEn8So= sha256:eX3qhSSWwQTS9rg7rxBBftcBC5eXaXU0FGkWIC/sWzc= sha1:AXQzqKO06APrNEmPo0SPH/9vaPY= sha256:aOobj8zp4P3NLu8cmFYIVfpWdsAFhTcIxlF0saLa7B8= 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 9FC71114DF0; Tue, 17 Nov 2026 04:07:11 +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 8V9JJChLstcS; Tue, 17 Nov 2026 04:07:07 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364868-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id D2BB8114DEF; Tue, 17 Nov 2026 04:06:58 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 2FF2B2ED82; Tue, 17 Nov 2026 01:06:36 +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=1794877593; b=OQNrcV/N0cW4tfORZybhX2o0pZTjpuI0IPsn7Y2egUSa/oyUSFYEAa8+ftXwA4N3hH1q 1ct+lSNN3OAtWX12TFjRmPM9ZUtuIKdPLyov9HvWEoqxHmpD8zi9/PfPbKpulvVdT4SLm ISGCfM41fz3NXnKWZI2sCIZ2xguuPcSB1loLawIDWPKaYHgnavuKR5dm344KbsSiFUpon 5O0EIuXgbuibNrfSO8pQMYo9UsgtIn6jCetDBQOKiWXjslaMaDunU4Sj6C9Gh+HUzb8YY A9sYvYsW2ybujjoDjDJ08mw9GnBjKzFY+kwUS6qJbTsbkqJ7oRCTP5KsRahpqL3qVPQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794877593; 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=Sb9h9j6lPynfBYh6n95WwXR9U5v9/0qOxm69owQ23yI=; b=V/pubPN6GgZn5EYUf7uaFTJ7V1TjcpQx8J3Qm9izY2KCLY7TsfDu8I0QzfeqqQml0YX7 hR05+Jz0F1R33TnORuwmfhrOjgzZWKzs0OsWsJNnGVe69w0OJ2Qkvx8J653OsCd8DMX4y z94sgpl+dv79+6O8e/y1AyzNRS33w4WtXe+Cw6gbYezf0Z/RDHivEFnbYi5ah4LLas5D7 iwzuIDcEaQLGVYHYsYTrvU4TaBrVthJDF6DRwsEVZbgwZVqtu/71YWD5wxzpBW85NpR7x MC3XGC9MkNxMH4XmnObhvCJiPcIHpgHNtw1R0WtxBDTvqM1/ar1zBjC+CMM/CtnITGQ== 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="bXD/oVvm"; 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 7B767606A339; Tue, 17 Nov 2026 01:06:33 +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=bXD/oVvm 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=1794877587; b=H6ELadEiP7aY0NabySqX0ZhE8hpf1aZTIR89o3Xpl7nUr1sFFHphQdDvrpmJn6TiUJfu cs9152FHzBIEhGotR7IbCYMTXpWMUrlWT0TXAOMy+jDPYIkPBqYQmYZk2kHhFCgwifyyC ToMFdK/6NRKf8cdZlQ9kL8BxJUWTxvLLRFmXDTimVgmar14IzX6NZOT525zFruy5rnvjT hIwLkRkyr3tkrt8xRP9yRmwOYoh/EtJzG7Y1XvAy3vBg/ntjnRPu2dEUY1X2OpCneKiWC 6SgsG6Lyd8Txcn2EnyEbSgP/Pm3EHhkh9RJ2ICijkG4sxzyEErLWnoPjuIiONGDYBUg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794877587; 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=Sb9h9j6lPynfBYh6n95WwXR9U5v9/0qOxm69owQ23yI=; b=0M+td1tRIWhnv4ddREK9nW2t+Yb5AqIfVJjvsYiXKTC6tzQeOpxcyzlIfPP34BVPuwFS KXO09tnzbzGZRbq1X8YRrnVEeN4WRhpvJAORPUbBX9LJqAwFkxEiYgJWcnSx24R8FkOiY +mYCKCEtc2eGCfiUviP6aplatQi4iHyjVWRD18phThQTns5nfcfZIXrj1blgmKFQqp1J/ bgMyK+95Gs+2x1lvUOL13PvlwbMV3NVhkunj7t7ltlW7yXNTqQBXvf23FxGN9rt/9/0Nw J3iHNjctMSF+BRIT0aFBrFgZy433DV59WyEQO9qEVPxokERn9iL7+up5ATF/cwK4BpQ== 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="bXD/oVvm"; 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 99838606A882; Tue, 17 Nov 2026 01:06:27 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 673BA1F000C4; Tue, 17 Nov 2026 01:06:26 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794877587; bh=Sb9h9j6lPynfBYh6n95WwXR9U5v9/0qOxm69owQ23yI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=bXD/oVvmhB9L9jp9ytgzC5qCGW3Ey2wz/1tlFoUdSEZdp392eY/YVWA2THUHjXD6X 6DR/Xn82HT3L/gpCKMlwIECGkbyM6iT7fLpWHVyGzmNxSis3DkACfVJGFo0yQv7A/6 stawLvWsg5OSgW+oBxtBEO1PVSw/WP+oNWrUfaMz6J6J3tEc6l6qsV7geJLOaiczY7 NuqFnqMAp781RfUJ2Wr001B20qqeiLbWM6/7sLdgOlflQMvE1RJe//lEAgVOO+sLeW AxcRSrqH6EYwLBaTV2k1Ly4jTRtFL8EOmsP5eCwP8AB13FilQ67ya177JeNAIidSPZ ZjVgPIXdjKwDQ== X-Cc: mjambigi@linux.ibm.com, kuba@kernel.org, dust.li@linux.alibaba.com, davem@davemloft.net, edumazet@kernel.org, sidraya@linux.ibm.com, pabeni@redhat.com, alibuda@linux.alibaba.com, hwippel@linux.ibm.com, linux-kernel@vger.kernel.org, wenjia@linux.ibm.com, netdev@vger.kernel.org, hidayath@linux.ibm.com, ubraun@linux.ibm.com, tonylu@linux.alibaba.com, linux-rdma@vger.kernel.org, guwen@linux.alibaba.com, linux-s390@vger.kernel.org, horms@kernel.org X-In-Reply-To: <20261112-b4-disp-1c8d3a53-v6-3-36a38ae35021@proton.me> X-sashiko-severity: High 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