Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yifei Gao" <gyf161023@gmail.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH] net/smc: fix sock refcount leak in smc_switch_conns() error path
Date: Wed, 05 Aug 2026 21:39:36 +0000	[thread overview]
Message-ID: <20260805213937.5B4CF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804213917.3413525-1-gyf161023@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] A concurrent connection abort during failover causes the healthy backup link to be erroneously torn down, failing the entire link group failover.
--

--- Patch [1]: [PATCH] net/smc: fix sock refcount leak in smc_switch_conns() error path ---
commit 1858eaf3cce20ce7bd2bd6af774eda2e7fe87f8d
Author: Yifei Gao <gyf161023@gmail.com>

net/smc: fix sock refcount leak in smc_switch_conns() error path

This commit resolves a socket reference count leak in smc_switch_conns()
by ensuring sock_put() is called when smc_cdc_get_free_slot() fails.

> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
> index b4208cb186c5e..c0027d2fe4e8c 100644
> --- a/net/smc/smc_core.c
> +++ b/net/smc/smc_core.c

[ ... ]

> @@ -1148,8 +1148,10 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr,
>  		read_unlock_bh(&lgr->conns_lock);
>  		/* pre-fetch buffer outside of send_lock, might sleep */
>  		rc = smc_cdc_get_free_slot(conn, to_lnk, &wr_buf, NULL, &pend);
> -		if (rc)
> +		if (rc) {
> +			sock_put(&smc->sk);
>  			goto err_out;
> +		}

[Severity: High]
This isn't a bug introduced by this patch, but this modified error path
appears to have a pre-existing logic issue during a concurrent abort.

If a concurrent abort event occurs (for example, if smc_cdc_msg_validate()
detects an invalid CDC sequence number) and sets conn->killed = 1,
smc_cdc_get_free_slot() will observe this and return -EPIPE.

Since smc_switch_conns() does not distinguish this connection-specific
error from a link-level error, it will jump directly to err_out and call
smcr_link_down_cond_sched(to_lnk).

Does this inadvertently tear down the healthy backup link and disrupt all
other connections in the link group that were successfully failing over,
just because a single connection was killed?

>  		/* avoid race with smcr_tx_sndbuf_nonempty() */
>  		spin_lock_bh(&conn->send_lock);
>  		smc_switch_link_and_count(conn, to_lnk);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260804213917.3413525-1-gyf161023@gmail.com?part=1

      parent reply	other threads:[~2026-08-05 21:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 21:39 [PATCH] net/smc: fix sock refcount leak in smc_switch_conns() error path Yifei Gao
2026-08-05  3:18 ` Tony Lu
2026-08-05  4:40 ` Mahanta Jambigi
2026-08-05  6:26 ` Hidayathulla Khan I
2026-08-06 15:00   ` 高逸飞
2026-08-05 21:39 ` 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=20260805213937.5B4CF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=gyf161023@gmail.com \
    --cc=hca@linux.ibm.com \
    --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