From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796279881; b=2j2RFBP2LVYVtcGxgjDEXNohPo/XssWTVo9nNCDYEVt5371x5GkEw0dScIxlPnxAQ02L bIgDRsySGu0yezCfT5Wybb9BdbIdLw58GRqP9HGf16Dek5IR2YP/R1d+OPjlNIUlC7U67 W1RHOgGrA6XHOiYE5XL6lKBdXJLanMtKynQWEqqgqVyDd6CImLdTBwT61QjL2JC9vwoIK aYSI23PMyLFuJ8D0MSr1rkUKJnyB6lHinOF3yG/rPvBUSsH4quwg5Qtg0rZwzTBfFxQNk IekPW8SFknIS26R0TEIxkkG+6k0Ap0QTbFhnKWkFvvUw8vzZgqIyvypRHytisEYFGbw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796279881; 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=KSKQGVb9w0ZXyIqwItkYuvLd1UGZVr6Xg41nuqvjE6U=; b=2O6e/WYuVKstMHEf45RUPmIfHOHyvWF2XIwWMIYrS4ecRp6B3YLW2PTiCRlnGFy70LYZ Jf3Y67sNVHo1ScLfgP1DXk9puWBkEo36q5W7wql1uvDWJhDHIOPj56GloXkdr/Ko5amYL O4mACoG4f3nAY7nLQnvmGP0H6u4vy8Pn3kKp10w/JZeJ9olbPDj3M49in6AWOIOWublwW PHnJSX1lwoDpD9ClXj4XFqDPc78F4wbo2HHVUTcaQf6WzOyEpmdUow+X/SBqTy0CM8sW9 sxgbzOGC34xUX04TJVZ2ZRPPg3qvg3i0utvCpu0CUwHBMagNOypHi49ejGnp8JOoC4A== 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=zW5gdq1y; arc=none smtp.remote-ip=74.125.224.52 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (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 511CA606A322 for ; Thu, 3 Dec 2026 06:38:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 511CA606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=zW5gdq1y Received: by mail-yx1-f52.google.com with SMTP id 956f58d0204a3-67da3d03263so14204925d50.1 for ; Wed, 02 Dec 2026 22:38:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796279880; x=1796884680; 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=KSKQGVb9w0ZXyIqwItkYuvLd1UGZVr6Xg41nuqvjE6U=; b=zW5gdq1y9/TLYa8XJwhU2wJ1tj4yYrgGUGowfSW9z490E/zezTtvIui0AJpvk1T6Oi wS31vq7S3Jb4E8D33KjtUzJmj5G/I5KhRptEKFnhCighH9XZ85doLRatMlru3DXS5LTV n2Ke9HWH0s690k6kVFm6LIbsd7SEdgltpGGxac9fkFvJbh6Hm8T5GEPg16xux9rdywnE zrPJj0WWRYLDDjxzCIipFPFC/pfQGPq5qfSmsiKm6eQZt+mGLJkzIwSh1w1Jj9xI6m3u gTRznoEnfXSjFoeTpCq6wbMkwScjIXyNnxypmFB/JW7mU/8gcQclXFSkzG57MO+h3jQ1 7WCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796279880; x=1796884680; 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=KSKQGVb9w0ZXyIqwItkYuvLd1UGZVr6Xg41nuqvjE6U=; b=P1uAC1LPlKXQ9kbYWncUFOawq/DYOKJFdEFGi5UtNS3FWNK+lycs+rS2bcGK80Z+Iy Jro0orZN5o84dOIypmvdVDUPtYkGp+Mqnj9X6NsQOEkYNZxEsGM8U8yUU0DuhmRnin0W citHWWvi+XDyFFM2qfUTBx7c/JT5i4GdAmGRKI1ZOTbEeOXPBmFS4CHPJCwGjhy/JM3j HteT19iFyhBmfwOUCknm4WezGX5p4ragOT0kPVUXnZM/Y+l6bzFEGDbAA6X9YdidSVTL l1xNXvUpWSCqE64iUE3vCHsOJqQ6ikxaMNgiMjEM+W8IiR66ANqR7gXfINbAxJGxkjAK oy1A== X-Gm-Message-State: APuU4Z+zYsX5ac+nr2QQ/h7C0ZuZU/lVX4wPra5OFl5W5ICB1IAzEq9e xpLqxgc9B1zI+1lrdJwriCS5CvfvHzcjznj9IXLfq5VgQLlpfCxl/0Ds X-Gm-Gg: AZFdTZfDjebqHgA2MPJxPeKupXOU9iyUCN325/Hp6LjKdqkKezE6hZffFDHavdwaWv3 TcIzkXr2cPd1vt71ngS3gpIYyg5TBsDpT73SNOeB0iceWdNqx0cNZLUZYtuoFldMI4FcMf7P/6l MAm9rqjOlmarPqIupxGrYtS+zYAuf2kvaGCMVRFv3bj/CazmEfolFsyI77l0it9qGD/duS+wmRi szRBooLBEPFX6aTRfJXRw+UxbMgvA7Crj4uBhRu9IZCBJgde1Q71GkW5NUz5zL1b5pq0XC7MWbi SbkW0GwmmZfeGDe+0dxl8MZxuVU9G1EbOQseE88GKWLtb27G4F//OS2qlxT6Az9EjcEERi22Y/d 3ZrU3DRYZWDzPH5nKheIHpwn1o7/Nn2NSrhZwzAVcQpM5AMOIPRzKoED3m5iw/QHMoARVMQNiJ3 5VUgy1h/0qibtDkQZjEUMEMNgg6wAgHiOkeU2dXZdnCxc3C8fsZ73XTKonciGBMwzc54jnnCKfp OtZdsRADV7d8rksxNbfllghbV10+zQbVAcI6ItJxEyuwwpAWYDPrv8lYEkBla/0DTxz/N63aprk CoFdEbJBRiT4eYowrSCuDRmVjFeuFjwAZMhmGYhBQeuERGXJoXjE/7M= X-Received: by 2002:a05:690e:bcb:b0:67c:c1d:e5f9 with SMTP id 956f58d0204a3-67df40c17abmr16534483d50.0.1796279879437; Wed, 02 Dec 2026 22:37:59 -0800 (PST) Received: from VPN-158-165.vpn.usf.edu ([2607:fe50:0:f802::4046]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67eb40514besm2492793d50.22.2026.12.02.22.37.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Dec 2026 22:37:58 -0800 (PST) From: Juan Agustin Niccolini To: Sabrina Dubroca , Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Kyuwon Cho , Cosmin Ratiu , Haseeb Malik , Paul Blakey , Marcelo Ricardo Leitner , Yossi Kuperman , Jiri Pirko Subject: [PATCH net 2/2] macsec: drop the conntrack entry of delivered clones to fix a double free Date: Thu, 3 Dec 2026 01:37:45 -0500 Message-ID: <20261203063745.75353-3-juanagusnicco@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261203063745.75353-1-juanagusnicco@gmail.com> References: <20261203063745.75353-1-juanagusnicco@gmail.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. If tc act_ct attached that entry at the lower device's ingress, it is still unconfirmed, and 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: b57dc7c13ea9 ("net/sched: Introduce action ct") Cc: stable@vger.kernel.org Signed-off-by: Juan Agustin Niccolini --- Reproducer: https://github.com/AgusNicco/macvlan-macsec-double-free/blob/main/macsec_untagged_ct_uaf.c 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 this patch. The macsec device still receives every clone, which now gets its own conntrack entry in prerouting. The reproducer sends frames without a SecTAG; the unknown-SCI and offload clones get the same one-line change but were not run. drivers/net/macsec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 240ba0ae0..a50266490 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.43.0