🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27001

[PATCH net v2 1/2] macvlan: drop the conntrack entry of source-mode clones to fix a double free

#27001
From: Juan Agustin Niccolini
Date: Fri, 04 Dec 2026 15:23
63 lines
13620 bytes
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 <juanagusnicco@gmail.com>
---
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
Technical Details
Message-ID: <20261204152345.9806-2-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-377438-linux-kernel-netdev=dewy.ru
References: <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-377438-linux-kernel-netdev=dewy.ru
From: juanagusnicco@gmail.com (Juan Agustin Niccolini)
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <20261204152345.9806-2-juanagusnicco@gmail.com>
References: <20261204152345.9806-1-juanagusnicco@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2793800"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+Z/JUI7sKIpcYfsxDNS5j3QSf+0= sha256:/itBnirDfMhQ/+xrtnKL2E7lNBdpJYX9Ymy4ov2U+tY=
	sha1:LBLvVlxb7TUEu5KnSiAo+V1TU0o= sha256:OW0qEzBtYn/t+kn+YP49YtokwRQuTbCSGINNDcIzvSs=
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 A6631117C4D; Fri,  4 Dec 2026 18:24:07 +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 e-dZ21uss3oU;
	Fri,  4 Dec 2026 18:24:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377438-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 83AF1117C4A; Fri,  4 Dec 2026 18:23:55 +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 8999382083; Fri,  4 Dec 2026 15:23:51 +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=1796397831;
	b=KHiy+Kj81ItUnD8xYEZU2nMqeQoOSiiVgJJsVGHMWa9ZpKgfN85c+fPy4XW2WpavYrV6
	 M6U3yfL5aw/d2NmPPGq5DND7XJEPniGgv300etQy3lSaz81UvXrUKtuvkeh299XMwviW6
	 93C7TAs5Eu1rirxXIur7NGCxACQ6M04oMQMe4C/mNnYo0+kVd1b1LKDRl4gLDdE8SdlmJ
	 qp5oTpRvQeQ5OMWm1svXDK0iNrBuST63wVNfs4po0p4HPQ2eOCgcgALBRIVRFuVEBBR6J
	 IVimLVFj0aGdV1IoQ8kGvHNUhs7eqiCwt11UoCI5s08Rju33/KKzhiupgDmuq1B4qNA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796397831;
	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=Cyncqzo/BnG8rlopGUDdyYW3pa/r5geolHoajGOlWIQ=;
	b=Yw36nG7Pih2/ErIltzEzGg69YJPnWYfovKQiTlqd4ed6gsKOqGGHDAPJ2nCMEhlH7f/z
	 90hNRhvIFCN0nrCKZoMUahOj0WmuiMVHDaL/S5jAi7DeAym7/OxIbx3YFwiLr8Xnef17d
	 cv10SEJ7CAZ+ow2XLwpgo4G6OnmGapU0vLycaxfiJBfUFtzpI7Jx1Km8uwOQO9xeTcSql
	 LiftK1NvyN/Yym7O9iCRZL6+98WqVx9siEW7iRQmJePyZFNQMNQXlW0Xe853oPbg6BvSp
	 ncm16G0qT97WFHZj1VVToV2DUYX7shXEb+VEwDGFHotufLzRDZf6YSfJ10e4+Nh2yVA==
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=ixifO82F;
	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 60E33606A335;
	Fri,  4 Dec 2026 15:23:51 +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=ixifO82F
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.48
X-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==
X-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==
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=ixifO82F;
	arc=none smtp.remote-ip=74.125.224.48
X-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 <netdev@vger.kernel.org>; Fri,  4 Dec 2026 15:23:49 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 30BE0606A334
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-f48.google.com with SMTP id 956f58d0204a3-67db3a48dc6so1028653d50.3
        for <netdev@vger.kernel.org>; Fri, 04 Dec 2026 07:23:49 -0800 (PST)
X-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)
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.47
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Fri, 04 Dec 2026 07:23:48 -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