Article View: linux.kernel.netdev
Article #1094[PATCH net v4 1/2] sctp: hold shkey across socket migration
From: Jun Yang
Date: Fri, 09 Oct 2026 07:42
Date: Fri, 09 Oct 2026 07:42
66 lines
10599 bytes
10599 bytes
From: David Lee <david.lee@trailofbits.com>
sctp_sock_migrate() transfers queued DATA skbs from the old socket to the
new one. skb_orphan() invokes sctp_wfree() during that transfer and drops
the skb-owned shared-key reference.
If userspace has removed that key from the association, this can be the
final reference. The following sctp_set_owner_w() then dereferences the
freed chunk->shkey while trying to take the new owner reference.
Take a temporary shared-key reference before orphaning the skb and release
it after the new owner has taken its reference. This preserves the selected
authentication key throughout the ownership transfer.
Bug found and triaged by OpenAI Security Research and
validated by Trail of Bits.
Fixes: 1b1e0bc99474 ("sctp: add refcnt support for sh_key")
Assisted-by: Codex:gpt-5.6-sol gpt-5.5-cyber
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Signed-off-by: David Lee <david.lee@trailofbits.com>
Acked-by: Xin Long <lucien.xin@gmail.com>
---
v4:
- Add David Lee's and the forwarding submitter's sign-offs.
Original submission:
https://lore.kernel.org/netdev/20260731120558.558957-1-david.lee@trailofbits.com/
net/sctp/socket.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index c7b9e325ec1c..4a08023d52aa 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -147,9 +147,19 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk)
static void sctp_clear_owner_w(struct sctp_chunk *chunk)
{
+ /* Keep the shkey alive until the new owner takes its reference. */
+ if (chunk->shkey)
+ sctp_auth_shkey_hold(chunk->shkey);
skb_orphan(chunk->skb);
}
+static void sctp_set_owner_w_migrate(struct sctp_chunk *chunk)
+{
+ sctp_set_owner_w(chunk);
+ if (chunk->shkey)
+ sctp_auth_shkey_release(chunk->shkey);
+}
+
#define traverse_and_process() \
do { \
msg = chunk->msg; \
@@ -9632,7 +9642,7 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
lock_sock_nested(newsk, SINGLE_DEPTH_NESTING);
sctp_for_each_tx_datachunk(assoc, true, sctp_clear_owner_w);
sctp_assoc_migrate(assoc, newsk);
- sctp_for_each_tx_datachunk(assoc, false, sctp_set_owner_w);
+ sctp_for_each_tx_datachunk(assoc, false, sctp_set_owner_w_migrate);
/* If the association on the newsk is already closed before accept()
* is called, set RCV_SHUTDOWN flag.
Technical Details
Message-ID:
<20261009074244.3718-2-juny24602@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343491-linux-kernel-netdev=dewy.ruReferences:
<20261009074244.3718-1-juny24602@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343491-linux-kernel-netdev=dewy.ru
From: juny24602@gmail.com (Jun Yang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v4 1/2] sctp: hold shkey across socket migration
Date: Fri, 9 Oct 2026 15:42:31 +0800
Organization: Usenet Network
Message-ID: <20261009074244.3718-2-juny24602@gmail.com>
References: <20261009074244.3718-1-juny24602@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1056926"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dP8+7ZYI602Dbvd6TAqYqHNYkwY= sha256:U4KdFZV9e0PmNPEg6Ct1lc9tEBKa/s9yMv69XFEDs9s=
sha1:Q5zzkN87zgDOH+ihddsNmgTMtNI= sha256:pC+io7VfBjtglzPMzQC1vrBsowOn+qw67nf5sNQ+5pc=
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 D8E0F10F5F2; Fri, 9 Oct 2026 10:44:18 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
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 jMF4Bl4lsV6g;
Fri, 9 Oct 2026 10:44:15 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-343491-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id DD7D510F5AC; Fri, 9 Oct 2026 10:44:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by tor.lore.kernel.org (Postfix) with ESMTP id 89C0038152; Fri, 9 Oct 2026 07:43:14 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 76B5847DF91;
Fri, 9 Oct 2026 07:43:12 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l9R+++0w"
X-Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4728547F797
for <netdev@vger.kernel.org>; Fri, 9 Oct 2026 07:43:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791531792; cv=none; b=ZHKmRMmz7cLaJp2yuJmwzu8zoi5ckCfcmSyrlOM/PKZL/Yi63ZNtIejVnIG+rf+2fJtVHBgONF3NedAWcN6o6P7ABPriFNXPHAQl9RNIDsfDtbwSaXgx1Q+EvAHqMoJhR1F74dbCTr4LMaXQPsMAV2/7y79eq9jXEL7Eua/QnjU=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791531792; c=relaxed/simple;
bh=qiZqiT0Tg1+Sp+sltzNiNK5HsXboDlmJ8Ghw6/SA9jk=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
MIME-Version; b=I4SS1TqFEajEt5eoDgqcWTaJJPrzz0dxbAd7mnvjtAaOrAgCMpjzhCOnu1fQaLoDfPYFBVp1kQr7I8GX9TAPR8ao4epEm7e8k7y+gUzwMg4V4g3Zky1kSZp1hyVsfaxLml0tze2kdo7G8DZ15BiVDbvIn5pGniXALuKLhI87bkc=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l9R+++0w; arc=none smtp.client-ip=209.85.216.53
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-38759bcd877so3152431a91.2
for <netdev@vger.kernel.org>; Fri, 09 Oct 2026 00:43:10 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1791531790; x=1792136590; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=4EGTu/vKHlKEvtTJS4Y1X7sDSvkjeqeXv7lxJj991V8=;
b=l9R+++0w8Ddo4s7S1V9EAZmKKzG4P4Iu8n1j5rOSvIvKT5yH13JQsTHb77IMsmrHgg
iEauB15+UHLJxIRGRsRQ7z+NQYU9zBsDt3Rs8MJo6Q1eG/sZpJnGutzBlVxAtRvB5Htv
FWiz5vCCN41wROuE8Zd7Bxc0EORKOHKmia04GUpL16sn8W6yrER+d4ZDuAQ/0sD2dhTM
XggeNceaa147ZtYUQjDzJTEun/4SkU7yi5JAixWcr0LAOGWhVkw5WFI5FfzOVZrxx388
h4XHcanBO0BUrZZE6lQKkti/ywsks8Zv4QAfLPVXeky4KsMzu432goq7eU0E8mS1tKt0
5M6w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1791531790; x=1792136590;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=4EGTu/vKHlKEvtTJS4Y1X7sDSvkjeqeXv7lxJj991V8=;
b=ADReH1dg/ONBuxioHGXBExLR7QL/5nrdtjRZ1ESPvTBY5Xz/nhOwe9osqrE0RayLsy
IgIx+9kO0x8AzAiy2am9r6FXZiscDbY8IpgOqpGucTuXKclk6Vi65ApAzpOPrEc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08 with SMTP id 98e67ed59e1d1-3ab3a4875cdmr1076377a91.9.1791531789860;
Fri, 09 Oct 2026 00:43:09 -0700 (PDT)
X-Received: from JUNVYYANG-MC1.tencent.com ([43.132.141.21])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ab38ddac6dsm2124986a91.7.2026.10.09.00.43.07
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Fri, 09 Oct 2026 00:43:09 -0700 (PDT)
X-Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
linux-sctp@vger.kernel.org,
netdev@vger.kernel.org,
David Lee <david.lee@trailofbits.com>,
Kyle Zeng <kylebot@openai.com>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261009074244.3718-1-juny24602@gmail.com>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>