Re: [PATCH net v3 6/7] net/smc: update the urgent state under the socket spinlock

From: netdev-bot+sashiko

Date: Fri Dec 04 2026 - 04:49:58 EST


Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] net/smc: unmarked lockless conn->urg_state access in
smc_rx_update_consumer()

--

> diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c
> --- a/net/smc/smc_rx.c
> +++ b/net/smc/smc_rx.c
> @@ -67,26 +67,38 @@ static int smc_rx_update_consumer(struct smc_sock *smc,
>
> smc_curs_add(conn->rmb_desc->len, &cons, len);
>
> - /* did we process urgent data? */
> + /* did we process urgent data? smc_cdc_msg_recv_action() sets a new
> + * mark under the socket spinlock, even while we own the socket:
> + * test again under it. A mark set after the first test is left to
> + * the next call, like one set after the unlock.
> + */
> if (conn->urg_state == SMC_URG_VALID || conn->urg_rx_skip_pend) {
> - diff = smc_curs_sdiff(conn->rmb_desc->len, &cons,
> - &conn->urg_curs);
> - if (sock_flag(sk, SOCK_URGINLINE)) {
> - if (diff == 0) {
> - force = true;
> - rc = 1;
> - conn->urg_state = SMC_URG_READ;
> + local_bh_disable();
> + bh_lock_sock(sk);
> + if (conn->urg_state == SMC_URG_VALID ||
> + conn->urg_rx_skip_pend) {
> + diff = smc_curs_sdiff(conn->rmb_desc->len, &cons,
> + &conn->urg_curs);
> + if (sock_flag(sk, SOCK_URGINLINE)) {
> + if (diff == 0) {
> + force = true;
> + rc = 1;
> + conn->urg_state = SMC_URG_READ;
> + }
> + } else {
> + if (diff == 1) {
> + /* skip urgent byte */
> + force = true;
> + smc_curs_add(conn->rmb_desc->len,
> + &cons, 1);
> + conn->urg_rx_skip_pend = false;
> + } else if (diff < -1)
> + /* we read past urgent byte */
> + conn->urg_state = SMC_URG_READ;
> }
> - } else {
> - if (diff == 1) {
> - /* skip urgent byte */
> - force = true;
> - smc_curs_add(conn->rmb_desc->len, &cons, 1);
> - conn->urg_rx_skip_pend = false;
> - } else if (diff < -1)
> - /* we read past urgent byte */
> - conn->urg_state = SMC_URG_READ;
> }
> + bh_unlock_sock(sk);
> + local_bh_enable();
> }
>
> smc_curs_copy(&conn->local_tx_ctrl.cons, &cons, conn);

[Severity: Low]
With this patch the outer test becomes an intentional lockless fast
path. It is still a plain load of conn->urg_state and
conn->urg_rx_skip_pend. Meanwhile smc_cdc_handle_urg_data_arrival()
and smc_cdc_msg_recv_action() store to conn->urg_state from
softirq/tasklet context while holding only bh_lock_sock().

Nothing breaks functionally. The re-check under the spinlock decides
what actually happens, and a mark missed by the outer test is picked
up on the next call, as your comment says. But KCSAN will report this
as a data race, and the compiler is free to fuse or reload the
unmarked access.

Since the patch deliberately turns this into a double-checked
pattern, could the outer test use READ_ONCE() for both fields? The
writers would then need matching WRITE_ONCE(): the cdc paths, plus
the stores in smc_rx_update_consumer() and smc_rx_recv_urg().

The other lockless readers of urg_state already have the same issue:
smc_rx_recvmsg_data_available(), smc_rx_recvmsg() and smc_poll(). If
you would rather keep this fix minimal for stable, a follow-up that
annotates all of them would be fine too.

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0%40proton.me