Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sechang Lim" <rhkrqnwk98@gmail.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
	linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	bpf@vger.kernel.org
Subject: Re: [PATCH net v3] net/smc: fix out-of-bounds read when sk_user_data holds a sk_psock
Date: Tue, 30 Jun 2026 09:52:16 +0000	[thread overview]
Message-ID: <20260630095216.E744F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260629095140.679754-1-rhkrqnwk98@gmail.com>

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

Pre-existing issues:
- [Critical] Unconditional overwrite of sk_user_data during SMC fallback causes sk_psock memory leak and critical type confusion (control flow hijack).
--

commit c092e3d84654761aba7753030c182ca2840fc519
Author: Sechang Lim <rhkrqnwk98@gmail.com>

net/smc: fix out-of-bounds read when sk_user_data holds a sk_psock

A passive-open child inherits the listener's smc_clcsock_data_ready callback.
This commit reserves the child's sk_user_data with a NULL pointer tagged
SK_USER_DATA_NOCOPY to prevent sockmap from claiming the slot, and releases
it at accept.

> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index b5db69073e20f..78f162344fe3a 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c

[ ... ]

> @@ -1786,6 +1791,9 @@ static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc)
>  		if (lsmc->clcsk_error_report)
>  			new_clcsock->sk->sk_error_report = lsmc->clcsk_error_report;
>  	}
> +	/* release the slot reserved in smc_tcp_syn_recv_sock() */
> +	rcu_assign_sk_user_data(new_clcsock->sk, NULL);

[Severity: Critical]
This is a pre-existing issue, but does clearing this reservation to NULL
explicitly re-open the window for a BPF sockmap program to attach to the
socket during the subsequent SMC handshake?

If a BPF SOCK_OPS program attaches the established TCP socket to a sockmap,
sk_psock_init() can set sk_user_data to a new sk_psock and hijack the socket
callbacks. Should the SMC handshake fail and fall back to TCP, the fallback
path appears to blindly overwrite sk_user_data:

net/smc/af_smc.c:smc_fback_replace_callbacks() {
        ...
        write_lock_bh(&clcsk->sk_callback_lock);
        __rcu_assign_sk_user_data_with_flags(clcsk, smc, SK_USER_DATA_NOCOPY);
        ...
}

Can this lead to a type confusion if the hijacked sockmap callbacks are left
active? When TCP data arrives, smc_fback_data_ready would forward to the
sockmap callback which dereferences sk_user_data expecting a struct sk_psock,
but receives a struct smc_sock instead.

> +	write_unlock_bh(&new_clcsock->sk->sk_callback_lock);
>  
>  	(*new_smc)->clcsock = new_clcsock;
>  out:

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

      reply	other threads:[~2026-06-30  9:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29  9:51 [PATCH net v3] net/smc: fix out-of-bounds read when sk_user_data holds a sk_psock Sechang Lim
2026-06-30  9:52 ` 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=20260630095216.E744F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=bpf@vger.kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=rhkrqnwk98@gmail.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