All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mahanta Jambigi" <mjambigi@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH net v2 2/2] net/smc: fix races in smc_diag dump path
Date: Sat, 29 Aug 2026 06:55:17 +0000	[thread overview]
Message-ID: <20260829065517.962971F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828065439.3582783-3-mjambigi@linux.ibm.com>

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

Pre-existing issues:
- [High] Incomplete fix: Missing protection against concurrent connection teardown for SMC_DIAG_CONNINFO, leading to Use-After-Free on conn->sndbuf_desc and conn->rmb_desc.
--

commit 7eff481cca86fa2c9b695508a4e20ae6a02805ad
Author: Mahanta Jambigi <mjambigi@linux.ibm.com>

net/smc: fix races in smc_diag dump path

This commit addresses concurrent teardown races in the SMC diag dump path
by adding mutex protection to clcsock reads and spinlock protection to
the LGRINFO and DMBINFO block accesses.

> diff --git a/net/smc/smc_diag.c b/net/smc/smc_diag.c
> index bf0beaa23bdb6..06db3d769929a 100644
> --- a/net/smc/smc_diag.c
> +++ b/net/smc/smc_diag.c
[ ... ]
> @@ -143,45 +162,57 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,
>  			goto errout;
>  	}
>  

[Severity: High]
This is a pre-existing issue, but does this incomplete fix leave a
use-after-free regression open in the SMC_DIAG_CONNINFO block just above?

The patch successfully adds lgr_lnk_lock protection to the LGRINFO and
DMBINFO blocks below to prevent concurrent teardown races, but completely
omits this protection for the CONNINFO block.

In __smc_diag_dump(), the CONNINFO block locklessly checks
smc->conn.alert_token_local:

	if ((req->diag_ext & (1 << (SMC_DIAG_CONNINFO - 1))) &&
	    smc->conn.alert_token_local) {
		struct smc_connection *conn = &smc->conn;
		struct smc_diag_conninfo cinfo = {
			.token = conn->alert_token_local,
			.sndbuf_size = conn->sndbuf_desc ?
				conn->sndbuf_desc->len : 0,

If smc_conn_free() executes concurrently on another CPU immediately after
the token check, it will free conn->sndbuf_desc and conn->rmb_desc via
smcd_buf_detach().

The dump thread then locklessly dereferences these pointers when
accessing ->len, leading to a use-after-free that can be triggered by
an unprivileged user running a socket dump during a network abort.

Should the CONNINFO block also be wrapped in the same lgr_lnk_lock
protection that was applied to the other diagnostic blocks?

> -	if (smc_conn_lgr_valid(&smc->conn) && !smc->conn.lgr->is_smcd &&
> -	    (req->diag_ext & (1 << (SMC_DIAG_LGRINFO - 1))) &&
> -	    !list_empty(&smc->conn.lgr->list)) {
> -		struct smc_link *link = smc->conn.lnk;
> -
> -		struct smc_diag_lgrinfo linfo = {
> -			.role = smc->conn.lgr->role,

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

  reply	other threads:[~2026-08-29  6:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28  6:54 [PATCH net v2 0/2] net/smc: fix diag dump lifetime races Mahanta Jambigi
2026-08-28  6:54 ` [PATCH net v2 1/2] net/smc: add connection lifetime infrastructure for diag Mahanta Jambigi
2026-08-29  6:55   ` sashiko-bot
2026-08-28  6:54 ` [PATCH net v2 2/2] net/smc: fix races in smc_diag dump path Mahanta Jambigi
2026-08-29  6:55   ` sashiko-bot [this message]
2026-08-31 13:42 ` [PATCH net v2 0/2] net/smc: fix diag dump lifetime races Dust Li
2026-08-31 14:08   ` Mahanta Jambigi
2026-08-31 14:57   ` Mahanta Jambigi
2026-09-01 13:02     ` Dust Li
2026-09-01 15:13       ` Mahanta Jambigi
2026-09-02 12:16         ` Dust Li
2026-09-03  7:56           ` Mahanta Jambigi
2026-09-04 15:21             ` Dust Li
2026-09-08 16:23               ` Hidayath Khan
2026-09-09 16:07                 ` Dust Li

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=20260829065517.962971F000E9@smtp.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-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 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.