From: Sidraya Jayagond <sidraya@linux.ibm.com>
To: hexlabsecurity@proton.me,
Mahanta Jambigi <mjambigi@linux.ibm.com>,
"D. Wythe" <alibuda@linux.alibaba.com>,
Eric Dumazet <edumazet@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
Dust Li <dust.li@linux.alibaba.com>
Cc: Stefan Raspl <raspl@linux.ibm.com>,
Simon Horman <horms@kernel.org>,
Guangguan Wang <guangguan.wang@linux.alibaba.com>,
Wen Gu <guwen@linux.alibaba.com>,
linux-s390@vger.kernel.org, linux-rdma@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Tony Lu <tonylu@linux.alibaba.com>,
Ursula Braun <ubraun@linux.ibm.com>,
Hidayath Khan <hidayath@linux.ibm.com>,
Wenjia Zhang <wenjia@linux.ibm.com>
Subject: Re: [PATCH net v2 5/6] net/smc: order the urgent mark across the cursor wrap rollover
Date: Tue, 1 Dec 2026 13:48:31 +0530 [thread overview]
Message-ID: <9de0921d-d01c-4cae-8ec2-7d86a3c3f438@linux.ibm.com> (raw)
In-Reply-To: <20261128-b4-disp-360e65c5-v2-5-d9c05004d430@proton.me>
On 28/11/26 7:53 pm, Bryam Vargas via B4 Relay wrote:
> 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.
>
> Use smc_curs_sdiff() in both, which orders the two cursors whatever
> their wraps. smc_curs_comp() has no other user; remove it.
SIOCATMARK in smc_ioctl() compares the same two cursors and still uses
smc_curs_diff():
answ = smc_curs_diff(conn->rmb_desc->len, &cons, &urg) == 1;
With a 16 KiB RMB, urg = {0, 0} and cons = {1, 16383}, this returns 1
although the reader is 32767 bytes past the mark. It also ignores
urg_state, so a connection that never got urgent data (urg_curs is
zeroed) or has a stale mark can report at-mark. Something like:
- 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;
Could you fold this into v3?
Also, smc_curs_sdiff() comes from 2/6 and the smc_curs_comp() caller
is removed in 4/6, both with a different Fixes tag, so this patch
does not build on its own in stable. Please add a dependency note:
Cc: stable@vger.kernel.org # depends on 2/6 and 4/6
Thanks,
Sidraya
>
> 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 | 11 ++++++-----
> 2 files changed, 6 insertions(+), 18 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..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
>
next prev parent reply other threads:[~2026-12-01 8:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 14:23 [PATCH net v2 0/6] net/smc: fix the failover cursor switch and wrap rollover Bryam Vargas via B4 Relay
2026-11-28 14:23 ` [PATCH net v2 1/6] net/smc: take the socket spinlock across the failover cursor switch Bryam Vargas via B4 Relay
2026-12-01 8:47 ` Sidraya Jayagond
2026-11-28 14:23 ` [PATCH net v2 2/6] net/smc: do not credit stale CDC completions after a link switch Bryam Vargas via B4 Relay
2026-12-01 9:00 ` Sidraya Jayagond
2026-11-28 14:23 ` [PATCH net v2 3/6] net/smc: store each cursor once in smc_switch_cursor() Bryam Vargas via B4 Relay
2026-12-01 9:03 ` Sidraya Jayagond
2026-11-28 14:23 ` [PATCH net v2 4/6] net/smc: fix the failover catch-up across the cursor wrap rollover Bryam Vargas via B4 Relay
2026-12-01 9:08 ` Sidraya Jayagond
2026-11-28 14:23 ` [PATCH net v2 5/6] net/smc: order the urgent mark " Bryam Vargas via B4 Relay
2026-12-01 8:18 ` Sidraya Jayagond [this message]
2026-11-28 14:23 ` [PATCH net v2 6/6] net/smc: update the urgent state under the socket spinlock Bryam Vargas via B4 Relay
2026-12-01 9:32 ` Sidraya Jayagond
2026-11-28 14:43 ` [PATCH net v2 0/6] net/smc: fix the failover cursor switch and wrap rollover sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9de0921d-d01c-4cae-8ec2-7d86a3c3f438@linux.ibm.com \
--to=sidraya@linux.ibm.com \
--cc=alibuda@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=dust.li@linux.alibaba.com \
--cc=edumazet@kernel.org \
--cc=guangguan.wang@linux.alibaba.com \
--cc=guwen@linux.alibaba.com \
--cc=hexlabsecurity@proton.me \
--cc=hidayath@linux.ibm.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjambigi@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=raspl@linux.ibm.com \
--cc=tonylu@linux.alibaba.com \
--cc=ubraun@linux.ibm.com \
--cc=wenjia@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox