🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21466

Re: [PATCH net-next] sctp: copy endpoint settings to accepted and peeled-off sockets

#21466
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 02:04
158 lines
13596 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In sctp_auth_ep_copy() (net/sctp/auth.c), the per-key copy is
  incomplete: the source key's `deactivated` flag is not copied.
- [Low] The commit message says the change only affects restart
  negotiation and lists PR-SCTP, ECN, RECONF, ASCONF, I-DATA and AUTH.
- [Low] The commit fixes a wire-visible bug: an association restart on an
  accepted or peeled-off socket negotiates capabilities (PR-SCTP, ECN,…

--

sctp: copy endpoint settings to accepted and peeled-off sockets

This patch makes sctp_sock_migrate() copy the feature flags and AUTH
configuration from the listening socket's endpoint to the new endpoint.
Association restarts on accepted and peeled-off sockets then negotiate the
same capabilities as the listener. It adds sctp_auth_ep_copy(), which
deep-copies the HMAC list, the chunk list and the shared keys.

> As gomaja noticed, when accept() or SCTP_SOCKOPT_PEELOFF creates a new
> socket, sctp_endpoint_new() initialises the new endpoint from the network

[ ... ]

> Signed-off-by: Xin Long <lucien.xin@gmail.com>

[Severity: Low]
This fixes a restart negotiation problem that is visible on the wire.
There is no Fixes: tag to tell stable tooling which commit introduced it.
Could one be added?

The reporter is credited in prose ("As gomaja noticed"), but there is no
Reported-by: or Closes: trailer. Should one be included?

> diff --git a/net/sctp/auth.c b/net/sctp/auth.c
> index cbeb8a87a17a7..e075297b9ead1 100644
> --- a/net/sctp/auth.c
> +++ b/net/sctp/auth.c
> @@ -1056,3 +1056,50 @@ void sctp_auth_free(struct sctp_endpoint *ep)
>  	ep->auth_hmacs_list = NULL;
>  	ep->auth_chunk_list = NULL;
>  }
> +
> +int sctp_auth_ep_copy(struct sctp_endpoint *dst,
> +		      const struct sctp_endpoint *src, gfp_t gfp)
> +{
> +	struct sctp_shared_key *sh_key, *new_key;
> +

[ ... ]

> +	key_for_each(sh_key, &src->endpoint_shared_keys) {
> +		new_key = sctp_auth_shkey_create(sh_key->key_id, gfp);
> +		if (!new_key)
> +			goto nomem;
> +		new_key->key = sh_key->key;
> +		sctp_auth_key_hold(new_key->key);
> +		list_add_tail(&new_key->key_list, &dst->endpoint_shared_keys);
> +	}

[Severity: Medium]
Should sh_key->deactivated be copied into new_key here too?

sctp_auth_shkey_create() returns a zeroed container. Only key_id, refcnt
and key_list are set, and this loop never reads sh_key->deactivated.

For endpoint keys, sctp_auth_deact_key_id() leaves the key on
ep->endpoint_shared_keys and only marks it:

net/sctp/auth.c:sctp_auth_deact_key_id() {
    ...
	key->deactivated = 1;
    ...
}

After accept() or peeloff, a key that was deactivated on the listening
socket therefore looks active again on the new endpoint. This check in
sctp_auth_set_active_key() no longer fires for it:

	if (!found || key->deactivated)
		return -EINVAL;

An endpoint-level SCTP_AUTH_ACTIVE_KEY for a retired key id returns
-EINVAL on the listener but succeeds on the new socket. That lets
newep->active_key_id point at the retired key. Associations created later
on the new endpoint, for example on restart, would then inherit it.

Would something like this be needed?

	new_key->deactivated = sh_key->deactivated;

sctp_auth_asoc_copy_shkeys() also drops this flag when it copies keys
into associations. That part is existing behaviour, not something this
patch adds.

[ ... ]

> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index bc68af88e2710..bfd87be8ed54c 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -9623,6 +9623,23 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
>  	if (err)
>  		return err;
>  
> +	/* Copy the endpoint's feature flags and AUTH settings from the original
> +	 * endpoint so that restarts on the accepted or peeled-off socket
> +	 * negotiate the same capabilities.
> +	 */
> +	newep->prsctp_enable = oldsp->ep->prsctp_enable;
> +	newep->ecn_enable = oldsp->ep->ecn_enable;
> +	newep->reconf_enable = oldsp->ep->reconf_enable;
> +	newep->asconf_enable = oldsp->ep->asconf_enable;
> +	newep->intl_enable = oldsp->ep->intl_enable;
> +	newep->strreset_enable = oldsp->ep->strreset_enable;
> +	newep->sndbuf_policy = oldsp->ep->sndbuf_policy;
> +	newep->rcvbuf_policy = oldsp->ep->rcvbuf_policy;

[Severity: Low]
The commit message only covers restart negotiation of PR-SCTP, ECN,
RECONF, ASCONF, I-DATA and AUTH. It doesn't mention these last three
copies.

sndbuf_policy and rcvbuf_policy are not negotiated. sctp_endpoint_init()
sets them only from net->sctp.sndbuf_policy and net->sctp.rcvbuf_policy.

Once sctp_assoc_migrate() sets asoc->ep = newep, the live association
reads them in these functions:

  sctp_wspace()
  sctp_wake_up_waiters()
  sctp_assoc_rwnd_decrease()
  sctp_ulpevent_make_rcvmsg()
  inet_sctp_diag_fill()

If the sysctls changed between creating the listener and accept() or
peeloff, this changes which buffer accounting model the migrated
association uses.

strreset_enable is also copied without mention. New associations inherit
it, and getsockopt(SCTP_ENABLE_STREAM_RESET) reports it.

Could the commit message describe these copies as well?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/48580ca6a02b588e9c24444801109506da11a9d2.1795396989.git.lucien.xin%40gmail.com
Technical Details
Message-ID: <179548588251.3135.10014340190099201603@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369950-linux-kernel-netdev=dewy.ru
References: <48580ca6a02b588e9c24444801109506da11a9d2.1795396989.git.lucien.xin@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369950-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next] sctp: copy endpoint settings to accepted and
 peeled-off sockets
