Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "D. Wythe" <alibuda@linux.alibaba.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
	linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH net-next v4 1/3] net/smc: clear the correct v2 slot and buffer in smc_wr_tx_put_slot()
Date: Fri, 17 Jul 2026 11:38:10 +0000	[thread overview]
Message-ID: <20260717113811.49E8C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716113745.65234-2-alibuda@linux.alibaba.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Data race in V2 slot cleanup allowing a concurrent sender's data to be overwritten.
- [High] Unconditional zeroing of the shared `lgr->wr_tx_buf_v2` in `smc_wr_tx_process_cqe()` on any link error corrupts in-progress LLC messages on other links.
--

--- Patch [1]: [PATCH net-next v4 1/3] net/smc: clear the correct v2 slot and buffer in smc_wr_tx_put_slot() ---
commit eb37bf5f30fd47da384e2535c48a0ad5576aa908
Author: D. Wythe <alibuda@linux.alibaba.com>

net/smc: clear the correct v2 slot and buffer in smc_wr_tx_put_slot()

smc_wr_tx_put_slot() tries to reset the v2 pending slot and buffer with
memset(&link->wr_tx_v2_pend, 0, sizeof(link->wr_tx_v2_pend)) and the
equivalent for wr_tx_buf_v2. Both are pointers, so this zeroes the 8-byte
pointer variable instead of the structure it points to. The pending slot
and buffer are therefore never actually cleared, and the pointers get
overwritten with NULL.

Pass the pointers directly and use sizeof(*pointer) so the intended
structures are cleared.

> diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c
> index 59c92b46945c5..6b5add9229937 100644
> --- a/net/smc/smc_wr.c
> +++ b/net/smc/smc_wr.c
> @@ -288,10 +288,10 @@ int smc_wr_tx_put_slot(struct smc_link *link,
>  	} else if (link->lgr->smc_version == SMC_V2 &&
>  		   pend->idx == link->wr_tx_cnt) {
>  		/* Large v2 buffer */
> -		memset(&link->wr_tx_v2_pend, 0,
> -		       sizeof(link->wr_tx_v2_pend));
> +		memset(link->wr_tx_v2_pend, 0,
> +		       sizeof(*link->wr_tx_v2_pend));

[Severity: High]
This isn't a bug introduced by this patch, but does clearing the control
structure before the data buffer create a race window?

If a thread sends an LLC message and waits for a response, the Rx tasklet 
might process the Rx CQE first, waking up the LLC flow thread which proceeds
to send the next message by calling smc_wr_tx_get_v2_slot().

Concurrently, the Tx tasklet could process the Tx CQE and clear the slot
control structure here. The zeroed idx immediately publishes the slot as
free, so the LLC thread could acquire it and begin formatting its message in
link->lgr->wr_tx_buf_v2.

The same sequence appears to occur in smc_wr_tx_process_cqe().

Would the following memset then wipe out the newly written message?

> -		memset(&link->lgr->wr_tx_buf_v2, 0,
> -		       sizeof(link->lgr->wr_tx_buf_v2));
> +		memset(link->lgr->wr_tx_buf_v2, 0,
> +		       sizeof(*link->lgr->wr_tx_buf_v2));

[Severity: High]
This is a pre-existing issue, but could unconditionally zeroing the shared
link->lgr->wr_tx_buf_v2 cause issues for other links in the LGR?

It looks like the same zeroing pattern happens in the error path of
smc_wr_tx_process_cqe():

net/smc/smc_wr.c:smc_wr_tx_process_cqe() {
    ...
    if (unlikely(wc->status)) {
        ...
        if (link->lgr->smc_version == SMC_V2) {
            memset(link->wr_tx_v2_pend, 0, sizeof(*link->wr_tx_v2_pend));
            memset(link->lgr->wr_tx_buf_v2, 0, sizeof(*link->lgr->wr_tx_buf_v2));
        }
    }
}

If Link B is actively formatting an LLC message in this shared LGR buffer,
and a normal data work request concurrently fails on Link A, would Link A's
tasklet incorrectly wipe out Link B's in-progress LLC message?

>  		return 1;
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260716113745.65234-1-alibuda@linux.alibaba.com?part=1

  reply	other threads:[~2026-07-17 11:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 11:37 [PATCH net-next v4 0/3] net/smc: transition to RDMA core CQ pooling D. Wythe
2026-07-16 11:37 ` [PATCH net-next v4 1/3] net/smc: clear the correct v2 slot and buffer in smc_wr_tx_put_slot() D. Wythe
2026-07-17 11:38   ` sashiko-bot [this message]
2026-07-22  7:12   ` Mahanta Jambigi
2026-07-16 11:37 ` [PATCH net-next v4 2/3] net/smc: reduce TX slot contention with exclusive wait D. Wythe
2026-07-16 11:37 ` [PATCH net-next v4 3/3] net/smc: transition to RDMA core CQ pooling D. Wythe
2026-07-22 11:47   ` Mahanta Jambigi
2026-07-22  0:53 ` [PATCH net-next v4 0/3] " Jakub Kicinski
2026-07-22  7:06   ` Mahanta Jambigi

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=20260717113811.49E8C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=alibuda@linux.alibaba.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --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