From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796279877; b=RnHjkrqLE/NTzA8wbfQJfccoTEQeedtyQqAaUvEh23HP2oKxrm7MkAbGlWMD0dtazxi8 wrPKZduI8kqrZyIThvq81ZbJtJj/vOGkDsiAOYeNn8Vk4dMW8Z4tCF1+PLcPdtDh13oBy Vdrcdexd+ZnXW5SbGrOiDwNBeR/gLm+720ZjDzXTqcoraL4lxllLx0bRgdHIMJLsp2Kpe 2WoxwlFzPDOzRiEQ+hf3WsbAOWXwp0NMJtzV21t8dBf9nKfLUEY+pTRpC9T3oubIMIYSU kwHw2l4kr5ny/d2D3TdWEUbdvcZiZ0Nh2ELwMQOVK06BhKH18oqrast/pRbUfmAMqsQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796279877; 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=O7tpyyYp7FcE4lh4mLJIvdvrrgNeEax1EE1nsYbvaXI=; b=bJ2GFwy0GVSYhRzR5BF57bHXbdi9u558k9x6HyCCTsXnv3p5DwAHtsXLly+Ek0hN4O+I nOjzsnACNoF6UxODFOqNK+Auw2OMKx0c48jrqygeTKFnYfO2+0Ws+julkP+swyuhoLcLb FqqraQwQzw/qM/EI8DzgoDlATC+xvDgsW1/COEQDwL0M2d9oW31BVZ+f00rjmi4qULpTH Kwm/HYt5nwHu7t1Ae8KWzvSIoY9YBbQNr2hZgWUrEB5JsvyAWaY8q49B0/kCLhAADX2tT s7Oa2b4cfsXhoUq5USWUUBBT4sPkUrEC5/hYtMR4ejfX9JbAT2FqBA9i460im78mt9A== 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=TmRW0Qf0; arc=none smtp.remote-ip=74.125.224.53 Received: from mail-yx1-f53.google.com (mail-yx1-f53.google.com [74.125.224.53]) (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 B0503606A322 for ; Thu, 3 Dec 2026 06:37:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B0503606A322 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=TmRW0Qf0 Received: by mail-yx1-f53.google.com with SMTP id 956f58d0204a3-67be4f2f4d4so16365431d50.2 for ; Wed, 02 Dec 2026 22:37:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796279876; x=1796884676; 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=O7tpyyYp7FcE4lh4mLJIvdvrrgNeEax1EE1nsYbvaXI=; b=TmRW0Qf0fj6akFHJSPJrEGSQ4f3jOfXsoT73PmTb/p8TA7NrdtNyRJPX3FTeBVcU8U DT9cgR00L5m/zhuUqJpqhWcaaRX6zM1o55qjF6YUp0l7mfEOo6F2cj2WjGg0bxam0RdD P4PrM8xrlE+d7EQBCgE8I2q4bmk/t6FgydLHgBy54haLww+N9i7WBsrOGisCzY1KPFKl Wu4/i6+gP3qfKvW0vkMnuJI4uvcODB+KjfOVarM6UL50OvmRDI075HcnP9VWxfoEWRtj /MXiqoEGVBQe03E4z8nKC+Vbae5HIAkWMgzRIr7ceVlbZLkyysGnUJ0p+GCEPEVlX3lm SEAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796279876; x=1796884676; 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=O7tpyyYp7FcE4lh4mLJIvdvrrgNeEax1EE1nsYbvaXI=; b=H57PvfNdHrOiCV2TCfgzfHYfwoHFUfSiIe+31nfDf6wL/ZukWmQXDySYD0IfeXEoHI NgaLN4FM7VHBREjjbF9suyCR+pyQCwapauofNtCtRzxp9w/l85sMDy6EeN+leph3+1uZ XcllcFx8fRmg4JAgsnC9+hie3bYCI7d2ALzkpLXHLqLDiJ0Tb3gPdMlXMPKIwcwbB98A ZxXJR5EEuKVIIWiaeb4lwpiPj5Zpm0jp4mO2+S6tdCLMqi2/GKgSDIyKOr7H7xV4Vu4l Atr7b+lxIv9XJwU90MNvB2FW/6eQDW7H6+2GvO9LeWBCSqdAfoZj56Dkw5uigzPPxcpj 4tQA== X-Gm-Message-State: APuU4Z/1ksxHw+bmgi0YuCFh0lfHaKyWuozBtexFt3v2JLh6hlYLdawJ APxJe+mthhSi0hdbNxj3o9opuzb376SFzDawohg6NDajPqHingITPdlC X-Gm-Gg: AZFdTZdI2MS3LXWZuMqkO6vmXd7ccfA3aYa8jjQK7Yozuosd2TRW1DZ2FFyfMCaWm+m 31fgMWJNeKImqe26CC+PzXvAMlHTNeQwWalRrD4IWPWDacq+jMYvpb9xlo6RP1jEdBWnIyN9p3O jz7ZbAeUmAT7Zi+lBvAc8lqjCLuH4azZFZ6koBcIRijTW4EH5ep5S5SL3YvxpMUUlueBEsHpKpT dmJYNUP6UcV0EywcEtMvU5FhgAK6x1zz/rwpk7cfaFLSNRHB1Vx48+HxfGsImRmZWCmMTVaG9tH 7xFFlts6HP8gAxfUKUG33zmPUkTceEJpC4T7xBO8WMdizEo195OtWMjc05Q0IFLSASXfe6HL4ZR uO4D9+en79IDleITZdH7ZFulV8oEC3H3a3X8efXaZCv89hfdD6e3PXIRi8ECTRrtf/+47gA9ENm W2TQdTCOsZI/f0f1YwXsllnqu8eKcGFcypUhS9f8OVkdU0g3BqRHGEzmifqz4FrqRQx/yGcI/ih +KGQ9vfXealluTAo0KxUpDarme2e/VTzUFAekblwCZBzZUlnkAJS7gYN6u9wPuFkjN88RPMzsq9 AOdvbTcGtZAVIMaJ7WXfHnwk11IvANmuP0qmO2dpDSbXmKhAQuWQ0UsaNqNpZ0rlf/ajUVo4aNA = X-Received: by 2002:a05:690e:4145:b0:67e:d163:c840 with SMTP id 956f58d0204a3-67ed163c9dcmr198044d50.84.1796279875794; Wed, 02 Dec 2026 22:37:55 -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.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Dec 2026 22:37:54 -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 1/2] macvlan: drop the conntrack entry of source-mode clones to fix a double free Date: Thu, 3 Dec 2026 01:37:44 -0500 Message-ID: <20261203063745.75353-2-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 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. 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 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: 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/macvlan_source_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 6000 frames, and none on 10 runs of 100000 frames with this patch. The source-mode device still receives every clone, which now gets its own conntrack entry in prerouting. drivers/net/macvlan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 4f8416bb5..7fb584621 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.43.0