Date: Tue, 24 Nov 2026 02:04:42 +0000
Organization: Usenet Network
Message-ID: <179548588251.3135.10014340190099201603@kernel.org>
References: <48580ca6a02b588e9c24444801109506da11a9d2.1795396989.git.lucien.xin@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4031008"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Fx1eyO8/CbSgz+dL/KsAx1uF3vk= sha256:UuNw7Fn9Q1BcokjiPJWDjFXIbOUUZ3NEzxfVSIcIsjg=
	sha1:O/DCZV4H62Wuul7Ek1maI9jR6Eo= sha256:EkRvylm3UgO3x7nF99IQ6st53ROOnVgR2h891QoOcM0=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id F1C7B125DC8; Tue, 24 Nov 2026 05:05:07 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id qB024yXjnWah;
	Tue, 24 Nov 2026 05:04:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369950-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id CAFA8125DC7; Tue, 24 Nov 2026 05:04:49 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 28DA033B6A; Tue, 24 Nov 2026 02:04:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795485885;
	b=KrdLlyzV79lbkfNFBg3JJmAbGXt4EVB782WdDPwXu44rOFfTXxVqTCFNzlpHk0vp2wEh
	 evaM612/4B3Leekswtzs+9bn7I3kZwZuQmM1reLggmABE3q9Ot+p8SR5quAheUPE2uzAA
	 p9M0ccfQCtEYD1xjtP5tO0N2xrmRqBsttd/SmgcR8Xkdk3XNyXX9vD/Yv6MHKdWhhbWqe
	 Pn6BKi0COw+yaTruIgyGitPxaEhzkl585o9y10pPmQqn4eF7B2eVWgu7cLMllNjZHiBor
	 qqtBXiQGbj/SXmtJIm4gCQjvNjoOMm7e5s0VKg0Yazxh05DA8uwmMFJU9tR1FlikpyA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795485885;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=+Gl7eprlpv+ZUtOJgjcLpfqTJt8SES8zPLde496oxuw=;
	b=UrxSaH9/daFnZbRmNflip/8O99nN1SKLw/sbsh+d/n+m5RgN1fl+LM1ARJSmGXu6K2o8
	 l3Ltp31XwmFXWRSef39/IsGzHvelsc/6A55B3hDW/vc0gyawafkCNbN8LGNeEAEiLeC/5
	 swZQSBRP1OlHrY5y6+1filLVOqOIgx5NS0T8zKNhryAzJSQFPZZAICyaTCvMIiGSuujDZ
	 UAaL8Una2wg62sXg1WRWQ6HquTOze6NKlGzVaHRfYoVwc5zYraN5sORUUV5X/pi6amvmL
	 BoZXWUztTWhprfjENomT+8c7psx1WBbWPLeq25iM/hbMw1HX0OF0fuBar/i2UDoCH9A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NBIZ1yCK;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id F29CA606A32D;
	Tue, 24 Nov 2026 02:04:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NBIZ1yCK
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795485884;
	b=SFUtgmf6afjSMLWh9EqtLZG0Xkz1e6hkVkEEpTTG8NdAR6rmSj2g9PKsaDO0mxQKqLOs
	 UJkEbBG00AwqdLY5fY0GHIbERKg+IQbDQ69Ki+H/n+fW0V9OMipl+yAHdX7KOjEwLWci3
	 pReK0Ni8ErGlBMAi/nV07tLZm1x8woWqQarb3O25/Ue8P11l9Eqt8psnNR1mtS/dlu3Vb
	 C2D+GgvgbS9CVs5HOKkKeUHVYG3WhqALYj46BaKCbl7zU5lqr+QQ8LcZlRSHQJtAWTTz4
	 oyTWyXS0dFkWUeqqAdESD3yDxQ/9p6lJscoNj54ivCKrzwECkiuAjYT5LMp7j4CV9Yg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795485884;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=+Gl7eprlpv+ZUtOJgjcLpfqTJt8SES8zPLde496oxuw=;
	b=DFxYIdpzThPMxZ7yss5XHPMcWXoIsm2ngXzOe1Q7gyMk0jYeNbpnU5Fw+B4JgWUWsvEn
	 NwxUyUGo4m30mx9hKnnPHF+WjyYLjNvYXjfut0iKncKrS6Q8l5kMWDRMGqGXwE4ylEu5O
	 G4+AJ7na/abihofU9ZV5Cxw+LRGTrkrGc/NcEmy6wvw7jdsB+CNCVIEG0KV1bMsGtdQyZ
	 54rad5Cm8xUDJ6ez1ziM/U/HMBMBXTYMHZiAPBIDGby/F7PoAuBnNzBwGp1s1hMyYvXBm
	 Q6TpfDzj1FZlLz3vwkAwfnSfJpA3imW4BKsie2FcxuG0+pku06bu1nAv+m9Trwji/Ag==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NBIZ1yCK;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18619606A31E;
	Tue, 24 Nov 2026 02:04:44 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECC431F000CA;
	Tue, 24 Nov 2026 02:04:42 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795485883;
	bh=+Gl7eprlpv+ZUtOJgjcLpfqTJt8SES8zPLde496oxuw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=NBIZ1yCKVUUiAb+KP3zu+CMqbegXtT5JZdE3NmbWKo2rwYlNWQyAtMmYl8O3DjOQY
	 O7XXPCR5pAiLkQzjZ2cbH+0oVnVbalVFDqjaQtsfCgXvTIJKBMm2fSdlM9VzTcNcpF
	 I7E1rl2rJOnO4qIjZH3qU8CpPEapfkxtqojUFEcRlCtFJvB5LJ7soH6GTvDgeL9UT2
	 icGntIvTrjI9LzGZz5kwBg0PwoCCDaGn84ILOiLZoHBg5JWg4ICge7OVYoPGkn+nuq
	 GRuI5NSldFvZKGYZ/zxwFAA++GXCN8cHWDkEpVyYufUTZ7k3rzepc4uDoJ46gMIK/5
	 DJgGEEcP7/Q/w==
X-Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org, davem@davemloft.net,
 kuba@kernel.org, edumazet@kernel.org, pabeni@redhat.com, horms@kernel.org,
 marcelo.leitner@gmail.com
X-In-Reply-To: <48580ca6a02b588e9c24444801109506da11a9d2.1795396989.git.lucien.xin@gmail.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list