Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Bryam Vargas via B4 Relay
Sat, 14 Nov 2026 04:14
[PATCH net 4/4] net/smc: order the urgent mark across the cursor wrap rollover
Author: Bryam Vargas via B4 Relay
Date: Sat, 14 Nov 2026 04:14
Date: Sat, 14 Nov 2026 04:14
66 lines
13083 bytes
13083 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, and the sender, which waits for its
urgent data to be consumed before it sends more, sends nothing more:
the connection stalls.
Use smc_curs_sdiff(), which orders the two cursors across the
rollover. smc_curs_comp() has no other user; remove it.
Fixes: de8474eb9d50 ("net/smc: urgent data support")
Cc: stable@vger.kernel.org
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
---
net/smc/smc_cdc.h | 13 -------------
net/smc/smc_rx.c | 4 ++--
2 files changed, 2 insertions(+), 15 deletions(-)
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..0345167cdc0d 100644
--- a/net/smc/smc_rx.c
+++ b/net/smc/smc_rx.c
@@ -68,8 +68,8 @@ static int smc_rx_update_consumer(struct smc_sock *smc,
/* 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;
--
2.56.0
Re: [PATCH net 4/4] net/smc: order the urgent mark across the cursor wrap rollover
Author: Sidraya Jayagond
Date: Thu, 26 Nov 2026 06:21
Date: Thu, 26 Nov 2026 06:21
6 lines
12686 bytes
12686 bytes
The review comment on this patch looks valid: smc_rx_recv_urg() can race with incoming CDC messages and duplicate an urgent byte. This is pre-existing, but the series touches this path, so please address it or explain why it is safe. Link: https://lore.kernel.org/all/sashiko-outbox-215220@kernel.org/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads