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=1795597959; b=Tne8DpynTD60lVWbszCxPI+G/YjLbu90KBrdlISQDVkywIegl3mFt0EzsW8Y6NkUWS+C Nwpe8+9J+0YNub+MhjPtxPnIzXUb1vwSnCQG3K5CTY6U1W1gJzq8XW3q0G8ILrZaEv148 6+d+VOD5hW+KDm0osCZaJim6uf/iQ3cOnIaVrylW8+cY1vIFcLnnNTAm+hEZzyQwssUPU rkquNfGKFKoJ3DlpjgqD73To8lJzMsF042A9rf9Cj1i1HH6cEunb8DlUOs0B58Phi90mI yBW265RrhKH2i6b0R5Fg4neFfxNj/jDvk/RGNSVxGFIF5OmGsqn7iPh6E9ZIT6C3FIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795597959; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=uDJ5Y9wT/b2fHizyJr1QjmDm0Fgl3E28THdW0JF8D/I=; b=NVS2NQuguTYXNJbCU47WfF1wRqZcK0H4uNVXD8j9MXNFe1+CwLNg38UCx6EGRKIElORP gN/TgIv9NW+yTODeMk6eqSELK69SAE/3JhW0Z/aXZR8JNfXb/LZ7z1yzPnnI8g+/ASeK0 tlhQRPF676vnoFnAB2H5e0Wk7O2geen9Q3Q0qFhtvC4AahCwXLoujadwc+B83yyxcmD8A vScgaVhtihKUr8xleZklPSL8u1QZmxAjUU1BYMboB0KIGL5D/DqNmjnwlGzYbGyUWITLb Me+WJYlbo1x85boYW34gEyn9RelgXIBkjHZbPxW71ht+P0U8G8FI0qOQ3mJTznJHObw== 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=P+lypgJX; 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 BEF3760A2636 for ; Wed, 25 Nov 2026 09:12:39 +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=P+lypgJX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09F361F000D1; Wed, 25 Nov 2026 09:12:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795597959; bh=uDJ5Y9wT/b2fHizyJr1QjmDm0Fgl3E28THdW0JF8D/I=; h=Subject:To:Cc:From:Date; b=P+lypgJX6MkqP6bcPy3MlfS7zKVOe6sSSLh73bwdMh92PGJVSdDcsb5cgqJacOlp1 hxlUL2Dj9opURrcig4EGhubTRE2BCLemhEBPkmbZvU8zQeqwSawy0utZQAAdg6cgM6 hgdg94uQmrDASnE1vmux8V/HsCOb1Z0mehpnclZE= Subject: FAILED: patch "[PATCH] netfilter: nf_dup: preserve guard across NFQUEUE reinjection" failed to apply to 5.15-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-deputy-ipad-7bcb@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 5.15-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-5.15.y git checkout FETCH_HEAD git cherry-pick -x 82052e5b5ec36504fe1b9c3c28a711a78fcacf37 # git commit -s git send-email --to '' --in-reply-to '2026112552-deputy-ipad-7bcb@gregkh' --subject-prefix 'PATCH 5.15.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