From: sashiko-bot@kernel.org
To: "D. Wythe" <alibuda@linux.alibaba.com>
Cc: "Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
linux-rdma@vger.kernel.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH net-next 1/2] net/smc: clear the correct v2 slot and buffer in smc_wr_tx_put_slot()
Date: Fri, 11 Sep 2026 10:45:06 +0000 [thread overview]
Message-ID: <20260911104506.76BF01F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260910104446.41423-2-alibuda@linux.alibaba.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] DMA use-after-free/unmap during link teardown due to ignored v2 TX pending state.
- [High] TOCTOU data race condition in V2 slot management causes data corruption of outgoing LLC messages due to lockless memset.
--
commit 4dd2538a0566b239179ada14640f3f763de057d5
Author: D. Wythe <alibuda@linux.alibaba.com>
net/smc: clear the correct v2 slot and buffer in smc_wr_tx_put_slot()
This commit fixes a bug where pointers were being zeroed instead of the
structures they point to when clearing the v2 pending slot and buffer. By
passing the pointers directly and using sizeof(*pointer), it ensures the
intended structures are actually zeroed.
> diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c
> index 97ba46893b17f..def2ab84b0c71 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->lgr->wr_tx_buf_v2, 0,
> - sizeof(link->lgr->wr_tx_buf_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));
[Severity: High]
This isn't a bug introduced by this patch, but since the memset is now
correctly clearing the struct, could this create a data race with
smc_wr_tx_get_v2_slot()?
The first memset clears the entire smc_wr_tx_pend structure, which includes
the idx field. Once idx becomes 0, a concurrent thread calling
smc_wr_tx_get_v2_slot() might locklessly see that the slot is available
since it checks:
if (link->wr_tx_v2_pend->idx == link->wr_tx_cnt)
return -EBUSY;
If the concurrent thread grabs the slot and starts writing data into the
payload buffer, the second memset here will then overwrite that newly claimed
buffer with zeroes. Could this cause the hardware to transmit a corrupted
or empty message?
[Severity: High]
This is also a pre-existing issue, but while reviewing the V2 TX pending
state logic, could there be a DMA use-after-free during link teardown?
During teardown, smc_wr_free_link() waits for pending sends to finish by
calling smc_wr_tx_wait_no_pending_sends(), which relies on:
static inline bool smc_wr_is_tx_pend(struct smc_link *link)
{
...
return !bitmap_empty(link->wr_tx_mask, link->wr_tx_cnt);
}
This only checks the wr_tx_mask bitmap. However, the V2 TX slot does not use
the mask; its pending state is tracked by link->wr_tx_v2_pend->idx.
If only a V2 TX request is in flight, would smc_wr_is_tx_pend() return false
and allow smc_wr_tx_wait_no_pending_sends() to return early? This could allow
subsequent DMA unmap operations to free memory while the hardware is still
transmitting the V2 message.
> return 1;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260910104446.41423-1-alibuda@linux.alibaba.com?part=1
next prev parent reply other threads:[~2026-09-11 10:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 10:44 [PATCH net-next 0/2] net/smc: fix v2 slot clearing and reduce TX slot contention D. Wythe
2026-09-10 10:44 ` [PATCH net-next 1/2] net/smc: clear the correct v2 slot and buffer in smc_wr_tx_put_slot() D. Wythe
2026-09-11 10:45 ` sashiko-bot [this message]
2026-09-10 10:44 ` [PATCH net-next 2/2] net/smc: reduce TX slot contention with exclusive wait D. Wythe
2026-09-11 3:54 ` Mahanta Jambigi
2026-09-11 10:45 ` 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=20260911104506.76BF01F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=alibuda@linux.alibaba.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--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