From: sashiko-bot@kernel.org
To: "Qican Ma" <goonsomeway@gmail.com>
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] net/smc: serialize clcsock release against CDC receive path
Date: Tue, 01 Dec 2026 06:24:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-242694@kernel.org> (raw)
In-Reply-To: <179610581608.84222.8603821461741221796@gmail.com>
> In smc_cdc_msg_recv_action(), receiving a close or senddone flag writes
> RCV_SHUTDOWN to smc->clcsock->sk->sk_shutdown while holding only
> bh_lock_sock(&smc->sk). Meanwhile __smc_release() drops the socket lock
> and calls smc_clcsock_release() (which clears smc->clcsock and calls
> sock_release() under clcsock_release_lock) before calling
> smc_conn_free(&smc->conn). Even on paths that call smc_conn_free() first,
> an in-flight SMC-R softirq that already looked up the connection in
> smc_cdc_rx_handler() can still enter smc_cdc_msg_recv() concurrently with
> smc_clcsock_release() and dereference or write through a freed clcsock.
>
> Free the SMC connection before releasing clcsock in __smc_release(),
> matching smc_close_active_abort() and smc_close_passive_work(). Because
> smc_conn_free() sets conn->freed while lock_sock(sk) is held and
> release_sock(sk) synchronizes on sk->sk_lock.slock before
> smc_clcsock_release() runs, checking !smc->conn.freed under
> bh_lock_sock(&smc->sk) in smc_cdc_msg_recv() guarantees that no CDC
> handler accesses smc->clcsock once smc_clcsock_release() can start.
>
> The freed flag is written under lock_sock() but read under bh_lock_sock()
> in softirq context, so the writer side and the smc_conn_create()
> initializer use WRITE_ONCE() and the CDC reader uses READ_ONCE() to avoid
> a KCSAN data race, as pointed out by Willem de Bruijn.
>
> Found with an LLM-assisted code review tool and verified by inspection on
> v7.4-rc4 (b6a9fa34ce4). Build-tested only; not runtime-tested due to lack
> of an SMC-R/SMC-D setup.
>
> Fixes: b38d732477e4 ("smc: socket closing and linkgroup cleanup")
> Cc: stable@vger.kernel.org
> Signed-off-by: Qican Ma <goonsomeway@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/179610581608.84222.8603821461741221796@gmail.com?part=1
prev parent reply other threads:[~2026-12-01 6:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 6:16 [PATCH net v3] net/smc: serialize clcsock release against CDC receive path Qican Ma
2026-12-01 6:24 ` 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-242694@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=goonsomeway@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.