Article View: linux.kernel.netdev
Article #2909[PATCH net v7 0/4] net/smc: bound wire-controlled CDC cursors against the local buffers
From: Bryam Vargas via B4 Relay
Date: Tue, 13 Oct 2026 20:12
Date: Tue, 13 Oct 2026 20:12
115 lines
12852 bytes
12852 bytes
A peer's CDC cursors come off the wire and are used, with no bound
against the local buffers, as a raw index into the RMB on the urgent
path (1/4), as the rx length (2/4), as the tx write space (3/4), and as
the cursor advance at SMC-R link failover (4/4). Any peer that completes
the SMC handshake controls them. With a forged cursor each use runs past
its buffer: an OOB read of kernel memory returned to the reader, send()
data written past the send buffer, or, at failover, an RDMA write whose
source and destination lie past the send buffer and the peer's RMB. Two
of these also happen with a conforming peer: a MSG_PEEK|MSG_WAITALL
reader racing another recv() (2/4), and late completions on the old
link after a failover (3/4).
With a second link in the group, the peer can force the failover: a
DELETE LINK request, or failing one of our RDMA writes, takes the link
down and switches the connections. Late completions need only ACKs on
the old link that arrive after the switch, from a degrading link or a
peer that delays them.
Bounding each cursor on arrival is not enough. A peer that only bumps
prod.wrap with count 0 hits the differing-wrap branch of
smc_curs_diff(), which returns the full buffer length on every CDC, so
bytes_to_rcv grows past the RMB while every cursor looks in range. IOW
the overflow is in the accumulator, not the cursor. 1/4 can clamp on
arrival because the urgent path indexes with the count itself; 2/4-4/4
bound the value where it is used. Hidayath Khan's "net/smc: abort the
connection when the peer overruns the RMB" [1] (net-next) drops the
connection at CDC receive; this series does not depend on it.
Tested on v7.3-rc6 with KASAN, over SMC-D loopback and over SMC-R on
rxe with two links, one end patched to forge its CDC cursors:
- unpatched: recv(), MSG_PEEK|MSG_WAITALL, SO_RCVLOWAT and splice()
read past the RMB, as does recv() once bytes_to_rcv wraps
negative; the urgent byte comes from past the RMB; send() writes
past the send buffer; after a failover with a forged consumer
cursor the next RDMA write takes its source past the send buffer
(rxe refuses that WR).
- conforming peers, unpatched: the peek race reads past the RMB; a
completion held back past the failover (a test hook makes the
timing deterministic) leaves sndbuf_space at 3x the buffer, and
send() writes past the send buffer.
- v6 still reads past the RMB on a peek longer than two ring lengths
and on repeated undrained splices.
- v7: each case above stays inside its buffer, with no KASAN report,
and no KMSAN report on the loopback runs.
- dropping any one patch, or any one part of 2/4, makes a test fail
again.
- conforming traffic is unchanged: streams compared byte for byte,
peek then recv, SO_RCVLOWAT, splice drained and undrained, urgent
data inline and out-of-band, deferred accept, SIOCINQ and poll,
nonblocking reads, close with unread data, failover mid-stream, a
reader waiting while the link group is torn down.
Logs on request.
Changes in v7:
- 2/4 (was v6 2/3): per Sashiko's reviews of v6 [2][3][5], MSG_PEEK
and splice() offsets could start the copy outside the RMB, a local
peek race [3] could leave the available length negative, and wrap
bumps grow bytes_to_rcv (the accumulator case above). The bound
moves into smc_rx_data_available(), counts peeked and spliced
bytes, maps a negative length to 0, not a full ring, and covers
the wait predicates too. The RMB length is cached in conn->rmb_len
for the unlocked wait, and splice_pending now drops before the
consumer cursor moves. New Fixes:, Reported-by: and Closes: tags;
R-b dropped.
- 4/4 is new: the failover cursor advance, which 3/4 does not cover.
- 3/4: code unchanged. [4] noted that DMB merge runs only on the
loopback device, so its peer is the local kernel; the message now
leads with the over-credit after a failover, which needs no forged
cursor, and says it bounds the copy. New Fixes:, R-b kept.
- 1/4: code unchanged, comment and message reworded. R-b kept.
- [6] (rmb_desc NULL before smc_buf_create()) is pre-existing; my
fix for it, [7], is marked changes requested in patchwork and
touches the same lines of __smc_buf_create() as 2/4.
v6: https://lore.kernel.org/all/20261008-b4-disp-f7cd3d96-v6-0-fba616c0920c@proton.me/
Changes in v6: repost on net; 2/3 message corrected (the over-read goes
to the reader, not the peer); Sidraya Jayagond's R-b.
v5: https://lore.kernel.org/all/20260723-b4-disp-0d07164f-v5-0-6a9e235dbc4e@proton.me/
Changes in v5: repost of v4.
v4: https://lore.kernel.org/all/20260705-b4-disp-28a1bbca-v4-0-be089b98acc6@proton.me/
Changes in v4: split off the validate/abort change, per Dust Li.
v3: https://lore.kernel.org/all/20260614-b4-disp-edd64be9-v3-0-551fa514257e@proton.me/
[1] https://lore.kernel.org/all/20260804141109.542202-1-hidayath@linux.ibm.com/
[2] https://lore.kernel.org/all/sashiko-outbox-164918@kernel.org/
[3] https://lore.kernel.org/all/179152807838.434549.2207466107170796457@kernel.org/
[4] https://lore.kernel.org/all/179152807992.434549.3295281690534839972@kernel.org/
[5] https://lore.kernel.org/all/179152807674.434549.14168488606722848951@kernel.org/
[6] https://lore.kernel.org/all/sashiko-outbox-164917@kernel.org/
[7] https://lore.kernel.org/all/20260728-b4-disp-52ee4e7d-v4-1-0dda94b0f397@proton.me/
---
Bryam Vargas (4):
net/smc: bound the wire-controlled producer cursor to the RMB
net/smc: bound the receive length to the RMB
net/smc: bound the send length to the send buffer in smc_tx_sendmsg()
net/smc: bound the link failover cursor advance to the send buffer
net/smc/smc.h | 3 +++
net/smc/smc_cdc.h | 17 ++++++++++++++---
net/smc/smc_core.c | 15 +++++++++++----
net/smc/smc_rx.c | 7 ++++++-
net/smc/smc_rx.h | 11 ++++++++++-
net/smc/smc_tx.c | 8 ++++++++
6 files changed, 52 insertions(+), 9 deletions(-)
---
base-commit: af32da41b0327b9c6a37856ba82b6760d6c8d10e
change-id: 20261013-b4-disp-f345196c-2add58b30202
Best regards,
--
Bryam Vargas <hexlabsecurity@proton.me>
Technical Details
Message-ID:
<20261013-b4-disp-f345196c-v7-0-ef3dddfbfa68@proton.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-345851-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-345851-linux-kernel-netdev=dewy.ru From: devnull+hexlabsecurity.proton.me@kernel.org (Bryam Vargas via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH net v7 0/4] net/smc: bound wire-controlled CDC cursors against the local buffers Date: Tue, 13 Oct 2026 15:12:47 -0500 Organization: Usenet Network Message-ID: <20261013-b4-disp-f345196c-v7-0-ef3dddfbfa68@proton.me> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2145685"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ffawuxVu+uRerV3vwfBrGEGHbeY= sha256:YL+gTY0E0YLuzljC5HyLEbhSVRZyL6kruzPupI/6e2o= sha1:iLEAvUT2ZJkxOVE/EcMio7W4I6Y= sha256:W7XRKtMuLz9Tv3ckoCnTcdIGQ+rX7+G6V6E79JIpuRM= 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 622C010FF02; Tue, 13 Oct 2026 23:26:48 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -1.34 X-Spam-Status: No, score=-1.34 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, 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 Y7aeBWXoKgZb; Tue, 13 Oct 2026 23:26:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-345851-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 815F310FEFB; Tue, 13 Oct 2026 23:26:32 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 246DD472FA; Tue, 13 Oct 2026 20:12:58 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37571548571; Tue, 13 Oct 2026 20:12:50 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c+Pr31qc" X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8F303E5A32; Tue, 13 Oct 2026 20:12:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791922369; cv=none; b=dFbrWafYOUbVB1HVnSVPVmUC3K3V/15qUUWDzh7x0jcR7rZ2FzP2hlT3N6pDJv6A2KGu2poj02gFewlB2AfsZstZzkciwnbbL5aNu8xG0AuzBNiQa3MAI1am3PTC4xGgQwMXRNdFGEVs+rlQ4MGfEAjzy8Soo/6HQHasWgY9Yak= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791922369; c=relaxed/simple; bh=0Mq9mAy9c5Rr5BSJvIj8O8dUcb75ZTTaUNYy2n4r8Xw=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=igyKwInLAwzccSLbCMJskFI2K5eesES3Rv5p7b1c0RKegpzZ7cUaVgn1cfkRGwJhRyUQ2WuySC9iN9oHS8tdQ45PnKp92RqF+kPRpNb35FATFNtaGDq6GZbBXIJQvASSOWn0FCdVzfNRa0KIdGJp0rmjvUGKqRsBDOmPT/3IQuE= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c+Pr31qc; arc=none smtp.client-ip=10.30.226.201 X-Received: by smtp.kernel.org (Postfix) with ESMTPS id 579DAC2BCF7; Tue, 13 Oct 2026 20:12:49 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1791922369; bh=0Mq9mAy9c5Rr5BSJvIj8O8dUcb75ZTTaUNYy2n4r8Xw=; h=From:Subject:Date:To:Cc:Reply-To:From; b=c+Pr31qcVikIUn0FECL7Zydr3LVEIDOW8a92+dX+XSGGaVYqQ+x9OOHsOVyHRnUhe POuwcCNDTKbDLuMdRax9BGbAEh8SV4F5FCnvPP/ND3Vi7XpzTX1MR01uuDY1HHzcxC sKKTPqIkx/PCabHX4CAa1FBy4Bma4WfsEq2wR52KuVr+kXCSxRo96YlIwFcuMaXDXN RdFB7aap+61wh2JSoHqANSdIhk00Omea35FLl9TJ07qIYygJLG83e80fYROYaEWGtP aWdpa5DywNOf0ZZMO8uEL9uHvOgLPxhHwtcStFHtUpli/ivdy8P5m35XaNfzz1u6YS txG69p0nWJTDw== X-Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C812CC6B19; Tue, 13 Oct 2026 20:12:49 +0000 (UTC) X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWMyw6CMBBFf4XctZP0Afj4FeOCtoOOi0o6aEwI/ 27B5bm55yxQLsKKS7Og8EdUXrnC8dAgPoZ8Z5JUGc643hrrKbSURCcafdvZcx/JDSl1p+BNvaB qU+FRvnvyiswzbv9R3+HJcd5iWNcfYaqtonkAAAA= X-Change-ID: 20261013-b4-disp-f345196c-2add58b30202 X-Cc: netdev@vger.kernel.org, Simon Horman <horms@kernel.org>, linux-kernel@vger.kernel.org, Wenjia Zhang <wenjia@linux.ibm.com>, Tony Lu <tonylu@linux.alibaba.com>, linux-s390@vger.kernel.org, Guangguan Wang <guangguan.wang@linux.alibaba.com>, Ursula Braun <ubraun@linux.ibm.com>, linux-rdma@vger.kernel.org, Stefan Raspl <raspl@linux.ibm.com>, Hidayath Khan <hidayath@linux.ibm.com>, Wen Gu <guwen@linux.alibaba.com> X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791922368; l=6268; i=hexlabsecurity@proton.me; s=default; h=from:subject:message-id; bh=0Mq9mAy9c5Rr5BSJvIj8O8dUcb75ZTTaUNYy2n4r8Xw=; b=lyy8YMqdJxzssb89ZmmD0Vz3+1s/vCTeIun4unm3woGR/+IPGgfYPo1p/Vk1Z3pu9ezSWvShU +nMQx/aXXQIAAqy3sI6uZ38GiWea0Tc6Uz7dXmiNd7ykY92N/BrthvS X-Developer-Key: i=hexlabsecurity@proton.me; a=ed25519; pk=xw1AhCtQdvuoQc+bOQIYy9o8G++cp4/VniI2G/tc3G8= X-Endpoint-Received: by B4 Relay for hexlabsecurity@proton.me/default with auth_id=893 X-Original-From: Bryam Vargas <hexlabsecurity@proton.me> X-Reply-To: hexlabsecurity@proton.me