From: sashiko-bot@kernel.org
To: "Xiang Mei" <xmei5@asu.edu>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH net v2] net/smc: fix UAF in smc_cdc_rx_handler() by pinning the socket
Date: Wed, 01 Jul 2026 18:32:40 +0000 [thread overview]
Message-ID: <20260701183240.ED0B71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630183227.2044998-1-xmei5@asu.edu>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Concurrent unprotected bitfield modifications in `struct smc_connection` can lead to lost updates for `freed`, `killed`, or `out_of_sync` flags, causing reference count underflows and Use-After-Free.
--
commit 2f1e95dfacd6a1bad8a756fc60b2dadb865fcaac
Author: Xiang Mei <xmei5@asu.edu>
net/smc: fix UAF in smc_cdc_rx_handler() by pinning the socket
This commit fixes a use-after-free in smc_cdc_rx_handler() by taking a socket
reference while holding conns_lock. This ensures the connection and socket
remain valid while the receive handler runs.
> diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
> index 619b3bab38248..32d6d03df3214 100644
> --- a/net/smc/smc_cdc.c
> +++ b/net/smc/smc_cdc.c
[ ... ]
> @@ -483,21 +483,26 @@ static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf)
> lgr = smc_get_lgr(link);
> read_lock_bh(&lgr->conns_lock);
> conn = smc_lgr_find_conn(ntohl(cdc->token), lgr);
> - read_unlock_bh(&lgr->conns_lock);
> - if (!conn || conn->out_of_sync)
> + if (!conn || conn->out_of_sync) {
> + read_unlock_bh(&lgr->conns_lock);
> return;
> + }
> smc = container_of(conn, struct smc_sock, conn);
> + sock_hold(&smc->sk);
> + read_unlock_bh(&lgr->conns_lock);
>
> if (cdc->prod_flags.failover_validation) {
> smc_cdc_msg_validate(smc, cdc, link);
> - return;
> + goto out;
[Severity: Critical]
This is a pre-existing issue, but can concurrent bitfield modifications in
struct smc_connection lead to lost updates and a use-after-free?
In net/smc/smc.h, we have:
struct smc_connection {
...
u8 killed : 1; /* abnormal termination */
u8 freed : 1; /* normal termination */
u8 out_of_sync : 1; /* out of sync with peer */
};
When smc_cdc_msg_validate() is called from softirq (tasklet) context here,
it sets conn->out_of_sync = 1 locklessly.
If a softirq interrupts a process context that is simultaneously setting
conn->freed = 1 in smc_conn_free(), or if they execute concurrently on
different CPUs, the compiler's read-modify-write on the shared byte could
cause one update to overwrite the other.
If the update to conn->freed = 1 is lost, could smc_conn_free() be executed
multiple times on the same connection, bypassing an early if (conn->freed)
check? This seems like it could underflow the link and link-group reference
counts, leading to a use-after-free of those structures.
> }
> if (smc_cdc_before(ntohs(cdc->seqno),
> conn->local_rx_ctrl.seqno))
> /* received seqno is old */
> - return;
> + goto out;
>
> smc_cdc_msg_recv(smc, cdc);
> +out:
> + sock_put(&smc->sk);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630183227.2044998-1-xmei5@asu.edu?part=1
prev parent reply other threads:[~2026-07-01 18:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 18:32 [PATCH net v2] net/smc: fix UAF in smc_cdc_rx_handler() by pinning the socket Xiang Mei
2026-07-01 18:32 ` 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=20260701183240.ED0B71F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=xmei5@asu.edu \
/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