From: Dust Li <dust.li@linux.alibaba.com>
To: Yifei Chu <Chuyf26@linux.alibaba.com>, alibuda@linux.alibaba.com
Cc: sidraya@linux.ibm.com, mjambigi@linux.ibm.com, kuba@kernel.org,
pabeni@redhat.com, tonylu@linux.alibaba.com,
guwen@linux.alibaba.com, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH v4] net/smc: release the internal TCP sock on IPPROTO_SMC socket creation failure
Date: Wed, 26 Aug 2026 15:42:44 +0800 [thread overview]
Message-ID: <ao6Y9P24-tnV3VVo@linux.alibaba.com> (raw)
In-Reply-To: <178753843966.342810.566471390946765094@linux.alibaba.com>
On 2026-08-24 10:27:19, Yifei Chu wrote:
>IPPROTO_SMC sockets create an internal TCP sock ("clcsock") from the
>proto->init hook. When socket creation fails after proto->init has
>run - e.g. a cgroup BPF program attached to BPF_CGROUP_INET_SOCK_CREATE
>denies the socket - sk_common_release() only invokes sk_prot->destroy
>if it is set, but neither smc_inet_prot nor smc_inet6_prot defines it,
>and smc_destruct() returns early unless sk_state is SMC_CLOSED. As a
>result, every failing socket(AF_INET, SOCK_STREAM, IPPROTO_SMC) call
>leaks one tcp_sock, so an unprivileged task able to attach a deny-all
>BPF_CGROUP_INET_SOCK_CREATE program to its own cgroup can grow kernel
>memory unboundedly.
>
>Add a .destroy hook to both protos that releases the clcsock via
>smc_clcsock_release(). smc_sk_init() hashes the sock into the smc
>hashinfo before the clcsock is created, and smc_diag dumps walk that
>hash dereferencing smc->clcsock without taking clcsock_release_lock,
>while sk_common_release() calls .destroy before .unhash. Unhash the
>sock before releasing the clcsock, as __smc_release() does, so a
>concurrent dump cannot observe the release; the second unhash in
>sk_common_release() is a no-op.
>
>Fixes: d25a92ccae6b ("net/smc: Introduce IPPROTO_SMC")
>Reported-by: Abaci <abaci@linux.alibaba.com>
>Assisted-by: abaci:qwen3.8-max
>Signed-off-by: Yifei Chu <Chuyf26@linux.alibaba.com>
Reviewed-by: Dust Li <dust.li@linux.alibaba.com>
Best regards,
Dust
prev parent reply other threads:[~2026-08-26 7:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 2:27 [PATCH v4] net/smc: release the internal TCP sock on IPPROTO_SMC socket creation failure Yifei Chu
2026-08-24 2:39 ` sashiko-bot
2026-08-26 7:42 ` Dust Li [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=ao6Y9P24-tnV3VVo@linux.alibaba.com \
--to=dust.li@linux.alibaba.com \
--cc=Chuyf26@linux.alibaba.com \
--cc=alibuda@linux.alibaba.com \
--cc=guwen@linux.alibaba.com \
--cc=kuba@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjambigi@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sidraya@linux.ibm.com \
--cc=tonylu@linux.alibaba.com \
/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