* [PATCH nf-next] netfilter: xt_TPROXY: enable defrag after protocol validation
@ 2026-12-04 14:00 Wanhui Fu
2026-12-05 6:04 ` Florian Westphal
0 siblings, 1 reply; 2+ messages in thread
From: Wanhui Fu @ 2026-12-04 14:00 UTC (permalink / raw)
To: pablo, fw, phil; +Cc: coreteam, netfilter-devel, Wanhui Fu
Both tproxy_tg4_check() and tproxy_tg6_check() enable defragmentation
before validating the rule protocol. If protocol validation fails,
the target destructor is not called, leaving the defragmentation
user count elevated.
Move protocol validation before enabling defragmentation to avoid
leaking references on rejected rules.
Found by a self-developed static analysis tool and compile-test passed.
Fixes: de8c12110a13 ("netfilter: disable defrag once its no longer needed")
Signed-off-by: Wanhui Fu <fuwh1120@163.com>
---
net/netfilter/xt_TPROXY.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/net/netfilter/xt_TPROXY.c b/net/netfilter/xt_TPROXY.c
index 5f60e7298a1e..cf710d758d0d 100644
--- a/net/netfilter/xt_TPROXY.c
+++ b/net/netfilter/xt_TPROXY.c
@@ -173,15 +173,10 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par)
static int tproxy_tg6_check(const struct xt_tgchk_param *par)
{
const struct ip6t_ip6 *i = par->entryinfo;
- int err;
-
- err = nf_defrag_ipv6_enable(par->net);
- if (err)
- return err;
if ((i->proto == IPPROTO_TCP || i->proto == IPPROTO_UDP) &&
!(i->invflags & IP6T_INV_PROTO))
- return 0;
+ return nf_defrag_ipv6_enable(par->net);
pr_info_ratelimited("Can be used only with -p tcp or -p udp\n");
return -EINVAL;
@@ -196,15 +191,10 @@ static void tproxy_tg6_destroy(const struct xt_tgdtor_param *par)
static int tproxy_tg4_check(const struct xt_tgchk_param *par)
{
const struct ipt_ip *i = par->entryinfo;
- int err;
-
- err = nf_defrag_ipv4_enable(par->net);
- if (err)
- return err;
if ((i->proto == IPPROTO_TCP || i->proto == IPPROTO_UDP)
&& !(i->invflags & IPT_INV_PROTO))
- return 0;
+ return nf_defrag_ipv4_enable(par->net);
pr_info_ratelimited("Can be used only with -p tcp or -p udp\n");
return -EINVAL;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf-next] netfilter: xt_TPROXY: enable defrag after protocol validation
2026-12-04 14:00 [PATCH nf-next] netfilter: xt_TPROXY: enable defrag after protocol validation Wanhui Fu
@ 2026-12-05 6:04 ` Florian Westphal
0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2026-12-05 6:04 UTC (permalink / raw)
To: Wanhui Fu; +Cc: pablo, phil, coreteam, netfilter-devel
Wanhui Fu <fuwh1120@163.com> wrote:
> Both tproxy_tg4_check() and tproxy_tg6_check() enable defragmentation
> before validating the rule protocol. If protocol validation fails,
> the target destructor is not called, leaving the defragmentation
> user count elevated.
>
> Move protocol validation before enabling defragmentation to avoid
> leaking references on rejected rules.
>
> Found by a self-developed static analysis tool and compile-test passed.
Acked-by: Florian Westphal <fw@strlen.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-05 6:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 14:00 [PATCH nf-next] netfilter: xt_TPROXY: enable defrag after protocol validation Wanhui Fu
2026-12-05 6:04 ` Florian Westphal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.