Article View: linux.kernel.netdev
Article #26236[PATCH net v3 5/7] net/smc: order the urgent mark across the cursor wrap rollover
From: Bryam Vargas via B4 Relay
Date: Thu, 03 Dec 2026 09:15
Date: Thu, 03 Dec 2026 09:15
112 lines
15121 bytes
15121 bytes
From: Bryam Vargas <hexlabsecurity@proton.me>
smc_rx_update_consumer() orders the consumer cursor against urg_curs
with smc_curs_comp(), which misorders them across the 65535 -> 0
rollover of the RMB wrap. Without SO_OOBINLINE, with the reader on wrap
65535 and the urgent byte on wrap 0, the mark reads as already passed:
urg_state becomes SMC_URG_READ before the byte is reached and
recv(MSG_OOB) fails with -EINVAL. The urgent byte, which bytes_to_rcv
leaves out, is then never skipped. The sender waits for its urgent data
to be consumed before it sends more, so the connection stalls.
smc_rx_recv_urg() compares the same two cursors with smc_curs_diff(). A
consumer cursor that is past the mark on the RMB's next wrap reads as
far behind it, and urg_rx_skip_pend is set with nothing left to skip.
SIOCATMARK uses smc_curs_diff() as well and does not test urg_state:
with urg_curs at the start of the RMB, a reader one byte short of the
RMB's end is told it is at the mark on every wrap except the mark's
own. That includes a connection that never received urgent data, where
urg_curs is zero.
Use smc_curs_sdiff(), which orders the two cursors across the wrap
rollover, in all three places, and let SIOCATMARK report the mark only
while it is valid or a skip of its byte is pending. smc_curs_comp() has
no other user; remove it.
Fixes: de8474eb9d50 ("net/smc: urgent data support")
Cc: stable@vger.kernel.org # depends on 2/7 and 4/7
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
---
net/smc/af_smc.c | 6 ++++--
net/smc/smc_cdc.h | 13 -------------
net/smc/smc_rx.c | 11 ++++++-----
3 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index bfc0c7e71a12..3877a3a4cbae 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -3277,8 +3277,10 @@ int smc_ioctl(struct socket *sock, unsigned int cmd,
} else {
smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn);
smc_curs_copy(&urg, &conn->urg_curs, conn);
- answ = smc_curs_diff(conn->rmb_desc->len,
- &cons, &urg) == 1;
+ answ = (conn->urg_state == SMC_URG_VALID ||
+ conn->urg_rx_skip_pend) &&
+ smc_curs_sdiff(conn->rmb_desc->len,
+ &cons, &urg) == 1;
}
break;
default:
diff --git a/net/smc/smc_cdc.h b/net/smc/smc_cdc.h
index 4b586a20dfc2..eecd0cc5bb79 100644
--- a/net/smc/smc_cdc.h
+++ b/net/smc/smc_cdc.h
@@ -167,19 +167,6 @@ static inline int smc_curs_diff(unsigned int size,
return max_t(int, 0, (new->count - old->count));
}
-/* calculate cursor difference between old and new - returns negative
- * value in case old > new
- */
-static inline int smc_curs_comp(unsigned int size,
- union smc_host_cursor *old,
- union smc_host_cursor *new)
-{
- if (old->wrap > new->wrap ||
- (old->wrap == new->wrap && old->count > new->count))
- return -smc_curs_diff(size, new, old);
- return smc_curs_diff(size, old, new);
-}
-
/* signed distance from old to new; the wrap difference is taken as s16,
* so it holds across the u16 wrap rollover, for cursors less than 32768
* rings apart
diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c
index 63c178c10bf1..564b976426ca 100644
--- a/net/smc/smc_rx.c
+++ b/net/smc/smc_rx.c
@@ -62,14 +62,15 @@ static int smc_rx_update_consumer(struct smc_sock *smc,
struct smc_connection *conn = &smc->conn;
struct sock *sk = &smc->sk;
bool force = false;
- int diff, rc = 0;
+ int rc = 0;
+ s64 diff;
smc_curs_add(conn->rmb_desc->len, &cons, len);
/* did we process urgent data? */
if (conn->urg_state == SMC_URG_VALID || conn->urg_rx_skip_pend) {
- diff = smc_curs_comp(conn->rmb_desc->len, &cons,
- &conn->urg_curs);
+ diff = smc_curs_sdiff(conn->rmb_desc->len, &cons,
+ &conn->urg_curs);
if (sock_flag(sk, SOCK_URGINLINE)) {
if (diff == 0) {
force = true;
@@ -330,8 +331,8 @@ static int smc_rx_recv_urg(struct smc_sock *smc, struct msghdr *msg, int len,
rc = memcpy_to_msg(msg, &conn->urg_rx_byte, 1);
len = 1;
smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn);
- if (smc_curs_diff(conn->rmb_desc->len, &cons,
- &conn->urg_curs) > 1)
+ if (smc_curs_sdiff(conn->rmb_desc->len, &cons,
+ &conn->urg_curs) > 1)
conn->urg_rx_skip_pend = true;
/* Urgent Byte was already accounted for, but trigger
* skipping the urgent byte in non-inline case
--
2.56.1
Technical Details
Message-ID:
<20261203-b4-disp-ba1ad55e-v3-5-6834ff90c5d0@proton.me>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376435-linux-kernel-netdev=dewy.ruReferences:
<20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0@proton.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376435-linux-kernel-netdev=dewy.ru From: devnull+hexlabsecurity.proton.me@kernel.org (Bryam Vargas via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH net v3 5/7] net/smc: order the urgent mark across the cursor wrap rollover Date: Thu, 03 Dec 2026 04:15:07 -0500 Organization: Usenet Network Message-ID: <20261203-b4-disp-ba1ad55e-v3-5-6834ff90c5d0@proton.me> References: <20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0@proton.me> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2445745"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:85GuG6leIpdixZs7ZfgyfXjQjeo= sha256:/IzA3kF6sDwf2GJQ3UsJKFCcQTVIFgUaLSjs9b1npcw= sha1:WFk8RQ/uZMnhS0K5zuqeKTHN8YE= sha256:uwm/E7TdLyf9CScN5pOLBk7+hxaAHsqxagB03HafkNs= 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 E331711789B; Thu, 3 Dec 2026 12:15:58 +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 SefBKisojWuu; Thu, 3 Dec 2026 12:15:56 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-376435-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 8410711786F; Thu, 3 Dec 2026 12:15:46 +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 16D9826AF6; Thu, 3 Dec 2026 09:15:45 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796289313; b=y/7TJFLIrvg0Ms1D49AaEdPeXgnDuu+8QdywrwT0usgbWOL4r0PIaWHgA4+/0I1aVnCE ENQ6RCfaIMrYtmCVs7GCrbLo+ni1d46al/N6uffjQBnVVE7dWkJJ1sd/T6lcOpxzVPwHd omE8xAMTzgLIdcxJ8T/VbDU8vKNLZrocXxxyEPjP9U4JbzoP78ZMnnKaUvIQpEgORvOpl OehZDai8qO8CQrMzIqLP2pmPQ306Kq00Ufx/jDJ2c9GModge4hhP5rptmh+a+Kxr3d2Zm lzYAmUc8o4t2j5nZlljokD97W2q67iCd13p42GfPxTPnE5Cw3Mk8o7IWdRZj15g2WlA== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289313; h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date: Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=VYZ6B5P39EDDVkw9WVyAdxFN3JdOqQIW8AkSKPlA8qg=; b=d6bXIPEaLPo7JtVrSrPobVze0XeKKgc9xgAaUlurnKVyI8DmbPZiXbmA+xifqk1lslNf XqvyTDpCUcjK2HPgqviOHGonQ9O4FmQEGHOiKXWX3azYL4duaYYXdMoPTB92MLAp0f0gf HQUQhBaf0nS04XbYpNyn/9eqdyT123h35RyxkxK+tvhjGeIckzDZwfyqjdEJLH4XrDdbT 33ls3Cd3WycQg8X44kaKbfvpWKISZ7JLu05YTKsuMisK+iPXDGALjZznkstbuO9szsskv ncT7rARXgT+2D8VvYa/sETx/+xcdqcXaS1hMsvKcwRMmwYFR4EFrmL+cBrob26JMMvg== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=X8cuu0yW; 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 47FE3606A68C; Thu, 3 Dec 2026 09:15:13 +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=X8cuu0yW X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796289306; b=223odvWaKx2HXIdb/N8HgnLESoWjzZXyfq2e8EnCZFFaCvLhvGCCIx00M4MX8dDVzl30 u1W1KxuoN58jfGnFyI9+3C9NRu37u4NGlzzvKq3QCRHw42RbA4TCCnPtZ1QGE83GCsBys O4jHmBZGRgDjbH/PyNxrJwEN7ukDZ9LoAArOXQis0x251nSGw1JpnR3nJ+e61bOl0l5OC 6OjGxwXEKe5ErmNET34zmjZagRrlBDDdd3ijoBMwg/uY2C44FE7QNIa7pJ6YOKXcycwU9 iRh5Oy6mwClMBW6S4jWSl01ITw5+0wa4+9l/4BdMg+BYn2AVjDvHdfUXI1yRIP2lEqw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289306; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=VYZ6B5P39EDDVkw9WVyAdxFN3JdOqQIW8AkSKPlA8qg=; b=dm42srNf6bnugAJWEYv8SokUKxH4HA8mKgSFAHtaaQWvWCSQzD8IXuh7x+euvl4FoRoC aOlNjnT77QleUexTTzdfKkXi9OTIy3l1ZN/g6RGxJHj6QaZOQ0PNBDh95Zqnl/VqAU6zu Wlfyhi4jDT9jw9Jb4gC5KiS8mvEs2Gcjjls/QsA/msToPPP/PCjS6at6EuyEhadyxFJ4L NFePnA45u8ey+7q4CTRul5MTVgpzi54kOri+TqeKKnB90ETmd9LFYXYcGSOtrYA1pWF0W P/RgZPI2WOK9vhAOAinFcwerHlTN8fbT6U42FBZdoya3tHzd/7jq3ZUJp9dBlmJdGwA== 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=X8cuu0yW; arc=pass header.oldest-pass=0 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 B00B2606A330; Thu, 3 Dec 2026 09:15:06 +0000 (UTC) X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796289306; b=oEJadjVZN3O/Jg19ofwiX3cYV57yXV6Cs5ssssKYESsc4OjijbB3ODFCVxh99bYlouhh 7iDFCaP08mX5i9VszXZ8WcUUinAe7t9F701PbDCXdc0OS83U9tn/pgdU1ds5fDPeBr/Ov xjsjg47QYDHFdfvphWie/lRtFT+g+chtq7ijGsz9gBz8Nye8V01uqSx/uuFhkS4LCm3OS DfsyMn5RRmzxEKIWLTAu4nocn4bwjH/yxgs+XFPXF3tN4D9KrDtdH8l2adHHZ4HJharSx QznugSERP1ciB3wX2mvGNthnaAOx6Luda+IfHM2ByH9k/l8yA9a2aE8qCfpEzrkTvEg== X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796289306; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=VYZ6B5P39EDDVkw9WVyAdxFN3JdOqQIW8AkSKPlA8qg=; b=hZv2YN8GYlxSyVzDZC0fR6I5ekWDqja14V3EncNqYFfmiTWuWzGkTemQ6LHGK8Z8/N9E c+DAzVf2NK42Ds2/cCTgjkbgX0CS7B8AZ7g2nCn2xf5ASStHy+ywCbdmedkKmkRLUV7/S XS4r0inXwXHEaQEhL18Adm7/VHRd25xON1bhxZmxqj6j6ZgIIIuWTUf8SWexH27MCRNfV ry6QI/wdflZ3CbvJz5zsrE9oomUyjqxh7TMQwdNYgSQbptK5fkxySRdKDBnTCZPiEK7Jz BDEeoB+Pp7FHkFsmrBXdfkDtsGq4wR5Vn17BODpwsv1erxAmjtDd+EU8rYC0Wt68eUA== X-ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 4930F1F000C1; Thu, 3 Dec 2026 09:15:05 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796289306; bh=VYZ6B5P39EDDVkw9WVyAdxFN3JdOqQIW8AkSKPlA8qg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=X8cuu0yWfeRBWx+ZIM4NCLr4jmCezoDQ/p4FXCdfL3s9xLZuvc54I3YmkYJ+p3sI7 sBxUUny4Ijg4pI6tZHt0NYjeXBjoYO2CVQOg1Rv6jJy11TpwW3E15/XaZWNX96OSje xR8baVFfk8Jw2Ik2j22wiMZyDtd///DkNJ/a1vExMFcEKseZKvLz0prr3MZ0tz8U09 Ce5lvge0kDrU7/d1bKZJ/ixyyaW4Ad7Weipb9UyBL8LY3u9bx1BZBtAcX1lI9l4djN Nvbip9O/kFeVaX3nBi8kTGjYbs1uOqWFnlk0fVS9fgT0wueGWyTrUv3Q9Kq3wHZ0R5 ZJ1vx39GZykdw== X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 2F9AB4F8BB; Thu, 3 Dec 2026 09:15:04 +0000 (UTC) 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 X-In-Reply-To: <20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0@proton.me> X-Cc: Wen Gu <guwen@linux.alibaba.com>, Guangguan Wang <guangguan.wang@linux.alibaba.com>, Tony Lu <tonylu@linux.alibaba.com>, Ursula Braun <ubraun@linux.ibm.com>, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Hidayath Khan <hidayath@linux.ibm.com>, Simon Horman <horms@kernel.org>, Wenjia Zhang <wenjia@linux.ibm.com>, linux-kernel@vger.kernel.org, Stefan Raspl <raspl@linux.ibm.com>, netdev@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796289302; l=4438; i=hexlabsecurity@proton.me; s=default; h=from:subject:message-id; bh=S5Jo1jasp68T7YgOl0+ZxwZjf/qZc6tyIhtIv+yOk5o=; b=DrtfNW1dhsRst28rGNHTXygLou0OBidwoPvauME/sx1iuhWB9AdpPcIX4y+hBH5Ol7Ai5eEG3 QD+KKInihckC5gXqWAHXmcDfKOpg/ePOyLs6DhOPvocXuixQJ96E8Q4 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 X-Received-Bytes: 14783