Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mahanta Jambigi" <mjambigi@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, linux-rdma@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-next 2/3] net/smc: remove the clcsock release lock
Date: Sat, 21 Nov 2026 12:46:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-227019@kernel.org> (raw)
In-Reply-To: <20261120124534.430200-3-mjambigi@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] net/smc: socket reference leak in smc_conn_free() and
  smc_clcsock_release() [1]
--

commit 6864a40c043f192c54d4d3afdd20c8aa7e2a7d49
Author: Mahanta Jambigi <mjambigi@linux.ibm.com>

net/smc: remove the clcsock release lock

This commit removes smc->clcsock_release_lock and the associated NULL
checks on smc->clcsock, relying instead on the socket lock during accept
and work flushing during clcsock teardown.

> diff --git a/net/smc/smc_close.c b/net/smc/smc_close.c
> index cf1add1ffda62..e71245dbb2960 100644
> --- a/net/smc/smc_close.c
> +++ b/net/smc/smc_close.c
> @@ -27,13 +27,13 @@ void smc_clcsock_release(struct smc_sock *smc)
>  
>  	if (smc->listen_smc && current_work() != &smc->smc_listen_work)
>  		cancel_work_sync(&smc->smc_listen_work);

[Severity: High]
This problem wasn't introduced by this patch, but can ignoring the return
value of cancel_work_sync() here and in smc_conn_free() leak socket
references [1]?

When smc_tcp_listen_work() queues smc->smc_listen_work, it takes
references on both the listener and child sockets that the work handler
is responsible for dropping:

net/smc/af_smc.c:smc_tcp_listen_work() {
	...
	while (lsk->sk_state == SMC_LISTEN) {
		...
		sock_hold(lsk); /* sock_put in smc_listen_work */
		INIT_WORK(&new_smc->smc_listen_work, smc_listen_work);
		...
		sock_hold(&new_smc->sk); /* sock_put in passive closing */
		if (!schedule_work(&new_smc->smc_listen_work))
			sock_put(&new_smc->sk);
	}
}

If smc_clcsock_release() cancels smc_listen_work before it runs,
cancel_work_sync() returns true and those references are never released,
leaking the SMC socket structures.  Similarly, smc_cdc_msg_validate()
calls sock_hold(&smc->sk) before scheduling conn->abort_work, and
smc_conn_free() ignores the return value of
cancel_work_sync(&conn->abort_work), leaking smc->sk when the abort work
is cancelled while pending.

[1] https://sashiko.dev/#/bug/linux-6e05f850-6f03-40a8-8a7b-254bd11242da

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120124534.430200-1-mjambigi@linux.ibm.com?part=2

  reply	other threads:[~2026-11-21 12:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 12:45 [PATCH net-next 0/3] net/smc: fix clcsock lifetime vs asynchronous paths Mahanta Jambigi
2026-11-20 12:45 ` [PATCH net-next 1/3] net/smc: keep clcsock until socket release Mahanta Jambigi
2026-11-21 12:46   ` sashiko-bot
2026-11-20 12:45 ` [PATCH net-next 2/3] net/smc: remove the clcsock release lock Mahanta Jambigi
2026-11-21 12:46   ` sashiko-bot [this message]
2026-11-20 12:45 ` [PATCH net-next 3/3] net/smc: document the clcsock lifetime Mahanta Jambigi
2026-11-21 12:46 ` [PATCH net-next 0/3] net/smc: fix clcsock lifetime vs asynchronous paths 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=sashiko-outbox-227019@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.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=mjambigi@linux.ibm.com \
    --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