From: sashiko-bot@kernel.org
To: "Bryam Vargas" <hexlabsecurity@proton.me>
Cc: linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
"Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH net v3 5/7] net/smc: order the urgent mark across the cursor wrap rollover
Date: Fri, 04 Dec 2026 09:15:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-249477@kernel.org> (raw)
In-Reply-To: <20261203-b4-disp-ba1ad55e-v3-5-6834ff90c5d0@proton.me>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net/smc: race between urg_curs copy and urg_state check in
smc_ioctl()
--
commit f0a9404787457616babe9aded75f7a3fe0de2944
Author: Bryam Vargas <hexlabsecurity@proton.me>
net/smc: order the urgent mark across the cursor wrap rollover
This commit replaces urgent-mark cursor comparisons in
smc_rx_update_consumer(), smc_rx_recv_urg(), and smc_ioctl() with
smc_curs_sdiff() to handle the 16-bit wrap rollover, removes
smc_curs_comp(), and gates SIOCATMARK on urg_state or urg_rx_skip_pend.
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index bfc0c7e71a12b..3877a3a4cbae0 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:
[Severity: Medium]
Can SIOCATMARK race with smc_cdc_handle_urg_data_arrival() and test
conn->urg_state against a stale copy of conn->urg_curs?
smc_ioctl() holds lock_sock(&smc->sk), whereas smc_cdc_msg_recv() runs
in tasklet context under bh_lock_sock(&smc->sk) without checking
sock_owned_by_user(&smc->sk), so the two execute concurrently:
CPU0 (smc_ioctl) CPU1 (tasklet: smc_cdc_msg_recv)
lock_sock(&smc->sk)
smc_curs_copy(&cons, ...)
smc_curs_copy(&urg, &conn->urg_curs)
bh_lock_sock(&smc->sk)
...
smc_cdc_handle_urg_data_arrival()
smc_curs_copy(&conn->urg_curs, ...)
conn->urg_state = SMC_URG_VALID
bh_unlock_sock(&smc->sk)
conn->urg_state == SMC_URG_VALID
smc_curs_sdiff(..., &cons, &urg) <-- compares against stale urg_curs
If cons is one byte before the wrap rollover (wrap 65535, count
rmb_desc->len - 1) on a connection with stale urg_curs {0, 0}, and a new
urgent byte arrives further ahead between the copy and the state check,
SIOCATMARK sees SMC_URG_VALID and falsely returns 1 to userspace.
Protecting the urg_state check and urg_curs copy with local_bh_disable()
and bh_lock_sock(&smc->sk) would keep them consistent.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0@proton.me?part=5
next prev parent reply other threads:[~2026-12-04 9:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 9:15 [PATCH net v3 0/7] net/smc: fix the failover cursor switch and wrap rollover Bryam Vargas via B4 Relay
2026-12-03 9:15 ` [PATCH net v3 1/7] net/smc: take the socket spinlock across the failover cursor switch Bryam Vargas via B4 Relay
2026-12-03 9:15 ` [PATCH net v3 2/7] net/smc: do not credit stale CDC completions after a link switch Bryam Vargas via B4 Relay
2026-12-04 9:15 ` sashiko-bot
2026-12-04 9:49 ` netdev-bot+sashiko
2026-12-03 9:15 ` [PATCH net v3 3/7] net/smc: store each cursor once in smc_switch_cursor() Bryam Vargas via B4 Relay
2026-12-04 9:15 ` sashiko-bot
2026-12-03 9:15 ` [PATCH net v3 4/7] net/smc: fix the failover catch-up across the cursor wrap rollover Bryam Vargas via B4 Relay
2026-12-04 9:15 ` sashiko-bot
2026-12-03 9:15 ` [PATCH net v3 5/7] net/smc: order the urgent mark " Bryam Vargas via B4 Relay
2026-12-04 9:15 ` sashiko-bot [this message]
2026-12-03 9:15 ` [PATCH net v3 6/7] net/smc: update the urgent state under the socket spinlock Bryam Vargas via B4 Relay
2026-12-04 9:15 ` sashiko-bot
2026-12-04 9:49 ` netdev-bot+sashiko
2026-12-03 9:15 ` [PATCH net v3 7/7] net/smc: skip the urgent byte when it is the next unread byte Bryam Vargas via B4 Relay
2026-12-04 9:49 ` netdev-bot+sashiko
2026-12-04 9:15 ` [PATCH net v3 0/7] 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=sashiko-outbox-249477@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hexlabsecurity@proton.me \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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