Article View: linux.kernel.netdev
Article #27002[PATCH net v2 2/2] macsec: drop the conntrack entry of delivered clones to fix a double free
From: Juan Agustin Niccolini
Date: Fri, 04 Dec 2026 15:23
Date: Fri, 04 Dec 2026 15:23
81 lines
14237 bytes
14237 bytes
When validation is not strict, macsec delivers a clone of a frame that
has no SecTAG, or a SecTAG with an unknown SCI, to each macsec device on
the lower device, while the original goes on up the lower device. With
offload, multicast frames are cloned to the macsec device the same way.
The clone keeps the original's conntrack entry. That entry is still
unconfirmed if tc act_ct attached it at the lower device's ingress, or
if the lower device is a bridge and conntrack ran on the bridge for a
frame to the host. netfilter treats an unconfirmed entry as owned by a
single skb: nf_ct_ext_add() moves its extension area with krealloc()
without any locking. When RPS processes the clone on another CPU, the
original and the clone can do this at the same time, and the old area
is freed twice:
BUG: KASAN: double-free in krealloc_node_align_noprof+0x1c6/0x340
Free of addr ff11000010e24e00 by task macsec_untagged/218
An unprivileged user can trigger this from a user and network
namespace, with a macsec device set to "validate disabled": RPS can be
enabled there for new devices through net.core.rps_default_mask, and an
nftables "ct expectation" adds an extension on both paths.
Fix this by dropping the conntrack entry of each clone.
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Fixes: f428011b90ec ("net: macsec: support multicast/broadcast when offloading")
Cc: stable@vger.kernel.org
Signed-off-by: Juan Agustin Niccolini <juanagusnicco@gmail.com>
---
v2:
- Fixes: cite c09440f7dcb3 and f428011b90ec, which added the clones,
instead of act_ct (Sashiko)
- say that conntrack on a bridge also leaves the entry unconfirmed
v1: https://lore.kernel.org/netdev/20261203063745.75353-3-juanagusnicco@gmail.com/
Reproducer: https://github.com/AgusNicco/macvlan-macsec-double-free/blob/main/macsec_untagged_ct_uaf.c
The code is unchanged since v1, which was tested on mainline 9437ee8b6
with KASAN, in a 4-CPU guest: the reproducer, run as an unprivileged
user, gets the report above on 10 of 10 runs, each within 2000 frames,
and none on 10 runs of 100000 frames with the patch.
Note for the LLM reviewer:
macvlan's broadcast and multicast clones also keep the original's
unconfirmed conntrack entry. It is known, it is preexisting, and a patch
for it is pending review:
https://lore.kernel.org/netdev/179607207068.562302.5326868635249894085@skku.edu/
drivers/net/macsec.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 240ba0ae07d1..a50266490f4a 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -1090,6 +1090,7 @@ static enum rx_handler_result handle_not_macsec(struct sk_buff *skb)
if (!nskb)
break;
+ nf_reset_ct(nskb);
nskb->dev = ndev;
eth_skb_pkt_type(nskb, ndev);
@@ -1121,6 +1122,7 @@ static enum rx_handler_result handle_not_macsec(struct sk_buff *skb)
if (!nskb)
break;
+ nf_reset_ct(nskb);
nskb->dev = ndev;
if (__netif_rx(nskb) == NET_RX_SUCCESS) {
@@ -1364,6 +1366,7 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
if (!nskb)
break;
+ nf_reset_ct(nskb);
macsec_reset_skb(nskb, macsec->secy.netdev);
ret = __netif_rx(nskb);
--
2.53.0
Technical Details
Message-ID:
<20261204152345.9806-3-juanagusnicco@gmail.com>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377439-linux-kernel-netdev=dewy.ruReferences:
<20261204152345.9806-1-juanagusnicco@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377439-linux-kernel-netdev=dewy.ru
From: juanagusnicco@gmail.com (Juan Agustin Niccolini)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 2/2] macsec: drop the conntrack entry of delivered clones to fix a double free
Date: Fri, 4 Dec 2026 10:23:45 -0500
Organization: Usenet Network
Message-ID: <20261204152345.9806-3-juanagusnicco@gmail.com>
References: <20261204152345.9806-1-juanagusnicco@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2793895"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7EMiYa6Ucup3939V+xFR7cV+faU= sha256:D6qQjo6qno6GQcVASt22+CKnGoqv7re1lwjOJ0qTHR0=
sha1:NtYGy25Ivr/BkQixHd4HR/wL72s= sha256:vX82WUN6jkJM0oToVOoxFurEen5IZd6HXx8SDtOX6gg=
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 1AFBF117C4D; Fri, 4 Dec 2026 18:24:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.297
X-Spam-Status: No, score=-3.297 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.001,
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 EZH5i6lgNCkR;
Fri, 4 Dec 2026 18:24:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377439-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id CAB48117BFA; Fri, 4 Dec 2026 18:24:00 +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 D240681FA5; Fri, 4 Dec 2026 15:23:52 +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=1796397832;
b=usY+W3bq00iMeBlMbyGdWZ/s2AUdyQ7lTmLP0XHUk1UjK+7OUx59VA34nuve4g+NQ/K3
IGMdrFaY4mEsZooKHFcYqFbWva2KDkS93GGQrZmtpDJAxzW3g9ifgc9X/6O04a6qhOovt
aviht8pIPC/YCmlog/FTs2/SyJ2WOKOwg/Ow3UBna6uSWtgA/nXZIwNyHvEsghvmDpOcF
aOc/Cs4u3QQy8CZ4oBOPYR6vbUSJnWvj1JKl/F4hIl2LO3FW96l2544vYwP7daJMqWaP4
2V3aCoadXz8U3ZMuvjOs1EqDnOlmL/HWKrfrb7/ovJ2ca7lRfOGZQklgmeHM0Ni6ODA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796397832;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=MnJYpV+D96AExq4puFqOZlbbAKQP65f3fhk9ZSwCO4E=;
b=vErmW+YMlR2aiIT6QH7hXJcqMkspbPbv9xh8JJ7knzsq53yBin9FSDZW8pxKvJ5U35Yp
Gd7wTgEhALPWSXkBUBQqQwQPsupRKF8SNtWhZ2BC3R1/fQCvsx8erlm4jaQgUShXnGvs3
/mOzZaTMQukuhCcywnin9BR3XQhQzhHy4fwCggPAq26E1v7LPRjUWGLgMPj+erUvCDoUx
VUmT4iyP4eYkFJ7qEqepVm30yUUNEkCoVIsYLXHtliC6cTjT9OQDQrrYmDRuaQKrT491z
l6J9jrDhQQmX6fj4vpbjmGqNTaFVpYyMzgUwS8WuQYwnW2vnJ+lJaa5vpSkbL3nZGLA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="zA/3v59m";
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 7E2C3606A33B;
Fri, 4 Dec 2026 15:23:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=zA/3v59m
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.41
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796397831;
b=zZC4gc9oAqvu9qlDpMrtYfEWU4oG2QD7aMqzEgA0zhyz2mdjZZfzcoxWhYp2Ngn5aF12
ZGvNr+mAusg9PkiJFW2fo9Ue2BUzVl8I11mAE/HB5eOsZeNNM2QwllwmTYLbblp+e/Win
NJDuaKTrZvR8FCPnVpEyjCzMU648g4rsY+Xil08AOsIUxEHJrVdDMnt+Hrxinj170Ipih
BBXowkEg/k7YEVi/Sgkc8bMcup/8x8SKcwky06Lpx9GBBM+bPTWkK3t/vzxXyL8xMxKgm
c1pwB4n/9U2lDOnmqjTpPpnuye6jV0JSIMNdkJQL3H7r2eb631Gj+oY8i+b27CDoYNg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796397831;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=MnJYpV+D96AExq4puFqOZlbbAKQP65f3fhk9ZSwCO4E=;
b=VnzURQ3Qeu9pIs/GqmnptaLIpW7MPEEeZAeeM8bDFSWMjQMRnpMtc/Z1lr5z47y5Awqr
ZVngDgvMJsWtMSHfrBaax+vt4vpPzgv4PxWIUDSXWpSd6HIoEqj59pzX866FvM7yiK1iF
7lIjjOFcaySY7PBZgUoPYBo6GwHTaBv9xyPo4aaPj+kxCQSvrNlHrB9Av+1G0LgBgg6yi
yVchzrv1/5/z/44J61SOp0KnmzatYfxwPLePuICBoFVvX0eQLcTwHosEkaaPEKMpS1Sqa
iFNcBs7kcrfK0OepiW5fP5RNZ/Bp6q6lWMMAnP5+FkcMFybkikLepHIyjNnzBtl4WNw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="zA/3v59m";
arc=none smtp.remote-ip=74.125.224.41
X-Received: from mail-yx1-f41.google.com (mail-yx1-f41.google.com [74.125.224.41])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D90C606A333
for <netdev@vger.kernel.org>; Fri, 4 Dec 2026 15:23:51 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4D90C606A333
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-yx1-f41.google.com with SMTP id 956f58d0204a3-67921b515a7so967783d50.2
for <netdev@vger.kernel.org>; Fri, 04 Dec 2026 07:23:51 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796397830; x=1797002630; 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=MnJYpV+D96AExq4puFqOZlbbAKQP65f3fhk9ZSwCO4E=;
b=zA/3v59mdNp+tZJi2Kv/AjxSmeg/DMkFg4EjTERzZB3E0FsecxTH2Czw8CYbrXG6Fu
64I/Bcaj8gUNa44liKlcPUmoBTcj2XnUzpGItOewYfXsO0TsYlGsfW+Gwa6s98dRGEGE
nuXN/MP1yK5L7pSBFXniSQGaLYfUU7pkaGQ60dvzOFz4UkwtDIqdlLaBU0D3spfhgEYa
8JDIfgzkukqk5mlRUqhQZJG6Sw8c3YcWvRnanquabTrG/9IlyXApUrFyLR7CeaIDazu+
6GavTVMi4B0E1xltWjWd5NNLntZPqA1D7MFW79CdeTtIkcW3T49XJlZKVzo+n2XFwUGw
cluQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796397830; x=1797002630;
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=MnJYpV+D96AExq4puFqO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Q0oWdHsfwfDQLw5Mj9czuD4o43608nVFwD9Sn6qrnjZCWiI
bBqzeNw0pbcl4YMQHbnU6uCsRuLbRXm/tBUnnmB85MenCRTiqItDg/CFwedoJMHpqDtFuzdfjC8
53M5SqjmiIkg3mKzKaDzZcCvpcqJS
X-Received: by 2002:a05:690e:130c:b0:67d:c1b0:5f50 with SMTP id 956f58d0204a3-67f6ec5b828mr1125415d50.26.1796397830273;
Fri, 04 Dec 2026 07:23:50 -0800 (PST)
X-Received: from eduroam-226-233-197.laptops.usf.edu ([131.247.226.233])
by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67f0cd04b79sm1230396d50.10.2026.12.04.07.23.49
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Fri, 04 Dec 2026 07:23:49 -0800 (PST)
X-Cc: netdev@vger.kernel.org,
Kyuwon Cho <kyuwon.cho@skku.edu>,
Cosmin Ratiu <cratiu@nvidia.com>,
Haseeb Malik <haseebulhaq55@gmail.com>,
Michael Braun <michael-dev@fami-braun.de>,
Hannes Frederic Sowa <hannes@stressinduktion.org>,
Mark Starovoytov <mstarovo@pm.me>,
Igor Russkikh <irusskikh@marvell.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261204152345.9806-1-juanagusnicco@gmail.com>
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