Netfilter/IPVS fixes for net
Subsystems (4)
Pablo Neira Ayuso
maintainerv2 cover Netfilter/IPVS fixes for net
v2: Keep back all the patches that Jakub's LLMs are complaining
about.
-o-
The following patchset contains Netfilter/IPVS fixes for net:
1) Reject malformed messages in IPVS sync, from Kyle Zeng.
2) Fix possible stale infoleak in IPVS sync, also from Kyle Zeng.
3) Out-of-bound read in the SIP conntrack helper, from Joas Antonio dos Santos.
4) UaF on cttimeout module removal, from Chengfeng Ye.
5) Unregister nf_loggers before netns teardown to fix UaF, also from Chengfeng Ye.
6) Fix race in nfnetlink_log due to concurrent instance destruction, from Florian Westphal.
7) Remove arp_table 32bit compat interface, this is already off in many distributions, from Florian Westphal.
8) Set IP6T_F_PROTO flag is e->ipv6.proto is set on to deal with insufficient validation of xtables extensions when used from legacy ip6tables, from Florian.
9) Set on the NLM_F_DUMP_FILTERED flag when all is filtering out in ctnetlink, from Ilya Maximets.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-26-09-07
Thanks.
----------------------------------------------------------------
The following changes since commit 1d2929d0850fff683b8aff051275945e65f082c8:
net: psp: do not inherit the Rx association on clone (2026-09-01 15:12:24 +0200)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-26-09-07
for you to fetch changes up to 7a099b347fef536a84068076e2d384f044e5cfc5:
netfilter: report NLM_F_DUMP_FILTERED when all is filtered out (2026-09-07 18:48:56 +0200)
----------------------------------------------------------------
netfilter pull request 26-09-07
----------------------------------------------------------------
Chengfeng Ye (2):
netfilter: cttimeout: prevent UAF during module unload
netfilter: nf_log: unregister loggers before per-net teardown
Florian Westphal (3):
netfilter: nfnetlink_log: cope with concurrent instance destruction
netfilter: arp_tables: remove the 32bit compat interface
netfilter: ip6_tables: set F_PROTO when proto value is nonzero
Ilya Maximets (1):
netfilter: report NLM_F_DUMP_FILTERED when all is filtered out
Joas Antonio dos Santos (1):
netfilter: nf_conntrack_sip: fix OOB read in sip_skip_whitespace()
Kyle Zeng (2):
ipvs: reject invalid states in connection template sync records
ipvs: fix reversed sequence option serialization
include/linux/netfilter_arp/arp_tables.h | 19 -- net/ipv4/netfilter/arp_tables.c | 472 +------------------------------ net/ipv6/netfilter/ip6_tables.c | 5 + net/netfilter/Kconfig | 2 +- net/netfilter/ipvs/ip_vs_sync.c | 20 +- net/netfilter/nf_conntrack_netlink.c | 2 + net/netfilter/nf_conntrack_sip.c | 2 +- net/netfilter/nf_log_syslog.c | 2 +- net/netfilter/nfnetlink_cttimeout.c | 2 +- net/netfilter/nfnetlink_log.c | 15 +- 10 files changed, 34 insertions(+), 507 deletions(-)
Pablo Neira Ayuso
maintainerPATCH v2 1/9 ipvs: reject invalid states in connection template sync records
From: Kyle Zeng <[email protected]>
IPVS sync receivers validate protocol states before creating or updating a connection. For connection templates, however, they only log states outside the template state range and still store the value in the connection.
A template can be returned by ordinary connection lookup. TCP and SCTP then use the invalid state as an index into their transition tables.
Reject invalid template states in both sync protocol versions before looking up or modifying a connection. The version 1 path handles both IPv4 and IPv6 records.
--- net/netfilter/ipvs/ip_vs_sync.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +8 -8
@@ -999,10 +999,10 @@ static void ip_vs_process_message_v0(struct netns_ipvs *ipvs, const char *buffer pp->name, state);continue ; } - }else { -if (state >=IP_VS_CTPL_S_LAST ) -IP_VS_DBG (7 ,"BACKUP v0, Invalid tpl state %u\n" , - state); + }else if (state >=IP_VS_CTPL_S_LAST ) { +IP_VS_DBG (7 ,"BACKUP v0, Invalid tpl state %u\n" , + state); +continue ; } ip_vs_conn_fill_param(ipvs, AF_INET, s->protocol,
@@ -1159,10 +1159,10 @@ static inline int ip_vs_proc_sync_conn(struct netns_ipvs *ipvs, __u8 *p, __u8 *m retc =40 ; goto out; } - }else { -if (state >=IP_VS_CTPL_S_LAST ) -IP_VS_DBG (7 ,"BACKUP, Invalid tpl state %u\n" , - state); + }else if (state >=IP_VS_CTPL_S_LAST ) { +IP_VS_DBG (7 ,"BACKUP, Invalid tpl state %u\n" , state); + retc =40 ; + goto out; }if (ip_vs_conn_fill_param_sync (ipvs, af, s, ¶m, pe_data, pe_data_len, pe_name, pe_name_len)) {
Signature · 1 line
2.47.3
Re: [PATCH net 1/9] ipvs: reject invalid states in connection template sync records
This series was applied to netdev/net.git (main) by Pablo Neira Ayuso <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Pablo Neira Ayuso <[email protected]>:
Quoted 10 lines · On Mon, 7 Sep 2026 19:17:24 +0200 you wrote:
From: Kyle Zeng <[email protected]>
IPVS sync receivers validate protocol states before creating or updating a connection. For connection templates, however, they only log states outside the template state range and still store the value in the connection.
A template can be returned by ordinary connection lookup. TCP and SCTP then use the invalid state as an index into their transition tables.
[...]
Here is the summary with links:
- [net,1/9] ipvs: reject invalid states in connection template sync records
https://git.kernel.org/netdev/net/c/74cb39735b6c - [net,2/9] ipvs: fix reversed sequence option serialization https://git.kernel.org/netdev/net/c/b04578b74f2d - [net,3/9] netfilter: nf_conntrack_sip: fix OOB read in sip_skip_whitespace() https://git.kernel.org/netdev/net/c/e8f8231824b5 - [net,4/9] netfilter: cttimeout: prevent UAF during module unload https://git.kernel.org/netdev/net/c/fec9b1de0d02 - [net,5/9] netfilter: nf_log: unregister loggers before per-net teardown https://git.kernel.org/netdev/net/c/2c018cc4842c - [net,6/9] netfilter: nfnetlink_log: cope with concurrent instance destruction https://git.kernel.org/netdev/net/c/387d744fa7e4 - [net,7/9] netfilter: arp_tables: remove the 32bit compat interface https://git.kernel.org/netdev/net/c/0bd7ed1a3263 - [net,8/9] netfilter: ip6_tables: set F_PROTO when proto value is nonzero https://git.kernel.org/netdev/net/c/da4afc5a956d - [net,9/9] netfilter: report NLM_F_DUMP_FILTERED when all is filtered out https://git.kernel.org/netdev/net/c/7a099b347fef
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Pablo Neira Ayuso
maintainerPATCH v2 2/9 ipvs: fix reversed sequence option serialization
In reply to Pablo Neira AyusoFrom: Kyle Zeng <[email protected]>
hton_seq() expects the host-order source first and the unaligned network-order destination second. The version 1 sync sender passes these arguments in reverse for both sequence blocks. This leaves 24 bytes of the kmalloc-backed message unwritten. It may disclose stale heap data and replace the live connection sequence state with values read from the buffer.
Pass the connection sequence state as the source and the message payload as the destination for both blocks.
--- net/netfilter/ipvs/ip_vs_sync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +2 -2
@@ -747,9 +747,9 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { *(p++) =IPVS_OPT_SEQ_DATA ; *(p++) =sizeof (struct ip_vs_sync_conn_options ); -hton_seq ((struct ip_vs_seq *)p, &cp->in_seq); +hton_seq (&cp->in_seq, (struct ip_vs_seq *)p); p +=sizeof (struct ip_vs_seq ); -hton_seq ((struct ip_vs_seq *)p, &cp->out_seq); +hton_seq (&cp->out_seq, (struct ip_vs_seq *)p); p +=sizeof (struct ip_vs_seq ); }/* Handle pe data */
Signature · 1 line
2.47.3
Pablo Neira Ayuso
maintainerPATCH v2 3/9 netfilter: nf_conntrack_sip: fix OOB read in sip_skip_whitespace()
In reply to Pablo Neira AyusoFrom: Joas Antonio dos Santos <[email protected]>
sip_skip_whitespace() returns dptr unchanged when its own loop exhausts the buffer (dptr == limit), instead of NULL like its sibling sip_follow_continuation() returns on its own "no more data" path.
ct_sip_get_header() only checks for NULL after calling it:
dptr = sip_skip_whitespace(dptr, limit);
if (dptr == NULL)
break;
if (*dptr != ':' || ++dptr >= limit)
break;so a recognized header name followed only by spaces/tabs running to the exact end of the SIP payload, with no colon, makes the very next statement read one byte past the buffer.
Make both "no more data" outcomes return NULL, matching the convention sip_follow_continuation() already uses and that both existing callers already check for.
--- net/netfilter/nf_conntrack_sip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_sip.c +1 -1
@@ -423,7 +423,7 @@ static const char *sip_skip_whitespace(const char *dptr, const char *limit) dptr =sip_follow_continuation (dptr, limit);break ; } -return dptr; +return dptr < limit ? dptr :NULL ; }/* Search within a SIP header value, dealing with continuation lines */
Signature · 1 line
2.47.3
Pablo Neira Ayuso
maintainerPATCH v2 4/9 netfilter: cttimeout: prevent UAF during module unload
In reply to Pablo Neira AyusoFrom: Chengfeng Ye <[email protected]>
nf_ct_set_timeout() protects the timeout hook dereference and policy lookup with rcu_read_lock(). cttimeout_exit(), however, unregisters the per-net operations before it clears the hook.
This allows the following interleaving:
CPU 0 CPU 1
cttimeout_exit() nf_ct_set_timeout()
unregister_pernet_subsys() rcu_read_lock()
kfree(pernet) h = nf_ct_timeout_hook
h->timeout_find_get()
nfct_timeout_pernet()
The hook still points to ctnl_timeout_find_get() when CPU 1 looks up the already freed per-net timeout list. KASAN reported:
BUG: KASAN: slab-use-after-free in ctnl_timeout_find_get Read of size 8 by task poc/90 Call Trace: ctnl_timeout_find_get+0x271/0x2a0 [nfnetlink_cttimeout] nf_ct_set_timeout+0x7b/0x3c0 xt_ct_tg_check+0x724/0xb20 xt_check_target+0x234/0xa90 do_ipt_set_ctl+0x570/0x1270 Allocated by task 89: __kmalloc_noprof+0x16e/0x460 ops_init+0x6d/0x420 register_pernet_operations+0x2f6/0x670 Freed by task 91: kfree+0x131/0x390 ops_undo_list+0x3d4/0x730 unregister_pernet_operations+0x232/0x490 unregister_pernet_subsys+0x1c/0x30 cttimeout_exit+0x52/0x970 [nfnetlink_cttimeout]
Clear the hook and wait for existing readers before unregistering the per-net operations. This blocks new policy lookups and ensures readers that observed the hook finish before the per-net storage is freed.
--- net/netfilter/nfnetlink_cttimeout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nfnetlink_cttimeout.c +1 -1
@@ -652,9 +652,9 @@ static void __exit cttimeout_exit(void) {nfnetlink_subsys_unregister (&cttimeout_subsys); -unregister_pernet_subsys (&cttimeout_ops);RCU_INIT_POINTER (nf_ct_timeout_hook,NULL );synchronize_net (); +unregister_pernet_subsys (&cttimeout_ops); }module_init (cttimeout_init);
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net 4/9] netfilter: cttimeout: prevent UAF during module unload
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Critical: 0 · High: 1 · Medium: 0 · Low: 0
- [High] cttimeout_exit() only drains RCU readers that reach the per-net timeout storage through nf_ct_timeout_hook.
--
netfilter: cttimeout: prevent UAF during module unload
This reorders cttimeout_exit() so that nf_ct_timeout_hook is cleared and synchronize_net() is called before unregister_pernet_subsys() frees the per-net timeout storage. That closes the window where nf_ct_set_timeout() could still reach the freed nfct_timeout_pernet blob through the hook.
net/netfilter/nfnetlink_cttimeout.c static void __exit cttimeout_exit(void) · line 658
Quoted 13 lines
net/netfilter/nfnetlink_cttimeout.c +1
-1@@ -652,9 +652,9 @@ static void __exit cttimeout_exit(void) {nfnetlink_subsys_unregister (&cttimeout_subsys); -unregister_pernet_subsys (&cttimeout_ops);RCU_INIT_POINTER (nf_ct_timeout_hook,NULL );synchronize_net (); +unregister_pernet_subsys (&cttimeout_ops); }
[Severity: High]
Does this leave the same per-net object reachable from the netlink dump path during unload?
cttimeout_get_timeout() starts the dump without a module reference:
net/netfilter/nfnetlink_cttimeout.c:cttimeout_get_timeout() {
if (info->nlh->nlmsg_flags & NLM_F_DUMP) {
struct netlink_dump_control c = {
.dump = ctnl_timeout_dump,
};
return netlink_dump_start(info->sk, skb, info->nlh, &c);
}With no .module set, __netlink_dump_start()'s try_module_get(control->module) is try_module_get(NULL), which succeeds without taking anything, and cb->module stays NULL. nf_tables_api.c and nfnetlink_hook.c pass .module = THIS_MODULE in their netlink_dump_control for comparison.
ctnl_timeout_dump() reads the per-net blob that unregister_pernet_subsys() frees, and it is not gated by nf_ct_timeout_hook:
net/netfilter/nfnetlink_cttimeout.c:ctnl_timeout_dump() {
rcu_read_lock();
pernet = nfct_timeout_pernet(net);
list_for_each_entry_rcu(cur, &pernet->nfct_timeout_list, head) {Is the following sequence possible?
1. IPCTNL_MSG_TIMEOUT_NEW creates one policy; cttimeout_new_timeout() does __module_get(THIS_MODULE).
2. A NLM_F_DUMP IPCTNL_MSG_TIMEOUT_GET parks the dump: with one entry present ctnl_timeout_dump() returns skb->len > 0, netlink_dump() queues the skb and leaves nlk->cb_running set with cb->dump = ctnl_timeout_dump.
3. IPCTNL_MSG_TIMEOUT_DELETE removes the policy, and ctnl_timeout_del() does module_put(THIS_MODULE), so the module refcount is back to zero while the dump is still parked.
4. rmmod runs cttimeout_exit(). The synchronize_rcu() inside nfnetlink_subsys_unregister() and the new synchronize_net() only wait for RCU read-side sections, and a parked dump is not in one, so unregister_pernet_subsys() frees the nfct_timeout_pernet allocation and the module text goes away.
5. The next recvmsg() on that netlink socket resumes the dump:
net/netlink/af_netlink.c:netlink_recvmsg() {
if (READ_ONCE(nlk->cb_running) &&
atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2) {
ret = netlink_dump(sk, false);which is an indirect call through cb->dump into freed module text, and then a read of the freed pernet->nfct_timeout_list.
Should the dump control also carry .module = THIS_MODULE so the parked dump pins the module across the unload, given the commit is aimed at the same freed nfct_timeout_pernet object during module unload?
Note that a dump over an empty policy list does not park: ctnl_timeout_dump() returns 0 there and netlink_dump() finishes the dump immediately, so the create/park/delete order above is what makes it reproducible.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260907171732.1407739-2-pablo%40netfilter.org
Pablo Neira Ayuso
maintainerRe: [PATCH net 4/9] netfilter: cttimeout: prevent UAF during module unload
Quoted 45 lines · On Tue, Sep 08, 2026 at 06:04:01PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Critical: 0 · High: 1 · Medium: 0 · Low: 0
- [High]
cttimeout_exit()only drains RCU readers that reach the per-net timeout storage throughnf_ct_timeout_hook.--
netfilter: cttimeout: prevent UAF during module unload
This reorders
cttimeout_exit()so thatnf_ct_timeout_hookis cleared andsynchronize_net()is called beforeunregister_pernet_subsys()frees the per-net timeout storage. That closes the window wherenf_ct_set_timeout()could still reach the freednfct_timeout_pernetblob through the hook.net/netfilter/nfnetlink_cttimeout.c static void __exit cttimeout_exit(void) · line 658
Quoted 13 lines
net/netfilter/nfnetlink_cttimeout.c +1
-1@@ -652,9 +652,9 @@ static void __exit cttimeout_exit(void) {nfnetlink_subsys_unregister (&cttimeout_subsys); -unregister_pernet_subsys (&cttimeout_ops);RCU_INIT_POINTER (nf_ct_timeout_hook,NULL );synchronize_net (); +unregister_pernet_subsys (&cttimeout_ops); }[Severity: High]
Does this leave the same per-net object reachable from the netlink dump path during unload?
cttimeout_get_timeout()starts the dump without a module reference:net/netfilter/nfnetlink_cttimeout.c:cttimeout_get_timeout() { if (info->nlh->nlmsg_flags & NLM_F_DUMP) { struct netlink_dump_control c = { .dump = ctnl_timeout_dump, }; return netlink_dump_start(info->sk, skb, info->nlh, &c); }
Quoted 4 lines
With no .module set, __netlink_dump_start()'s
try_module_get(control->module)istry_module_get(NULL), which succeeds without taking anything, andcb->modulestays NULL.nf_tables_api.candnfnetlink_hook.cpass .module =THIS_MODULEin theirnetlink_dump_controlfor comparison.
This is a pre-existing issue. I can follow up on this.
Pablo Neira Ayuso
maintainerPATCH v2 5/9 netfilter: nf_log: unregister loggers before per-net teardown
In reply to Pablo Neira AyusoFrom: Chengfeng Ye <[email protected]>
nf_log_syslog and nfnetlink_log unregister their per-network namespace operations before unregistering their global logger backends. This leaves a window where a sysctl or netlink writer can rebind the still- registered logger after the per-net pre-exit callback cleared the old selection.
The race looks like this:
CPU 0 CPU 1
---- ----
unregister_pernet_subsys()
nf_log_unset(net, logger)
net->nf.nf_loggers[pf] = NULL
lock nf_log_mutex
find logger in loggers[][]
net->nf.nf_loggers[pf] = logger
unlock nf_log_mutex nf_log_unregister(logger)
lock nf_log_mutex
loggers[pf][type] = NULL
unlock nf_log_mutex
synchronize_rcu()
module exit returns
module core frees backend memory
Later, a sysctl read or packet logging operation can dereference the stale per-net logger pointer.
Fix this by unregistering the global logger backends before tearing down per-net state. Once the global registrations are gone, later writers can no longer rebind the logger. unregister_pernet_subsys() already waits for an RCU grace period after the pre-exit callback clears the per-net selection, while nf_log_unregister() continues to cover readers of the global logger table.
Apply this ordering fix to both nf_log backends that combine per-net teardown with global logger registration.
--- net/netfilter/nf_log_syslog.c | 2 +- net/netfilter/nfnetlink_log.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_log_syslog.c +1 -1
@@ -1073,12 +1073,12 @@ static int __init nf_log_syslog_init(void) static void __exit nf_log_syslog_exit(void) { -unregister_pernet_subsys (&nf_log_syslog_net_ops);nf_log_unregister (&nf_ip_logger);nf_log_unregister (&nf_arp_logger);nf_log_unregister (&nf_ip6_logger);nf_log_unregister (&nf_netdev_logger);nf_log_unregister (&nf_bridge_logger); +unregister_pernet_subsys (&nf_log_syslog_net_ops); }module_init (nf_log_syslog_init);
net/netfilter/nfnetlink_log.c +1 -1
@@ -1233,8 +1233,8 @@ static void __exit nfnetlink_log_fini(void) {nfnetlink_subsys_unregister (&nfulnl_subsys);netlink_unregister_notifier (&nfulnl_rtnl_notifier); -unregister_pernet_subsys (&nfnl_log_net_ops);nf_log_unregister (&nfulnl_logger); +unregister_pernet_subsys (&nfnl_log_net_ops); }MODULE_DESCRIPTION ("netfilter userspace logging" );
Signature · 1 line
2.47.3
Pablo Neira Ayuso
maintainerPATCH v2 6/9 netfilter: nfnetlink_log: cope with concurrent instance destruction
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
Instances are refcounted. However, only memory release happens on the 1 -> 0 transition; the unlink from hashes can occur with any refcount.
Uncooperative userspace can force a situation where a queue is pending for destruction from netlink event while a different socket with same portid processes an UNBIND request.
With right timing, this will unhash the instance again:
Oops: general protection fault, [..] Call Trace: <TASK> nfulnl_recv_config+0x31a/0xd50 nfnetlink_rcv_msg+0x7c2/0xeb0
--- net/netfilter/nfnetlink_log.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
net/netfilter/nfnetlink_log.c +9 -4
@@ -228,13 +228,18 @@ static void __nfulnl_flush(struct nfulnl_instance *inst);static void __instance_destroy (struct nfulnl_instance *inst) { +spin_lock (&inst->lock); +if (inst->copy_mode ==NFULNL_COPY_DISABLED ) { +/* attempt to UNBIND a queue already pending +* destruction via netlink close event. Ignore. +*/ +spin_unlock (&inst->lock); +return ; + } +/* first pull it out of the global list */ hlist_del_rcu (&inst->hlist); -/* then flush all pending packets from skb */ - -spin_lock (&inst->lock); -/* lockless readers wont be able to use us */ inst->copy_mode =NFULNL_COPY_DISABLED ;
Signature · 1 line
2.47.3
Pablo Neira Ayuso
maintainerPATCH v2 7/9 netfilter: arp_tables: remove the 32bit compat interface
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
This feature is required to use 32bit arptables binary on 64bit kernels. It's already off in many distributions including Debian and Fedora for many years.
Zap arptables first, it's the most esoteric of the 4 flavors.
--- include/linux/netfilter_arp/arp_tables.h | 19 - net/ipv4/netfilter/arp_tables.c | 472 +---------------------- net/netfilter/Kconfig | 2 +- 3 files changed, 4 insertions(+), 489 deletions(-)
include/linux/netfilter_arp/arp_tables.h +0 -19
@@ -56,23 +56,4 @@ void arpt_unregister_table(struct net *net, const char *name);extern unsigned int arpt_do_table (void *priv,struct sk_buff *skb,const struct nf_hook_state *state); -#ifdef CONFIG_NETFILTER_XTABLES_COMPAT -#include <net/compat.h> - -struct compat_arpt_entry { -struct arpt_arp arp; -__u16 target_offset; -__u16 next_offset; -compat_uint_t comefrom; -struct compat_xt_counters counters; -unsigned char elems[]; -}; - -static inline struct xt_entry_target * -compat_arpt_get_target (struct compat_arpt_entry *e) -{ -return (void *)e + e->target_offset; -} - -#endif /* CONFIG_COMPAT */ #endif /* _ARPTABLES_H */
net/ipv4/netfilter/arp_tables.c +3 -469
525 lines not on this page · raw message
net/netfilter/Kconfig +1 -1
@@ -739,7 +739,7 @@ config NETFILTER_XTABLES_COMPAT bool "Netfilter Xtables 32bit support" depends on COMPAT help - This option provides a translation layer to run 32bit arp,ip(6),ebtables + This option provides a translation layer to run 32bit ip(6),ebtables binaries on 64bit kernels. If unsure, say N.
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net 7/9] netfilter: arp_tables: remove the 32bit compat interface
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 1
- [Low] The arptables 32-bit compat interface is only partially removed.
--
netfilter: arp_tables: remove the 32bit compat interface
This removes all arptables-specific 32-bit compat translation code from net/ipv4/netfilter/arp_tables.c, drops struct compat_arpt_entry and its accessor from include/linux/netfilter_arp/arp_tables.h, and updates the NETFILTER_XTABLES_COMPAT help text to no longer mention arp.
Quoted 4 lines
net/ipv4/netfilter/arp_tables.c +0
-0
[ ... ]
Quoted 24 lines
net/ipv4/netfilter/arp_tables.c +0
-12@@ -811,23 +736,11 @@ static int get_info(struct net *net, void __user *user, const int *len)return -EFAULT ; name[XT_TABLE_MAXNAMELEN -1 ] ='\0' ; -#ifdef CONFIG_NETFILTER_XTABLES_COMPAT -if (in_compat_syscall ()) -xt_compat_lock (NFPROTO_ARP ); -#endif t =xt_request_find_table_lock (net,NFPROTO_ARP , name);if (!IS_ERR (t)) {struct arpt_getinfo info;const struct xt_table_info *private = t->private; -#ifdef CONFIG_NETFILTER_XTABLES_COMPAT -struct xt_table_info tmp; -if (in_compat_syscall ()) { - ret =compat_table_info (private, &tmp); -xt_compat_flush_offsets (NFPROTO_ARP ); - private = &tmp; - } -#endif memset (&info,0 ,sizeof (info)); info.valid_hooks = t->valid_hooks; memcpy(info.hook_entry, private->hook_entry,
[ ... ]
Quoted 4 lines
net/ipv4/netfilter/arp_tables.c +0
-0@@ -1432,12 +981,7 @@ static int do_arpt_set_ctl(struct sock *sk, int cmd, sockptr_t arg,switch (cmd) {case ARPT_SO_SET_REPLACE :
net/ipv4/netfilter/arp_tables.c static int do_arpt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, · line 987
Quoted 10 lines
net/ipv4/netfilter/arp_tables.c +1
-6-#ifdef CONFIG_NETFILTER_XTABLES_COMPAT -if (in_compat_syscall ()) - ret =compat_do_replace (sock_net (sk), arg, len); - else -#endif - ret =do_replace (sock_net (sk), arg, len); + ret =do_replace (sock_net (sk), arg, len);break ;case ARPT_SO_SET_ADD_COUNTERS :
[Severity: Low]
Should the two arptables ctl handlers also stop accepting compat callers? Both do_arpt_set_ctl() and do_arpt_get_ctl() still start with:
if (!xt_compat_check()) return -EPERM;
and that helper intentionally lets 32-bit callers continue when CONFIG_NETFILTER_XTABLES_COMPAT is set:
include/linux/netfilter/x_tables.h:xt_compat_check() {
if (!in_compat_syscall())
return true;
pr_warn_once("%s %s\n",
"xtables 32bit compat interface no longer supported",
"in namespaces and will be removed soon.");
if (!capable(CAP_NET_ADMIN))
return false;
#endif
return true;
}So a 32-bit task with CAP_NET_ADMIN now falls straight into the native handlers, which gives three different behaviours:
ARPT_SO_GET_INFO succeeds and copies out the native xt_table_info values, since the compat_table_info() rescaling above is gone:
memcpy(info.hook_entry, private->hook_entry, sizeof(info.hook_entry)); memcpy(info.underflow, private->underflow, sizeof(info.underflow)); info.num_entries = private->number; info.size = private->size;
Are those offsets and size still meaningful to a caller that will walk them using the 32-bit struct arpt_entry layout?
ARPT_SO_SET_REPLACE and ARPT_SO_GET_ENTRIES end up failing with -EINVAL purely as a side effect of header size arithmetic in do_replace() and get_entries() (76 vs 80 bytes for the replace header, 36 + size vs 40 + size for the get_entries header) rather than a defined unsupported error. Would an explicit rejection be clearer here, for example:
if (in_compat_syscall()) return -EOPNOTSUPP;
ARPT_SO_SET_ADD_COUNTERS keeps a working 32-bit ABI, because do_add_counters() -> xt_copy_counters() still carries its own compat branch that converts compat_xt_counters_info for every family, NFPROTO_ARP included:
net/netfilter/x_tables.c:xt_copy_counters() {
#ifdef CONFIG_NETFILTER_XTABLES_COMPAT
if (in_compat_syscall()) {
/* structures only differ in size due to alignment */
struct compat_xt_counters_info compat_tmp;
...
}Does "remove the 32bit compat interface" then hold for that sockopt? If leaving the shared counter path compat-capable until the other three flavors are converted is intended, could the commit message say so?
One more asymmetry: the ip_tables, ip6_tables and ebtables ctl handlers still branch on in_compat_syscall() after the same xt_compat_check() call, so the shared helper now means "translate" for those flavors and "warn, then run the native path" for arptables. Along the same lines, a 32-bit task without CAP_NET_ADMIN now gets -EPERM plus a warning about a compat interface that no longer exists for this flavor.
Quoted 14 lines
net/ipv4/netfilter/arp_tables.c +1
-6@@ -1466,12 +1010,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *lenbreak ;case ARPT_SO_GET_ENTRIES : -#ifdef CONFIG_NETFILTER_XTABLES_COMPAT -if (in_compat_syscall ()) - ret =compat_get_entries (sock_net (sk), user, len); - else -#endif - ret =get_entries (sock_net (sk), user, len); + ret =get_entries (sock_net (sk), user, len);break ;case ARPT_SO_GET_REVISION_TARGET : {
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260907171732.1407739-2-pablo%40netfilter.org
Pablo Neira Ayuso
maintainerRe: [PATCH net 7/9] netfilter: arp_tables: remove the 32bit compat interface
Quoted 4 lines · On Tue, Sep 08, 2026 at 06:04:02PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 1
This rising a lot of issues, because arptables 32bit gets broken.
We can follow up to break it more "nicely", but it is not a big issue.
Pablo Neira Ayuso
maintainerPATCH v2 8/9 netfilter: ip6_tables: set F_PROTO when proto value is nonzero
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
The ip6tables traverser doesn't search the extension header chain unless userspace did set the IP6T_F_PROTO flag.
This also means that userspace that sets the e->ipv6.proto flag can bypass the protocol check for the rule by not setting this flag.
That in turn means that all ip6_tables modules and targets that want to reject rules without '-p' flag MUST also check for that flag.
Not all do, likely because they got copied from iptables which lacks this flag (no extension headers).
Instead of fixing up all the relevant targets, emulate ip6tables behaviour in the kernel (like nft_compat.c) and set the flag if the protocol is set.
--- net/ipv6/netfilter/ip6_tables.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ipv6/netfilter/ip6_tables.c +5 -0
@@ -647,6 +647,11 @@ check_entry_size_and_hooks(struct ip6t_entry *e,/* Clear counters and comefrom */ e->counters = ((struct xt_counters ) {0 ,0 }); e->comefrom =0 ; + +/* set F_PROTO, else ip6_packet_match won't do the right thing. */ +if (e->ipv6.proto) + e->ipv6.flags |=IP6T_F_PROTO ; +return 0 ; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH net 8/9] netfilter: ip6_tables: set F_PROTO when proto value is nonzero
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 1
- [Low] Stale/contradicted UAPI documentation for struct ip6t_ip6::proto.
--
netfilter: ip6_tables: set F_PROTO when proto value is nonzero
This makes the kernel set IP6T_F_PROTO for any rule that carries a nonzero ipv6.proto, so ip6_packet_match() always performs the protocol comparison and extension header walk instead of skipping it when userspace left the flag clear. It mirrors the normalisation already done in nft_compat.c.
Quoted 5 lines
net/ipv6/netfilter/ip6_tables.c +0
-0
net/ipv6/netfilter/ip6_tables.c check_entry_size_and_hooks(struct ip6t_entry *e, · line 656
Quoted 10 lines
net/ipv6/netfilter/ip6_tables.c +5
-0@@ -647,6 +647,11 @@ check_entry_size_and_hooks(struct ip6t_entry *e,/* Clear counters and comefrom */ e->counters = ((struct xt_counters ) {0 ,0 }); e->comefrom =0 ; + +/* set F_PROTO, else ip6_packet_match won't do the right thing. */ +if (e->ipv6.proto) + e->ipv6.flags |=IP6T_F_PROTO ; +return 0 ; }
[Severity: Low]
Should the uapi header comment be updated in the same patch? The description of struct ip6t_ip6::proto in include/uapi/linux/netfilter_ipv6/ip6_tables.h still documents the opposite contract:
/* Upper protocol number * ... * - You also need to set IP6T_FLAGS_PROTO to "flags" to check protocol. */ __u16 proto;
After this change, a non-standard userspace that follows that comment and sets proto = IPPROTO_TCP while leaving flags = 0 (expecting a protocol-agnostic rule) gets a protocol-narrowed rule instead, and ip6_packet_match() now takes the flag-gated branch, including the ipv6_find_hdr() walk and its *hotdrop = true path when the lookup fails with _frag_off == 0:
if (ip6info->flags & IP6T_F_PROTO) {
...
protohdr = ipv6_find_hdr(skb, protoff, -1, &_frag_off, NULL);
if (protohdr < 0) {
if (_frag_off == 0)
*hotdrop = true;Standard ip6tables always sets IP6T_F_PROTO together with -p, so this only affects hand-crafted rule blobs, and the resulting rule is stricter rather than unsafe. Still, the field's documented meaning changes here.
While in that comment, IP6T_FLAGS_PROTO does not exist anywhere in the tree; the macro defined a few lines below is IP6T_F_PROTO. That name is a pre-existing typo and was not introduced by this patch, but it sits in the same sentence this change invalidates.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260907171732.1407739-2-pablo%40netfilter.org
Pablo Neira Ayuso
maintainerRe: [PATCH net 8/9] netfilter: ip6_tables: set F_PROTO when proto value is nonzero
Quoted 27 lines · On Tue, Sep 08, 2026 at 06:04:04PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 1
- [Low] Stale/contradicted UAPI documentation for
struct ip6t_ip6::proto.--
netfilter:
ip6_tables: setF_PROTOwhen proto value is nonzeroThis makes the kernel set
IP6T_F_PROTOfor any rule that carries a nonzero ipv6.proto, soip6_packet_match()always performs the protocol comparison and extension header walk instead of skipping it when userspace left the flag clear. It mirrors the normalisation already done innft_compat.c.Quoted 10 lines
net/ipv6/netfilter/ip6_tables.c +2
-0@@ -647,6 +647,11 @@ check_entry_size_and_hooks(struct ip6t_entry *e,/* Clear counters and comefrom */ e->counters = ((struct xt_counters ) {0 ,0 }); e->comefrom =0 ; + +/* set F_PROTO, else ip6_packet_match won't do the right thing. */
Quoted 8 lines
net/ipv6/netfilter/ip6_tables.c check_entry_size_and_hooks(struct ip6t_entry *e, · line 656
Quoted 5 lines
net/ipv6/netfilter/ip6_tables.c +3
-0+if (e->ipv6.proto) + e->ipv6.flags |=IP6T_F_PROTO ; +return 0 ; }[Severity: Low]
Should the uapi header comment be updated in the same patch?
No.
Pablo Neira Ayuso
maintainerRe: [PATCH net 8/9] netfilter: ip6_tables: set F_PROTO when proto value is nonzero
In reply to [email protected]Quoted 39 lines · On Tue, Sep 08, 2026 at 06:04:04PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 1
- [Low] Stale/contradicted UAPI documentation for
struct ip6t_ip6::proto.--
netfilter:
ip6_tables: setF_PROTOwhen proto value is nonzeroThis makes the kernel set
IP6T_F_PROTOfor any rule that carries a nonzero ipv6.proto, soip6_packet_match()always performs the protocol comparison and extension header walk instead of skipping it when userspace left the flag clear. It mirrors the normalisation already done innft_compat.c.Quoted 5 lines
net/ipv6/netfilter/ip6_tables.c +0
-0net/ipv6/netfilter/ip6_tables.c check_entry_size_and_hooks(struct ip6t_entry *e, · line 656
Quoted 10 lines
net/ipv6/netfilter/ip6_tables.c +5
-0@@ -647,6 +647,11 @@ check_entry_size_and_hooks(struct ip6t_entry *e,/* Clear counters and comefrom */ e->counters = ((struct xt_counters ) {0 ,0 }); e->comefrom =0 ; + +/* set F_PROTO, else ip6_packet_match won't do the right thing. */ +if (e->ipv6.proto) + e->ipv6.flags |=IP6T_F_PROTO ; +return 0 ; }[Severity: Low]
Should the uapi header comment be updated in the same patch? The description of structip6t_ip6::protoininclude/uapi/linux/netfilter_ipv6/ip6_tables.hstill documents the opposite contract:
Quoted 4 lines
/* Upper protocol number * ... * - You also need to set IP6T_FLAGS_PROTO to "flags" to check protocol. */
That is still the indeed recommended practise, so no, comment must be not updated.
This is just makes a work-around for broken userspace code that has no real usecase other than triggering a bug.
Quite a bit of noise from LLM, one pre-existing issue found, but other than that, just lengthy text noise.
Pablo Neira Ayuso
maintainerPATCH v2 9/9 netfilter: report NLM_F_DUMP_FILTERED when all is filtered out
In reply to Pablo Neira AyusoFrom: Ilya Maximets <[email protected]>
NLM_F_DUMP_FILTERED is only set on data elements in the conntrack dump. But when everything is filtered out it is confusing for the user space, since the flag is not reported anymore and it looks like the table was empty, which may or may not be the case.
'answer_flags' were introduced precisely for this use case, and the conntrack dump should set the flag in there in case the filtering was applied.
This is important, for example, to be able to tell if the filters are supported or not by the kernel without modifying the kernel state.
With the proper reporting of NLM_F_DUMP_FILTERED on NLMSG_DONE, an application in user space can just try and dump with an arbitrary filter without worrying that there could be no matching entry. The reported flag will signal that the filtering was applied and therefore supported.
--- net/netfilter/nf_conntrack_netlink.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_conntrack_netlink.c +2 -0
@@ -1077,6 +1077,8 @@ static int ctnetlink_start(struct netlink_callback *cb) } cb->data = filter; +if (filter) + cb->answer_flags =NLM_F_DUMP_FILTERED ;return 0 ; }
Signature · 1 line
2.47.3