Netfilter/IPVS fixes for net
Subsystems (4)
Pablo Neira Ayuso
maintainercover Netfilter/IPVS fixes for net
Hi,
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) Limit IPVS cache growth for LBLCR and LBLC schedulers, from Zhiling Zou.
7) Restrict checksum offset to known supported protocols in nft_payload, from Florian Westphal.
8) Fix race in nfnetlink_log due to concurrent instance destruction, from Florian Westphal.
9) Hold nfnl mutex from event notifier path of nfnetlink_queue to deal with race between close() and UNBIND request on same portid, also from Florian.
10) Remove arp_table 32bit compat interface, this is already off in many distributions, from Florian Westphal.
11) 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.
12) 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-03
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 tags/nf-26-09-03
for you to fetch changes up to 5dfd63737fb19c6b179799d3ae784673152f61eb:
netfilter: report NLM_F_DUMP_FILTERED when all is filtered out (2026-09-03 01:39:28 +0200)
----------------------------------------------------------------
netfilter pull request 26-09-03
----------------------------------------------------------------
Chengfeng Ye (2):
netfilter: cttimeout: prevent UAF during module unload
netfilter: nf_log: unregister loggers before per-net teardown
Florian Westphal (5):
netfilter: nft_payload: restrict checksum offsets to known values
netfilter: nfnetlink_log: cope with concurrent instance destruction
netfilter: nfnetlink_queue: hold nfnl mutex in event notifier
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
Zhiling Zou (1):
ipvs: bound LBLCR and LBLC cache growth
include/linux/netfilter_arp/arp_tables.h | 19 -- net/ipv4/netfilter/arp_tables.c | 472 +------------------------------ net/ipv6/netfilter/ip6_tables.c | 5 + net/netfilter/ipvs/ip_vs_lblc.c | 3 + net/netfilter/ipvs/ip_vs_lblcr.c | 3 + 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 +- net/netfilter/nfnetlink_queue.c | 8 +- net/netfilter/nft_payload.c | 36 ++- 13 files changed, 73 insertions(+), 516 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/12 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
Pablo Neira Ayuso
maintainerPATCH 2/12 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 3/12 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 4/12 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
Pablo Neira Ayuso
maintainerPATCH 5/12 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 6/12 ipvs: bound LBLCR and LBLC cache growth
In reply to Pablo Neira AyusoFrom: Zhiling Zou <[email protected]>
ip_vs_lblcr_new() and ip_vs_lblc_new() create cache entries for every previously unseen destination address. The table max_size only tells the periodic collector to reclaim entries after the cache has already exceeded the limit. It does not reclaim entries that the attacker continues to use.
Reject new cache entries once either table reaches max_size * 3 / 2. The extra headroom lets the periodic collector catch up while the existing scheduler fallback continues to use the selected destination when cache creation fails. New traffic therefore stays serviceable without growing the tables further.
--- net/netfilter/ipvs/ip_vs_lblc.c | 3 +++ net/netfilter/ipvs/ip_vs_lblcr.c | 3 +++ 2 files changed, 6 insertions(+)
net/netfilter/ipvs/ip_vs_lblc.c +3 -0
@@ -204,6 +204,9 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,return en;ip_vs_lblc_del (en); } +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc_obj (*en,GFP_ATOMIC );if (!en)return NULL ;
net/netfilter/ipvs/ip_vs_lblcr.c +3 -0
@@ -363,6 +363,9 @@ ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr, en =ip_vs_lblcr_get (af, tbl, daddr);if (!en) { +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc_obj (*en,GFP_ATOMIC );if (!en)return NULL ;
Signature · 1 line
2.47.3
Pablo Neira Ayuso
maintainerPATCH 7/12 netfilter: nft_payload: restrict checksum offsets to known values
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
We need to prevent userspace from corrupting e.g. tcp->doff, because many locations in conntrack and conntrack helpers rely on nf_conntrack_in() having validated the packet headers. nft_payload allows to alter headers later which invalidates this assumption.
The 'Fixes' commit restricts writes to safe fields, but there is another side channel: the checksum location.
Restrict this too. Reported via sashiko/gemini.
--- net/netfilter/nft_payload.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-)
net/netfilter/nft_payload.c +29 -7
@@ -1008,11 +1008,13 @@ static bool nft_payload_validate_inet_csum_offset(const struct nft_ctx *ctx,if (priv->csum_flags)/* makes no sense, asks for "re-update" of L4 checksum */ return false; -/* no further check here; offset can't be negative so bogus -* offsets can corrupt L4 or payload but not l3 headers. -* We already allow arbitrary l4/inner payload writes. -*/ -return true; +/* Validate csum_offset is one of the supported transport header checksums */ +if (priv->csum_offset == offsetof(struct tcphdr , check) || + priv->csum_offset == offsetof(struct udphdr , check) || + priv->csum_offset == offsetof(struct icmp6hdr , icmp6_cksum)) +return true; + +return false;case NFT_PAYLOAD_INNER_HEADER :return true;case NFT_PAYLOAD_TUN_HEADER :
@@ -1046,6 +1048,25 @@ static bool nft_payload_csum_nh_write_ok(const struct nft_payload_set *priv,return false; } +static bool nft_payload_csum_th_write_ok (const struct nft_payload_set *priv, +const struct nft_pktinfo *pkt) +{ +if (!(pkt->flags &NFT_PKTINFO_L4PROTO )) +return false; + +switch (pkt->tprot) { +case IPPROTO_TCP : +return priv->csum_offset == offsetof(struct tcphdr , check); +case IPPROTO_UDP : +case IPPROTO_UDPLITE : +return priv->csum_offset == offsetof(struct udphdr , check); +case IPPROTO_ICMPV6 : +return priv->csum_offset == offsetof(struct icmp6hdr , icmp6_cksum); + } + +return false; +} +static bool nft_payload_csum_write_ok (const struct nft_pktinfo *pkt,const struct nft_payload_set *priv) {
@@ -1055,9 +1076,10 @@ static bool nft_payload_csum_write_ok(const struct nft_pktinfo *pkt,case NFT_PAYLOAD_NETWORK_HEADER :return nft_payload_csum_nh_write_ok (priv, pkt);case NFT_PAYLOAD_TRANSPORT_HEADER : +return nft_payload_csum_th_write_ok (priv, pkt);case NFT_PAYLOAD_INNER_HEADER : -/* neither offsets are validated, offsets cannot be -* negative so real l3 headers cannot be mangled. +/* offset is not validated, offset cannot be +* negative so real l3/l4 headers cannot be mangled. */ return true;case NFT_PAYLOAD_TUN_HEADER :
Signature · 1 line
2.47.3
Pablo Neira Ayuso
maintainerPATCH 8/12 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 9/12 netfilter: nfnetlink_queue: hold nfnl mutex in event notifier
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
We must serialize the release notifier and the config netlink function. A concurrent thread can issue close() which can call the release function while unrelated socket processes UNBIND request for same portid:
Oops: general protection fault, [..] RIP: 0010:__instance_destroy+0x60/0x210 [nfnetlink_queue] Call Trace: nfqnl_recv_config+0x9b0/0xdc0 [nfnetlink_queue] nfnetlink_rcv_msg+0x7c2/0xeb0 ? __pfx_nfnetlink_rcv_msg+0x10/0x10
After this, parallel UNBIND and URELEASE events are impossible.
This change isn't nice, but its the shortest fix given instances are not refcounted and the nfnetlink config callback drops the rcu read lock early due to need for sleeping allocations.
--- net/netfilter/nfnetlink_queue.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/netfilter/nfnetlink_queue.c +5 -3
@@ -1593,6 +1593,7 @@ nfqnl_rcv_nl_event(struct notifier_block *this,if (event ==NETLINK_URELEASE && n->protocol ==NETLINK_NETFILTER ) {int i; +nfnl_lock (NFNL_SUBSYS_QUEUE );/* destroy all instances for this portid */ spin_lock (&q->instances_lock);for (i =0 ; i <INSTANCE_BUCKETS ; i++) {
@@ -1606,6 +1607,7 @@ nfqnl_rcv_nl_event(struct notifier_block *this, } }spin_unlock (&q->instances_lock); +nfnl_unlock (NFNL_SUBSYS_QUEUE ); }return NOTIFY_DONE ; }
@@ -1925,9 +1927,9 @@ static int nfqnl_recv_config(struct sk_buff *skb, const struct nfnl_info *info,/* Lookup queue under RCU. After peer_portid check (or for new queue * in BIND case), the queue is owned by the socket sending this message. -* A socket cannot simultaneously send a message and close, so while -* processing this CONFIG message, nfqnl_rcv_nl_event() (triggered by -* socket close) cannot destroy this queue. Safe to use without RCU. +* nfqnl_rcv_nl_event() will block on the nfnl subsys mutex that is +* held by the caller, so the queue cannot be destroyed in parallel, +* even after we drop the RCU read lock. */ rcu_read_lock (); queue =instance_lookup (q, queue_num);
Signature · 1 line
2.47.3
Pablo Neira Ayuso
maintainerPATCH 10/12 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 +---------------------- 2 files changed, 3 insertions(+), 488 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
Signature · 1 line
2.47.3
Pablo Neira Ayuso
maintainerPATCH 11/12 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
Pablo Neira Ayuso
maintainerPATCH 12/12 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
Jakub Kicinski
maintainerRe: [PATCH net 06/12] ipvs: bound LBLCR and LBLC cache growth
In reply to Pablo Neira AyusoThis is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
ipvs: bound LBLCR and LBLC cache growth
This adds a hard admission limit to ip_vs_lblc_new() and ip_vs_lblcr_new(), rejecting new cache entries once atomic_read(&tbl->entries) reaches max_size * 3 / 2. The stated intent is to leave headroom so the periodic collector can catch up while the scheduler fallback keeps serving traffic.
Quoted 5 lines
net/netfilter/ipvs/ip_vs_lblc.c +0
-0
net/netfilter/ipvs/ip_vs_lblc.c ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr, · line 212
Quoted 9 lines
net/netfilter/ipvs/ip_vs_lblc.c +3
-0@@ -204,6 +204,9 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,return en;ip_vs_lblc_del (en); } +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc_obj (*en,GFP_ATOMIC );if (!en)return NULL ;
[Severity: High]
Can tbl->entries be trusted as a bound on the number of live entries in ip_vs_lblc_new()? The replacement path just above the new test is the only ip_vs_lblc_del() call site that does not decrement the counter:
net/netfilter/ipvs/ip_vs_lblc.c:ip_vs_lblc_new() {
en = ip_vs_lblc_get(af, tbl, daddr);
if (en) {
if (en->dest == dest)
return en;
ip_vs_lblc_del(en); /* no atomic_dec(&tbl->entries) */
}
...
}The helper itself does not touch the counter:
static inline void ip_vs_lblc_del(struct ip_vs_lblc_entry *en)
{
hlist_del_rcu(&en->list);
call_rcu(&en->rcu_head, ip_vs_lblc_rcu_free);
}while every other caller pairs it with an explicit decrement, e.g. in ip_vs_lblc_flush(), ip_vs_lblc_full_check() and ip_vs_lblc_check_expire():
ip_vs_lblc_del(en); atomic_dec(&tbl->entries);
Does that mean each dest change for an already cached daddr adds +1 to tbl->entries while the live entry count stays the same, since ip_vs_lblc_hash() is the only place that increments?
hlist_add_head_rcu(&en->list, &tbl->bucket[hash]); atomic_inc(&tbl->entries);
If so, does the drift ever get corrected? The collector decrements only when it removes a real entry, so it lowers both the counter and the live count equally, and tbl->entries otherwise seems to be reset only in ip_vs_lblc_init_svc().
There also looks to be a second effect from the placement of the new test after ip_vs_lblc_del(): when the limit fires, the old entry has already been unlinked and NULL is returned without a decrement and without a replacement, so the table shrinks while the counter stays where it is.
The replacement path appears to be driven by remote packets, since ip_vs_lblc_schedule() calls __ip_vs_lblc_schedule() and then ip_vs_lblc_new() with a different dest whenever the cached dest is not available, has zero weight, or is_overloaded():
dest = __ip_vs_lblc_schedule(svc); ... spin_lock_bh(&svc->sched_lock); if (!tbl->dead) ip_vs_lblc_new(tbl, &iph->daddr, svc->af, dest);
Once the accumulated drift alone reaches max_size * 3 / 2 (24576 with the default 16384), does ip_vs_lblc_new() return NULL permanently for that service, even with an empty table? That would leave LBLC locality caching disabled for the lifetime of the service, with every packet taking the full __ip_vs_lblc_schedule() dest walk and ip_vs_lblc_check_expire() still scanning all 1024 buckets under svc->sched_lock looking for entries that are no longer there.
That also seems to conflict with the commit message text:
The extra headroom lets the periodic collector catch up while the existing scheduler fallback continues to use the selected destination when cache creation fails.
Would adding the missing atomic_dec(&tbl->entries) next to the ip_vs_lblc_del(en) in ip_vs_lblc_new(), or moving the new test ahead of the lookup and delete, make the limit match the live entry count?
Note that ip_vs_lblcr_new() below places the identical test inside if (!en), before any removal, and has no unbalanced delete, so the two schedulers' counters do not appear to satisfy the same invariant even though the same expression is applied to both.
Quoted 5 lines
net/netfilter/ipvs/ip_vs_lblcr.c +0
-0
net/netfilter/ipvs/ip_vs_lblcr.c ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr, · line 371
Quoted 9 lines
net/netfilter/ipvs/ip_vs_lblcr.c +3
-0@@ -363,6 +363,9 @@ ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr, en =ip_vs_lblcr_get (af, tbl, daddr);if (!en) { +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc_obj (*en,GFP_ATOMIC );if (!en)return NULL ;
[Severity: Medium]
This isn't a bug introduced by this patch, but does the new limit still leave the per-bucket chain length unbounded? ip_vs_lblc_hashkey() and ip_vs_lblcr_hashkey() hash the destination address with no per-table random seed:
return hash_32(ntohl(addr_fold), IP_VS_LBLC_TAB_BITS);
so bucket selection for a chosen address is predictable offline, and ip_vs_lblc_get() / ip_vs_lblcr_get() walk the chain linearly on every scheduled packet:
hlist_for_each_entry_rcu(en, &tbl->bucket[hash], list) if (ip_vs_addr_equal(af, &en->addr, addr)) return en;
Since the new test caps only the total entry count and not the chain length, can all 24576 permitted entries be steered into a single one of the 1024 buckets, leaving the lookup in softirq context (and again under spin_lock_bh(&svc->sched_lock) from ip_vs_lblc_new()) walking a ~24k element list per packet? The patch does reduce the worst case compared to the unbounded chain before it, so this is a pre-existing exposure rather than something the patch adds, but would seeding the hash or bounding chain length be worth doing on top?
Jakub Kicinski
maintainerRe: [PATCH net 07/12] netfilter: nft_payload: restrict checksum offsets to known values
In reply to Pablo Neira AyusoThis is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
netfilter: nft_payload: restrict checksum offsets to known values
This restricts the NFT_PAYLOAD_CSUM_INET checksum offset for transport header writes, both at rule load time in nft_payload_validate_inet_csum_offset() and at packet time via the new nft_payload_csum_th_write_ok() helper. Previously the transport header case accepted any csum_offset.
Quoted 35 lines
net/netfilter/nft_payload.c +15
-5@@ -1008,11 +1008,13 @@ static bool nft_payload_validate_inet_csum_offset(const struct nft_ctx *ctx,if (priv->csum_flags)/* makes no sense, asks for "re-update" of L4 checksum */ return false; -/* no further check here; offset can't be negative so bogus -* offsets can corrupt L4 or payload but not l3 headers. -* We already allow arbitrary l4/inner payload writes. -*/ -return true; +/* Validate csum_offset is one of the supported transport header checksums */ +if (priv->csum_offset == offsetof(struct tcphdr , check) || + priv->csum_offset == offsetof(struct udphdr , check) || + priv->csum_offset == offsetof(struct icmp6hdr , icmp6_cksum)) +return true; + +return false;case NFT_PAYLOAD_INNER_HEADER :return true;case NFT_PAYLOAD_TUN_HEADER :@@ -1046,6 +1048,25 @@ static bool nft_payload_csum_nh_write_ok(const struct nft_payload_set *priv,return false; } +static bool nft_payload_csum_th_write_ok (const struct nft_payload_set *priv, +const struct nft_pktinfo *pkt) +{ +if (!(pkt->flags &NFT_PKTINFO_L4PROTO )) +return false; + +switch (pkt->tprot) { +case IPPROTO_TCP :
net/netfilter/nft_payload.c static bool nft_payload_csum_nh_write_ok(const struct nft_payload_set *priv, · line 1068
Quoted 10 lines
net/netfilter/nft_payload.c +10
-0+return priv->csum_offset == offsetof(struct tcphdr , check); +case IPPROTO_UDP : +case IPPROTO_UDPLITE : +return priv->csum_offset == offsetof(struct udphdr , check); +case IPPROTO_ICMPV6 : +return priv->csum_offset == offsetof(struct icmp6hdr , icmp6_cksum); + } + +return false; +}
[Severity: High]
Should nft_payload_csum_th_write_ok() also handle IPPROTO_ICMP? There is no arm for it, and neither IPPROTO_ICMP nor struct icmphdr appear anywhere in nft_payload.c (linux/icmp.h is not included), so pkt->tprot == IPPROTO_ICMP falls out of the switch and returns false.
At the same time the load time check above accepts csum_offset == 2, because the two checksum fields sit at the same offset:
include/uapi/linux/icmp.h:
struct icmphdr {
__u8 type;
__u8 code;
__sum16 checksum;
...
So a rule such as:
nft add rule ip filter output icmp id set 1
still loads without error, but at packet time the checksum fixup is skipped. In nft_payload_set_eval() the helper is only the middle operand of an && chain, so a false return does not reach the err label:
if (priv->csum_type == NFT_PAYLOAD_CSUM_INET && nft_payload_csum_write_ok(pkt, priv) && nft_payload_csum_inet(skb, src, fsum, tsum, csum_offset)) goto err; ... if (skb_ensure_writable(skb, max(offset + priv->len, 0)) || skb_store_bits(skb, offset, src, priv->len) < 0) goto err;
Does this mean the ICMPv4 header bytes are still rewritten by skb_store_bits() while the old checksum is left in place, so such packets go out with a stale checksum? Before this patch the NFT_PAYLOAD_TRANSPORT_HEADER case of nft_payload_csum_write_ok() returned true unconditionally, so previously working ICMPv4 mangling rules would change behaviour here.
The accepted protocol list looks like the one in nft_payload_l4csum_offset(), which serves the csum_flags pseudo-header path and therefore has a reason to omit ICMPv4. Is that the right list to reuse for the NFT_PAYLOAD_CSUM_INET path?
Two things that may be worth considering: adding
case IPPROTO_ICMP: return priv->csum_offset == offsetof(struct icmphdr, checksum);
to nft_payload_csum_th_write_ok(), and making the run time refusal set NFT_BREAK rather than silently skipping the checksum update, so load time and run time agree.
Quoted 13 lines
net/netfilter/nft_payload.c +3
-2@@ -1055,9 +1076,10 @@ static bool nft_payload_csum_write_ok(const struct nft_pktinfo *pkt,case NFT_PAYLOAD_NETWORK_HEADER :return nft_payload_csum_nh_write_ok (priv, pkt);case NFT_PAYLOAD_TRANSPORT_HEADER : +return nft_payload_csum_th_write_ok (priv, pkt);case NFT_PAYLOAD_INNER_HEADER : -/* neither offsets are validated, offsets cannot be -* negative so real l3 headers cannot be mangled. +/* offset is not validated, offset cannot be +* negative so real l3/l4 headers cannot be mangled. */ return true;case NFT_PAYLOAD_TUN_HEADER :
[ ... ]
Jakub Kicinski
maintainerRe: [PATCH net 09/12] netfilter: nfnetlink_queue: hold nfnl mutex in event notifier
In reply to Pablo Neira AyusoThis is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
netfilter: nfnetlink_queue: hold nfnl mutex in event notifier
The NETLINK_URELEASE notifier now takes the NFNL_SUBSYS_QUEUE mutex around the instance teardown loop, so it can no longer run concurrently with nfqnl_recv_config(). The comment in nfqnl_recv_config() is updated to explain that the notifier blocks on the subsystem mutex held by the caller.
net/netfilter/nfnetlink_queue.c nfqnl_rcv_nl_event(struct notifier_block *this, · line 1599
Quoted 12 lines
net/netfilter/nfnetlink_queue.c +1
-0@@ -1593,6 +1593,7 @@ nfqnl_rcv_nl_event(struct notifier_block *this,if (event ==NETLINK_URELEASE && n->protocol ==NETLINK_NETFILTER ) {int i; +nfnl_lock (NFNL_SUBSYS_QUEUE );/* destroy all instances for this portid */ spin_lock (&q->instances_lock);for (i =0 ; i <INSTANCE_BUCKETS ; i++) {
[Severity: Medium]
The new mutex gives mutual exclusion, but does it give any ordering against the socket unhash? In netlink_release() the socket is removed from the hash table before the notifier chain is invoked:
net/netlink/af_netlink.c:netlink_release() {
...
netlink_remove(sk);
sock_orphan(sk);
...
if (nlk->portid && nlk->bound) {
struct netlink_notify n = {
...
.portid = nlk->portid,
};
blocking_notifier_call_chain(&netlink_chain,
NETLINK_URELEASE, &n);
}
}Once netlink_remove(sk) has run, the portid is free for anyone else to claim:
net/netlink/af_netlink.c:netlink_bind() {
...
err = nladdr->nl_pid ?
netlink_insert(sk, nladdr->nl_pid) :
netlink_autobind(sock);
}So the sequence below looks possible:
thread A: close() -> netlink_remove(sk) unhashes portid P thread B: bind(P) succeeds
thread B: NFQNL_MSG_CONFIG / NFQNL_CFG_CMD_BIND
-> instance_create(q, queue_num, NETLINK_CB(skb).portid)
stamps inst->peer_portid = P thread A: blocking_notifier_call_chain(NETLINK_URELEASE) finally runs
Since the loop here keys ownership only on the numeric portid:
hlist_for_each_entry_safe(inst, t2, head, hlist) {
if (n->portid == inst->peer_portid)
__instance_destroy(inst);
}does thread A's notifier then destroy the instance that thread B just created? __instance_destroy() does hlist_del_rcu() plus queue_rcu_work(), and instance_destroy_work() -> nfqnl_flush() drops all queued packets, after which thread B's NFQNL_MSG_VERDICT calls fail with -ENODEV from verdict_instance_lookup(), leaving the NFQUEUE rule to drop or bypass traffic depending on the queue-bypass setting.
The portid-based ownership test itself predates this patch, but does the new mutex widen the window rather than narrow it? Before, the notifier only contended on q->instances_lock and could easily win the race and find nothing to destroy. Now, if the notifier arrives at any point while the re-binding socket is inside nfqnl_recv_config() holding the QUEUE mutex (which sleeps in kzalloc_obj(GFP_KERNEL_ACCOUNT) and rhashtable_init()), the notifier is parked until that CONFIG operation completes, so it is guaranteed to run after the new instance is linked and will match it.
Would keying ownership on the socket identity, or refcounting instances as the commit message notes is currently missing, avoid this rather than relying on the subsystem mutex?
Quoted 11 lines
net/netfilter/nfnetlink_queue.c +1
-0@@ -1606,6 +1607,7 @@ nfqnl_rcv_nl_event(struct notifier_block *this, } }spin_unlock (&q->instances_lock); +nfnl_unlock (NFNL_SUBSYS_QUEUE ); }return NOTIFY_DONE ; }@@ -1925,9 +1927,9 @@ static int nfqnl_recv_config(struct sk_buff *skb, const struct nfnl_info *info,/* Lookup queue under RCU. After peer_portid check (or for new queue
net/netfilter/nfnetlink_queue.c static int nfqnl_recv_config(struct sk_buff *skb, const struct nfnl_info *info, · line 1935
Quoted 10 lines
net/netfilter/nfnetlink_queue.c +3
-3* in BIND case), the queue is owned by the socket sending this message. -* A socket cannot simultaneously send a message and close, so while -* processing this CONFIG message, nfqnl_rcv_nl_event() (triggered by -* socket close) cannot destroy this queue. Safe to use without RCU. +* nfqnl_rcv_nl_event() will block on the nfnl subsys mutex that is +* held by the caller, so the queue cannot be destroyed in parallel, +* even after we drop the RCU read lock. */ rcu_read_lock (); queue =instance_lookup (q, queue_num);
This finding was flagged as requiring validation, so please double check whether the portid reuse window described above is reachable in practice on your side.
Jakub Kicinski
maintainerQuoted 1 line · On Thu, 3 Sep 2026 02:41:37 +0200 Pablo Neira Ayuso wrote:
netfilter pull request 26-09-03
I think the AI is now going too far claiming the patches don't fully close the issue and/or the commit message isn't 100% accurate. But we missed the net PR today, already, so why not confirm..
Julian Anastasov
maintainerRe: [PATCH net 06/12] ipvs: bound LBLCR and LBLC cache growth
In reply to Jakub KicinskiHello,
Quoted 31 lines · Jakub Kicinski
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
ipvs: bound LBLCR and LBLC cache growthThis adds a hard admission limit to
ip_vs_lblc_new()andip_vs_lblcr_new(), rejecting new cache entries onceatomic_read(&tbl->entries)reachesmax_size* 3 / 2. The stated intent is to leave headroom so the periodic collector can catch up while the scheduler fallback keeps serving traffic.Quoted 5 lines
net/netfilter/ipvs/ip_vs_lblc.c +0
-0net/netfilter/ipvs/ip_vs_lblc.c ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr, · line 212
Quoted 9 lines
net/netfilter/ipvs/ip_vs_lblc.c +3
-0@@ -204,6 +204,9 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,return en;ip_vs_lblc_del (en); } +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc_obj (*en,GFP_ATOMIC );if (!en)return NULL ;[Severity: High]
Cantbl->entriesbe trusted as a bound on the number of live entries inip_vs_lblc_new()? The replacement path just above the new test is the onlyip_vs_lblc_del()call site that does not decrement the counter:
Quoted 6 lines
net/netfilter/ipvs/ip_vs_lblc.c:ip_vs_lblc_new() {
en = ip_vs_lblc_get(af, tbl, daddr);
if (en) {
if (en->dest == dest)
return en;
ip_vs_lblc_del(en); /* no atomic_dec(&tbl->entries) */ Yes, we remember this place from the previous Sashiko
review but the new change depends on the current patch to apply gracefully.
Quoted 100 lines
} ... }The helper itself does not touch the counter:
static inline void
ip_vs_lblc_del(struct ip_vs_lblc_entry *en){ hlist_del_rcu(&en->list); call_rcu(&en->rcu_head, ip_vs_lblc_rcu_free); }while every other caller pairs it with an explicit decrement, e.g. in
ip_vs_lblc_flush(),ip_vs_lblc_full_check()andip_vs_lblc_check_expire():ip_vs_lblc_del(en); atomic_dec(&tbl->entries);Does that mean each dest change for an already cached daddr adds +1 to
tbl->entrieswhile the live entry count stays the same, sinceip_vs_lblc_hash()is the only place that increments?hlist_add_head_rcu(&en->list, &tbl->bucket[hash]); atomic_inc(&tbl->entries);If so, does the drift ever get corrected? The collector decrements only when it removes a real entry, so it lowers both the counter and the live count equally, and
tbl->entriesotherwise seems to be reset only inip_vs_lblc_init_svc().There also looks to be a second effect from the placement of the new test after
ip_vs_lblc_del(): when the limit fires, the old entry has already been unlinked and NULL is returned without a decrement and without a replacement, so the table shrinks while the counter stays where it is.The replacement path appears to be driven by remote packets, since
ip_vs_lblc_schedule()calls__ip_vs_lblc_schedule()and thenip_vs_lblc_new()with a different dest whenever the cached dest is not available, has zero weight, oris_overloaded():dest = __ip_vs_lblc_schedule(svc); ... spin_lock_bh(&svc->sched_lock); if (!tbl->dead) ip_vs_lblc_new(tbl, &iph->daddr, svc->af, dest);Once the accumulated drift alone reaches
max_size* 3 / 2 (24576 with the default 16384), doesip_vs_lblc_new()return NULL permanently for that service, even with an empty table? That would leave LBLC locality caching disabled for the lifetime of the service, with every packet taking the full__ip_vs_lblc_schedule()dest walk andip_vs_lblc_check_expire()still scanning all 1024 buckets undersvc->sched_locklooking for entries that are no longer there.That also seems to conflict with the commit message text:
The extra headroom lets the periodic collector catch up while the existing scheduler fallback continues to use the selected destination when cache creation fails.
Would adding the missing
atomic_dec(&tbl->entries)next to theip_vs_lblc_del(en)inip_vs_lblc_new(), or moving the new test ahead of the lookup and delete, make the limit match the live entry count?Note that
ip_vs_lblcr_new()below places the identical test inside if (!en), before any removal, and has no unbalanced delete, so the two schedulers' counters do not appear to satisfy the same invariant even though the same expression is applied to both.Quoted 5 lines
net/netfilter/ipvs/ip_vs_lblcr.c +0
-0net/netfilter/ipvs/ip_vs_lblcr.c ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr, · line 371
Quoted 9 lines
net/netfilter/ipvs/ip_vs_lblcr.c +3
-0@@ -363,6 +363,9 @@ ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr, en =ip_vs_lblcr_get (af, tbl, daddr);if (!en) { +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc_obj (*en,GFP_ATOMIC );if (!en)return NULL ;[Severity: Medium]
This isn't a bug introduced by this patch, but does the new limit still leave the per-bucket chain length unbounded?ip_vs_lblc_hashkey()andip_vs_lblcr_hashkey()hash the destination address with no per-table random seed:return hash_32(ntohl(addr_fold), IP_VS_LBLC_TAB_BITS);so bucket selection for a chosen address is predictable offline, and
ip_vs_lblc_get()/ip_vs_lblcr_get()walk the chain linearly on every scheduled packet:hlist_for_each_entry_rcu(en, &tbl->bucket[hash], list) if (ip_vs_addr_equal(af, &en->addr, addr)) return en;
Quoted 8 lines
Since the new test caps only the total entry count and not the chain length, can all 24576 permitted entries be steered into a single one of the 1024 buckets, leaving the lookup in softirq context (and again under
spin_lock_bh(&svc->sched_lock)fromip_vs_lblc_new()) walking a ~24k element list per packet? The patch does reduce the worst case compared to the unbounded chain before it, so this is a pre-existing exposure rather than something the patch adds, but would seeding the hash or bounding chain length be worth doing on top?
Yes, adding random seed and changing the hash function
can be useful improvement. Added to TODO.
Regards
--
Julian Anastasov <[email protected]>
Florian Westphal
maintainerRe: [PATCH net 07/12] netfilter: nft_payload: restrict checksum offsets to known values
In reply to Jakub KicinskiQuoted 5 lines · Jakub Kicinski
[Severity: High]
Shouldnft_payload_csum_th_write_ok()also handleIPPROTO_ICMP? There is no arm for it, and neitherIPPROTO_ICMPnor struct icmphdr appear anywhere innft_payload.c(linux/icmp.his not included), sopkt->tprot==IPPROTO_ICMPfalls out of the switch and returns false.
Sigh.
Quoted 8 lines
Two things that may be worth considering: adding
case IPPROTO_ICMP: return priv->csum_offset == offsetof(struct icmphdr, checksum);to
nft_payload_csum_th_write_ok(), and making the run time refusal setNFT_BREAKrather than silently skipping the checksum update, so load time and run time agree.
Sigh.
Florian Westphal
maintainerRe: [PATCH net 09/12] netfilter: nfnetlink_queue: hold nfnl mutex in event notifier
In reply to Jakub KicinskiQuoted 18 lines · Jakub Kicinski
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
netfilter:nfnetlink_queue: hold nfnl mutex in event notifierThe
NETLINK_URELEASEnotifier now takes theNFNL_SUBSYS_QUEUEmutex around the instance teardown loop, so it can no longer run concurrently withnfqnl_recv_config(). The comment innfqnl_recv_config()is updated to explain that the notifier blocks on the subsystem mutex held by the caller.Quoted 8 lines
net/netfilter/nfnetlink_queue.c +0
-0@@ -1593,6 +1593,7 @@ nfqnl_rcv_nl_event(struct notifier_block *this,if (event ==NETLINK_URELEASE && n->protocol ==NETLINK_NETFILTER ) {int i;
Quoted 9 lines
net/netfilter/nfnetlink_queue.c nfqnl_rcv_nl_event(struct notifier_block *this, · line 1599
Quoted 4 lines
net/netfilter/nfnetlink_queue.c +1
-0+nfnl_lock (NFNL_SUBSYS_QUEUE );/* destroy all instances for this portid */ spin_lock (&q->instances_lock);for (i =0 ; i <INSTANCE_BUCKETS ; i++) {[Severity: Medium]
The new mutex gives mutual exclusion, but does it give any ordering against the socket unhash? Innetlink_release()the socket is removed from the hash table before the notifier chain is invoked:
I'm useless. I don't even know what this is trying to tell me.
Florian Westphal
maintainerQuoted 6 lines · Jakub Kicinski
Quoted 1 line · On Thu, 3 Sep 2026 02:41:37 +0200 Pablo Neira Ayuso wrote:
netfilter pull request 26-09-03
I think the AI is now going too far claiming the patches don't fully close the issue and/or the commit message isn't 100% accurate. But we missed the net PR today, already, so why not confirm..
Pablo, I suggest you drop all my patches from this batch and resend.
Pablo Neira Ayuso
maintainerQuoted 9 lines · Florian Westphal
Quoted 6 lines · Jakub Kicinski
Quoted 1 line · On Thu, 3 Sep 2026 02:41:37 +0200 Pablo Neira Ayuso wrote:
netfilter pull request 26-09-03
I think the AI is now going too far claiming the patches don't fully close the issue and/or the commit message isn't 100% accurate. But we missed the net PR today, already, so why not confirm..
Pablo, I suggest you drop all my patches from this batch and resend.
I can skip, then pick them up for you to address the issues and resubmit.
Just let me know, thanks!
Florian Westphal
maintainerQuoted 5 lines · Pablo Neira Ayuso
Quoted 4 lines · Florian Westphal
Quoted 3 lines · Jakub Kicinski
Quoted 1 line · On Thu, 3 Sep 2026 02:41:37 +0200 Pablo Neira Ayuso wrote:
netfilter pull request 26-09-03
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I think the AI is now going too far claiming the patches don't fully close the issue and/or the commit message isn't 100% accurate. But we missed the net PR today, already, so why not confirm..
Pablo, I suggest you drop all my patches from this batch and resend.
I can skip, then pick them up for you to address the issues and resubmit.
You can replace the cchecksum restriction patch with the v2 I sent a few minutes ago, if you feel lucky. Don't know what else AI will complain about next time.
As for the nfnetlink patch, I will not send a new version, I don't know what LLM is telling me, nor what the consequence is or why I should bend over backwards and add refcounting or whatever in this patch.
Julian Anastasov
maintainerRe: [PATCH net 06/12] ipvs: bound LBLCR and LBLC cache growth
In reply to Julian AnastasovHi Pablo,
Quoted 40 lines · Julian Anastasov
Quoted 31 lines · Jakub Kicinski
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
ipvs: bound LBLCR and LBLC cache growthThis adds a hard admission limit to
ip_vs_lblc_new()andip_vs_lblcr_new(), rejecting new cache entries onceatomic_read(&tbl->entries)reachesmax_size* 3 / 2. The stated intent is to leave headroom so the periodic collector can catch up while the scheduler fallback keeps serving traffic.Quoted 5 lines
net/netfilter/ipvs/ip_vs_lblc.c +0
-0net/netfilter/ipvs/ip_vs_lblc.c ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr, · line 212
Quoted 9 lines
net/netfilter/ipvs/ip_vs_lblc.c +3
-0@@ -204,6 +204,9 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,return en;ip_vs_lblc_del (en); } +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc_obj (*en,GFP_ATOMIC );if (!en)return NULL ;[Severity: High]
Cantbl->entriesbe trusted as a bound on the number of live entries inip_vs_lblc_new()? The replacement path just above the new test is the onlyip_vs_lblc_del()call site that does not decrement the counter:Quoted 6 lines
net/netfilter/ipvs/ip_vs_lblc.c:ip_vs_lblc_new() { en = ip_vs_lblc_get(af, tbl, daddr); if (en) { if (en->dest == dest) return en; ip_vs_lblc_del(en); /* no atomic_dec(&tbl->entries) */
Quoted 3 lines
Yes, we remember this place from the previous Sashiko
review but the new change depends on the current patch to apply gracefully.
I expected this patch to be applied before posting
a separate fix for the missing atomic_dec(&tbl->entries). Another option is to post the atomic_dec fix on top of the current patch or better before it, so that both can be applied together. If needed, I can repost them together in a new patchset, so that they can be reviewed together properly.
Quoted 13 lines
Quoted 4 lines
hlist_for_each_entry_rcu(en, &tbl->bucket[hash], list) if (ip_vs_addr_equal(af, &en->addr, addr)) return en;Quoted 8 lines
Since the new test caps only the total entry count and not the chain length, can all 24576 permitted entries be steered into a single one of the 1024 buckets, leaving the lookup in softirq context (and again under
spin_lock_bh(&svc->sched_lock)fromip_vs_lblc_new()) walking a ~24k element list per packet? The patch does reduce the worst case compared to the unbounded chain before it, so this is a pre-existing exposure rather than something the patch adds, but would seeding the hash or bounding chain length be worth doing on top?
Quoted 2 lines
Yes, adding random seed and changing the hash function
can be useful improvement. Added to TODO.
As for the hashing change, it can be a -next material.
Regards
--
Julian Anastasov <[email protected]>
Pablo Neira Ayuso
maintainerRe: [PATCH net 06/12] ipvs: bound LBLCR and LBLC cache growth
Hi Julian,
Quoted 11 lines · Julian Anastasov
Hi Pablo,
Quoted 6 lines · Julian Anastasov
Quoted 4 lines · Jakub Kicinski
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
ipvs: bound LBLCR and LBLC cache growth
[...]
Quoted 10 lines
Quoted 3 lines
Yes, we remember this place from the previous Sashiko
review but the new change depends on the current patch to apply gracefully.I expected this patch to be applied before posting
a separate fix for the missingatomic_dec(&tbl->entries). Another option is to post theatomic_decfix on top of the current patch or better before it, so that both can be applied together. If needed, I can repost them together in a new patchset, so that they can be reviewed together properly.
Apologies for the inconvenience, I decided to keep back the three patches that LLMs are barfing when I saw the "Changed Requested" label in patchwork. Too bad.
Please, go ahead post them together, including a cover letter explaining the logic, when bugs are multidimensional, LLMs become a bit strict because they want you to fix all at once, that's hard.
Thanks.
Julian Anastasov
maintainerRe: [PATCH net 06/12] ipvs: bound LBLCR and LBLC cache growth
Hi Pablo,
Quoted 9 lines · Pablo Neira Ayuso
Quoted 7 lines · Julian Anastasov
I expected this patch to be applied before posting
a separate fix for the missingatomic_dec(&tbl->entries). Another option is to post theatomic_decfix on top of the current patch or better before it, so that both can be applied together. If needed, I can repost them together in a new patchset, so that they can be reviewed together properly.
Quoted 7 lines
Apologies for the inconvenience, I decided to keep back the three patches that LLMs are barfing when I saw the "Changed Requested" label in patchwork. Too bad.
Please, go ahead post them together, including a cover letter explaining the logic, when bugs are multidimensional, LLMs become a bit strict because they want you to fix all at once, that's hard.
Just posted the new patch and the old patch in a
new patchset:
https://lore.kernel.org/netfilter-devel/[email protected]/T/#t
The Sashiko review looks ok for now:
https://sashiko.dev/#/patchset/20260910100832.36004-1-ja%40ssi.bg
Regards
--
Julian Anastasov <[email protected]>