From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796397830; b=PGNXYe6+rVw3non3lnWCiEDB4o9ke5ygYsSq1vMl0MFJgZPx2MSwd519i6chzTrsK9cq WZpI/SCDzm8/D6aheNhVQykb2rZrIO3+ra1ehSpv9hOkbjV8yrwS7juCWrVGVznuCVDVt 6Iaeo11hylDref/MaN8sIRKnuTVOh0NEXTmHLMOLwiy6eqvjb/XIQGV9Eqc/t74LBgVI7 vtS28ZqUtaf7Jbtk+jHUvwQGgxPvg+rH4tJS8snpPXFraSfbIfvZuL6hx4GCb281OasXi 5hE5/Ndf4M3a5/P3VQ2Wirb+wPfWKR8rT0mFlSCEO5XYi2Aei9RZ8GHmQpKTYV/nGBg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796397830; 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=Cyncqzo/BnG8rlopGUDdyYW3pa/r5geolHoajGOlWIQ=; b=zsNpPsv/dOGc06J1ym/2me6rXt2w3IiC4CHKGEqqQOl9GD1+fsmyvVcqDceqBJMH398/ ThAvfUqBXOzrzhHSNniHK7QjDeerdRK+y5h8BLO0sDt4JzpAKM2wlH4J+PwhvRRtUldH3 F3SbeauIdi3VSxclQ/LfbYZmvEksyLimQ/9lwnIIsiJqKo8x0PmZQHRZJMjGm4HCaKV0a IiFuqXJZAZ++Ch+NZRbGtyiZKoSpxXcjZHKaSgLwgWbI/AgnRC/KvEKenZKEYoQPD3h9T bjxRRAFXMCiLuAjUdkmk0miI0Y7gJMc0canj3OStRaljO5AgahTgVYgtXlZF8yGrKJw== 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=ixifO82F; arc=none smtp.remote-ip=74.125.224.48 Received: from mail-yx1-f48.google.com (mail-yx1-f48.google.com [74.125.224.48]) (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 30BE0606A334 for ; Fri, 4 Dec 2026 15:23:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 30BE0606A334 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=ixifO82F Received: by mail-yx1-f48.google.com with SMTP id 956f58d0204a3-67db3a48dc6so1028653d50.3 for ; Fri, 04 Dec 2026 07:23:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796397829; x=1797002629; 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=Cyncqzo/BnG8rlopGUDdyYW3pa/r5geolHoajGOlWIQ=; b=ixifO82FH3xXjN6cTGJQx4CzWo+xhr1HLzAhgwaqkhPl72glhf29CFnh7QgNDWE+zO WCJTh03qCygg4o6DKIUNj+kKmeNfVQYrzLcEQvWcJ5sbIidqN3oRPH6Hafvv0+bDUVzs vxgxD4BJNNKpovVhVE6JCa6qVWlxFzIFkF3ogwKywSfdxgoswQbodGxYPVYE+C5GeMht PK1iZedJBMOKA+9xwZvcErAzSek3aJ+kCcTJuhUtorCRY9EpOTXsiDScu/lBaER8zH+5 oowWM5OA1wVEuFWQpaOTDUgC3Ar6LBooCfvhQR75cqnp/5UNm0aGQPIEtjUmYdcX6W+C RAkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796397829; x=1797002629; 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=Cyncqzo/BnG8rlopGUDdyYW3pa/r5geolHoajGOlWIQ=; b=VoCu+lmOrghA3tHiDubsR6uWoRUKKyb0h5EW+SRMJNJ7UGo16qKMFjt4k7bJ+9b0PA ZqDGEzO9nclX4B60STMk7ffC+s6vP0j3h/ezW2/asbLbZLFtvOWfOyWW5GgjnswrvyJc tiT4DDvgfMS3mv2orPUr+8V18+AgZgchDvJ/YsuP23WE3sTnU/yQCfQtUpShHfDYVc52 XVNzI0gHc7EQEo+s1hB/ZpY2xgSOJHvUAwA0nj1xAAWpmOOj40HnNKuwapXGzRuGdzzY hXgHxYjCCICBt3xNK82JhzSSTTTvq5K5pC3y5CnzWL4/0QZiq6fKl21YHVr+JBbCoGaG zTMA== X-Gm-Message-State: AB4q+uFVZbBnWxP956oVN+HhkiQ/k83V325ejG4MK0lE/r1qyccPUT6K ha0jMMMw1wSuB/a+k3Np6nn9Q42k/poCV7+nzshuRtIXS9Cne6LK6blK X-Gm-Gg: AZFdTZdd0qxI2pjrOWyCJE2abdIaTTIAZSeJQUgmciM7YBnzN0nIxEEuSi48sk2kHuP lBCLtWdqIXnoKq4nBLRwtChR6h84mcL99nko27mu06wiWKGBevCVyXoo05E35SFERxLs4pUql93 yUDdwINwhs0wuqC5dv4JVIOqtPC5K6uWGHQ9TISOa91JZJyLrc0uidIr8StA97ZHuj2F5QVMVh3 Fs1jkYPSCYDorEmRjawlafH7/erVG/QF/TFLiy43cDOXbfnzCiB5jjCByop4ScMq7l+Ch9TDf7Q Rz/H6if1WuFqDlb+v5iHo14YWA9GDP1j+WVE1qwb8WIby4iolbNmT8pEB48EJzeYGW604N+WSZM NqEZxrp3kVGukf6TCXrqzTCB+cESRJhHW77YSIScI1yEEYn8m6Anh076J8QFBFmsfmI8ie8LEyG 36d9LWsogPL/epwrewlIHW/uN3l9p2YQVmKauI0dZLVkU6Pffe5IBTWiVOiYV8RsgoeSeZ1sJTP nfCw6iuk9dW6/E6iL310huAkYDBpZgh2osH6Unr7BAYdCnSncSFzHOutLfuWbsTHWqeUka0B34N yPPFKOllQBC0ofx9G8j1iwfKDFscSSq23lXByI0NF/vMGgh6Ttmqg6VArX19YK8pqPDDLfygijs zPfWi0beUqvvtIltaTFsF1g2lvcw2lg== X-Received: by 2002:a05:690e:138a:b0:679:ab08:5278 with SMTP id 956f58d0204a3-67f6ec5e5d4mr942223d50.32.1796397828968; Fri, 04 Dec 2026 07:23:48 -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.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Dec 2026 07:23:48 -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 1/2] macvlan: drop the conntrack entry of source-mode clones to fix a double free Date: Fri, 4 Dec 2026 10:23:44 -0500 Message-ID: <20261204152345.9806-2-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 macvlan_forward_source_one() hands a clone of each frame from a listed source address to a source-mode macvlan device, while the original goes on up the lower device. 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 ff11000010c04200 by task macvlan_source_/215 An unprivileged user can trigger this from a user and network namespace: 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 clone's conntrack entry, as __dev_forward_skb() does when macvlan forwards a frame between its own devices. Fixes: 79cf79abce71 ("macvlan: add source mode") Cc: stable@vger.kernel.org Signed-off-by: Juan Agustin Niccolini --- v2: - Fixes: cite 79cf79abce71, which added the clone, instead of act_ct (Sashiko) - say that conntrack on a bridge also leaves the entry unconfirmed v1: https://lore.kernel.org/netdev/20261203063745.75353-2-juanagusnicco@gmail.com/ Reproducer: https://github.com/AgusNicco/macvlan-macsec-double-free/blob/main/macvlan_source_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 6000 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/macvlan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 4f8416bb5169..7fb584621fa0 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -422,6 +422,7 @@ static void macvlan_forward_source_one(struct sk_buff *skb, return; len = nskb->len + ETH_HLEN; + nf_reset_ct(nskb); nskb->dev = dev; if (ether_addr_equal_64bits(eth_hdr(skb)->h_dest, dev->dev_addr)) -- 2.53.0