From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795597956; b=XxKHOadE+nShePvZjn4xI9Fpel15xC6JCg2zxXamvz82IxWCQU0aB8Cks2VL0noyYOM5 fidcJOqJfqoMnkyyC7PtVMKWsZiVV1bvxJbpiIszVaVMDxZ+M+KJvU4VK+XSILdjTPePe rk1A6tjsJgRl57GTML6PQAQmt84AtcZGqN4cePjUndyTBcZ3M8dE6fJRzNSM/iT/X4haT 2Jo5aFgW36S2w1YxKpBgR9Uwn+i1iaT3c1K2Pk8VTASRzVIZnXvbrPBMb4iXPDXm2JTd6 a8hdkzUJT/LjEgsZ4YBy83jZgfUI1X3ELKGFAUi7v1inSwbOD5DpN+AcAo/8bhm4ZEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795597956; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Kunwj7pLBE8DUbL6yNOilvl3uYAbnG7PAKvCpDEKa4M=; b=QZHWs9Vpr91eQ5vFwgmb5OpNZaQ62Pxl7OrdqN3eKIE+HAL6wHkZG53xbhnjX9vchObD CySuiC8Z8p2GbRxansw9+WWcyUG2t09hoyUl5/93XV805uSXw91yizuIZ+92cie44o6QF oNodT9XlEGt3ietlqKDosJMxyJB0qUJCDMMAtA7B+VIJ4zqswKx5CzyC9uqEfhtOQPFAJ mBF6RUDfOMOfzpXsZnCiiNVAYzfari8nBwYSra4ekW4DHoqhH8FoOHuLatPgg3kqbr/pu vM4G27NZISlieYUuSQ99BfpZIG7G4xH6ezCsCSlaZEmnajcm/JrCnh9ADlQKAq6X9Bw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JWNBpeC8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A09F660A3834 for ; Wed, 25 Nov 2026 09:12:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JWNBpeC8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A6F31F000D0; Wed, 25 Nov 2026 09:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795597956; bh=Kunwj7pLBE8DUbL6yNOilvl3uYAbnG7PAKvCpDEKa4M=; h=Subject:To:Cc:From:Date; b=JWNBpeC8vV4bsCeTSrGff2Et2RYO4vWycMXgn0ZAe2wYAru3qIRZlkL9rViOOcKCt LOTtpo9Yoq/n/rIT17vsofzVYeCRrwnR2UhaYotEwuRZyfaNE2afIvMAWoB2Je+6zK 8S6PHPw4/A8CGbW98ib+uzAis8I4jHiRd/Q2q0dM= Subject: FAILED: patch "[PATCH] netfilter: nf_dup: preserve guard across NFQUEUE reinjection" failed to apply to 6.1-stable tree To: zihanx@nebusec.ai,pablo@netfilter.org,root@tr0jan.top,vega@nebusec.ai Cc: From: Date: Wed, 25 Nov 2026 10:01:52 +0100 Message-ID: <2026112552-outrage-proton-1df4@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x 82052e5b5ec36504fe1b9c3c28a711a78fcacf37 # git commit -s git send-email --to '' --in-reply-to '2026112552-outrage-proton-1df4@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 82052e5b5ec36504fe1b9c3c28a711a78fcacf37 Mon Sep 17 00:00:00 2001 From: Zihan Xi Date: Fri, 16 Oct 2026 16:14:17 +0000 Subject: [PATCH] netfilter: nf_dup: preserve guard across NFQUEUE reinjection NFQUEUE can suspend traversal of a duplicated packet while the task-local duplication guard is set. The output call then returns and clears the guard before a later verdict resumes hook traversal. Save the guard in the queue entry and restore it while reinjection continues hook traversal. Preserve and restore the verdict task's prior state, including nested synchronous reinjection. Fixes: cd58bcd9787e ("netfilter: xt_TEE: have cloned packet travel through Xtables too") Cc: stable@vger.kernel.org Reported-by: Vega Assisted-by: LLM Co-developed-by: Luxing Yin Signed-off-by: Luxing Yin Signed-off-by: Zihan Xi Signed-off-by: Pablo Neira Ayuso diff --git a/include/net/netfilter/nf_queue.h b/include/net/netfilter/nf_queue.h index 86021c55ba3c..4a8cefd8398d 100644 --- a/include/net/netfilter/nf_queue.h +++ b/include/net/netfilter/nf_queue.h @@ -23,6 +23,7 @@ struct nf_queue_entry { struct net_device *physout; #endif struct nf_hook_state state; + bool in_nf_duplicate; bool nf_ct_is_unconfirmed; u16 size; /* sizeof(entry) + saved route keys */ diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c index 166d05e994ac..bd603e3a99a5 100644 --- a/net/netfilter/nf_queue.c +++ b/net/netfilter/nf_queue.c @@ -219,6 +219,7 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, *entry = (struct nf_queue_entry) { .skb = skb, .skb_dev = skb->dev, + .in_nf_duplicate = current->in_nf_duplicate, .state = *state, .hook_index = index, .size = sizeof(*entry) + route_key_size, diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index 90d887546f7d..a8aa7ad832c3 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -365,21 +366,30 @@ static void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict) const struct nf_hook_entry *hook_entry; const struct nf_hook_entries *hooks; struct sk_buff *skb = entry->skb; + bool old_in_nf_duplicate; const struct net *net; unsigned int i; int err; u8 pf; + DEBUG_NET_WARN_ONCE(current->in_nf_duplicate && + !entry->in_nf_duplicate, + "%s called with unexpected duplication guard", + __func__); + local_bh_disable(); + old_in_nf_duplicate = current->in_nf_duplicate; + net = entry->state.net; pf = entry->state.pf; + current->in_nf_duplicate = entry->in_nf_duplicate; hooks = nf_hook_entries_head(net, pf, entry->state.hook); i = entry->hook_index; if (!hooks || i >= hooks->num_hook_entries) { kfree_skb_reason(skb, SKB_DROP_REASON_NETFILTER_DROP); nf_queue_entry_free(entry); - return; + goto out; } hook_entry = &hooks->hooks[i]; @@ -402,9 +412,7 @@ static void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict) switch (verdict & NF_VERDICT_MASK) { case NF_ACCEPT: case NF_STOP: - local_bh_disable(); entry->state.okfn(entry->state.net, entry->state.sk, skb); - local_bh_enable(); break; case NF_QUEUE: err = nf_queue(skb, &entry->state, i, verdict); @@ -418,6 +426,9 @@ static void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict) } nf_queue_entry_free(entry); +out: + current->in_nf_duplicate = old_in_nf_duplicate; + local_bh_enable(); } /* return true if the entry has an unconfirmed conntrack attached that isn't owned by us