Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bryam Vargas" <hexlabsecurity@proton.me>
Cc: linux-s390@vger.kernel.org, linux-rdma@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 4/4] net/smc: order the urgent mark across the cursor wrap rollover
Date: Sun, 15 Nov 2026 04:14:50 +0000	[thread overview]
Message-ID: <sashiko-outbox-215220@kernel.org> (raw)
In-Reply-To: <20261113-b4-disp-1a9ab9b0-v1-4-4a7c8d85d849@proton.me>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] net/smc: TOCTOU race in smc_rx_recv_urg() [1]
--

commit 474a1c81553cc3992c5253fbaae536390326e390
Author: Bryam Vargas <hexlabsecurity@proton.me>

net/smc: order the urgent mark across the cursor wrap rollover

This commit replaces smc_curs_comp() with smc_curs_sdiff() in
smc_rx_update_consumer() so that consumer and urgent cursors are ordered
correctly across the 16-bit wrap rollover, and removes the unused
smc_curs_comp() helper.

> diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c
> index 63c178c10bf1a..0345167cdc0dc 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;

[Severity: Medium]
This problem wasn't introduced by this patch, but can smc_rx_recv_urg()
race [1] with incoming CDC messages and duplicate an urgent byte?

net/smc/smc_rx.c:smc_rx_recv_urg() {
	...
	if (conn->urg_state == SMC_URG_VALID) {
		if (!(flags & MSG_PEEK))
			smc->conn.urg_state = SMC_URG_READ;
		msg->msg_flags |= MSG_OOB;
		if (len > 0) {
			if (!(flags & MSG_TRUNC))
				rc = memcpy_to_msg(msg, &conn->urg_rx_byte, 1);
	...
}

Although smc_rx_recv_urg() runs under lock_sock(), smc_cdc_msg_recv() in
softirq context only takes bh_lock_sock() without checking
sock_owned_by_user():

CPU0                                  CPU1 (softirq)
smc_rx_recv_urg()
  smc->conn.urg_state = SMC_URG_READ;
                                      smc_cdc_msg_recv()
                                        bh_lock_sock(&smc->sk)
                                        smc_cdc_handle_urg_data_arrival()
                                          conn->urg_rx_byte = new_byte;
                                          conn->urg_state = SMC_URG_VALID;
                                        bh_unlock_sock(&smc->sk)
  memcpy_to_msg(..., &conn->urg_rx_byte, 1)  <-- copies new_byte

The first urgent byte is lost, the current recv(MSG_OOB) returns the new
urgent byte, and because conn->urg_state was reset to SMC_URG_VALID, the
next recv(MSG_OOB) reads the same new byte a second time.

[1] https://sashiko.dev/#/bug/linux-fba17bf0-1137-4667-8969-554d43e1d736

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261113-b4-disp-1a9ab9b0-v1-0-4a7c8d85d849@proton.me?part=4

      reply	other threads:[~2026-11-15  4:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14  4:14 [PATCH net 0/4] net/smc: fix the failover cursor switch and wrap rollover Bryam Vargas via B4 Relay
2026-11-14  4:14 ` [PATCH net 1/4] net/smc: take the socket spinlock across the failover cursor switch Bryam Vargas via B4 Relay
2026-11-15  4:14   ` sashiko-bot
2026-11-14  4:14 ` [PATCH net 2/4] net/smc: do not credit stale CDC completions after a link switch Bryam Vargas via B4 Relay
2026-11-15  4:14   ` sashiko-bot
2026-11-14  4:14 ` [PATCH net 3/4] net/smc: fix the failover catch-up across the cursor wrap rollover Bryam Vargas via B4 Relay
2026-11-15  4:14   ` sashiko-bot
2026-11-14  4:14 ` [PATCH net 4/4] net/smc: order the urgent mark " Bryam Vargas via B4 Relay
2026-11-15  4:14   ` sashiko-bot [this message]

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-215220@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