From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.41 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== 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== 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 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 ; Fri, 4 Dec 2026 15:23:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4D90C606A333 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=zA/3v59m Received: by mail-yx1-f41.google.com with SMTP id 956f58d0204a3-67921b515a7so967783d50.2 for ; Fri, 04 Dec 2026 07:23:51 -0800 (PST) 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+D96AExq4puFqOZlbbAKQP65f3fhk9ZSwCO4E=; b=rdcX+5ghbRSdqOqNIOZmP+3Gq7PwiuhQwiGW+9KeQMRR7BgmKT+Mc0lHsG/LnvqbE+ asJcuAwkRn+G2A1R4XdTtlu2e9dn1QeXEaPnyJARWigNhUvDu+zilz1qBDsfaiXEzRFz sttjyu/03SkxmQbESgTl8gIm1sdcYL2oftELIMoHvZjTKVtK0KrhVRa6IZhLdBmH1rlA ETnnq/1oaH6Fv7fdY5UupT+NoEu6iH2wezyhb72BCCXd6evfawmDXZ0h6lM7ZJr0MDBg cSGN7NwjtK5xc9SeaMkZKvPDL9zDljOFlzTHxOJ/rAByqHCN2D8YAJYGSgSy1Br1yYPU lnDg== X-Gm-Message-State: AB4q+uEwTbPVE9bT9GSdl6UxM6boIIdRxVqJ7T83+9rIqY3Qcw2MCVlQ JMlm5ar+/e558cAX/cxccCuw5Zxkea77Ya64Yg6xqJaTLAyxfcU2QJEY X-Gm-Gg: AZFdTZdY2626YEcINdXc7PvT+bzq/e9Q9eCkP+NrCQu0A2/gFq+PEoa9+w2KN/F4vzC NMAf8YAiVqkUgWZO0/3xurGDzg3maGUkTFokigfo3z0Gjbflr8DGmRTjw0d09jY3UEf/7opxNEK t/G9xP8vjAfaTvvK3Xb2YlR9JZtDKl2e6B65H3zIxHU+Wu55HGo2kMkyyXYDSbAbR6J3/ZAYs1y 924jNCbDdv071v/iF+JC3iHlBKVr4gOQhvMxL3B4AvR5XW8x2deWjc8bh4eUo1unYTrkSPnk3eW 8oJJYAMn0HaIkyMQQ6wgRLI33u0acW3dNpDSSAaOvuiOqrRghSG9gNUSUIRGtT31O2y2ofO8zFm dm4OMj/fvRHQWNpAitCVTsCgPc/2L2UAekjzXVYviSEhNMtzdsCXBZdY39ENZYIzy2TYZRVWKf3 wDsUKLCIcDplb96A3PrqCxOvk5snKdr3b4zJcV52zR87djxwzBORDhCCq3Ew67Uy/lUt1aug2lH lPOycHSII7Qbg5DBgxp7UKz+XmtYQ0oWdHsfwfDQLw5Mj9czuD4o43608nVFwD9Sn6qrnjZCWiI 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) 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) 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 , Michael Braun , Hannes Frederic Sowa , Mark Starovoytov , Igor Russkikh 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 Message-ID: <20261204152345.9806-3-juanagusnicco@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204152345.9806-1-juanagusnicco@gmail.com> References: <20261204152345.9806-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. 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 --- 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