Skip to contentSkip to conversation

Netfilter/IPVS fixes for net

PATCH In review Pablo Neira Ayuso 5 participants 26 messages Nov 2 – Nov 3

Subsystems (6)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

cover Netfilter/IPVS fixes for net

Hi,

The following batch contains Netfilter/IPVS fixes for net:

1) Add recursion count to nf_reject infrastructure to prevent stack overflow, from Fernando F. Mancera.

2) Address a infinite loop in RCU list traversal with the TWOS IPVS scheduler, from Darong Lu and Julian Anastasov.

3) Use kfree_rcu() to release IPVS parent application to fix UaF, from Chengfeng Ye.

4) Fix UaF in IPVS netns removal path due to releasing per-net protocol data too early, from Chengfeng Ye.

5) Fix unbounded growth of stale, unmatchable IPVS connection entries, from Julian Anastasov.

6) Restrict maximum master conntrack chain depth in ctnetlink, from Florian Westphal.

7) Preserve recursion count on nfqueue reinjection, from Zihan Xi.

8) Restore GRE timeout in the flowtable, otherwise, WARN_ON_ONCE() is reachable, from Michail Andreas Michalopoulos.

9) Check non-null gc transaction in nft_rbtree before queuing it for processing, from Xingyuan Mo.

10) Replace WARN_ON_ONCE() by DEBUG_NET_WARN_ON_ONCE() in nf_conntrack_bridge which is reachable if the protocol of the tag of a frame differs from the vlan_protocol of the bridge. From Laveesh Bansal.

11) Check x_tables target name is non-null before accessing it when building a new table, from Fernando F. Mancera.

12) Fix out-of-bound memory read in nf_conntrack_sip, from Joas Antonio Dos Santos.

13) Fix a memleak in nf_tables hardware offload when double deleting the same rule, in the same batch.

14) Use a mutex in xt_recent netns exit path instead of spinlock, since proc unregistration might sleep. From Cen Zhang.

15) Zero the nf_nat_range2 struct before filling it up, to avoid using stale uninitialized stack data to configure NAT with an esoteric NAT flags combination. From Florian Westphal.

Please, pull these changes from:

git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-26-11-02

Thanks.

----------------------------------------------------------------

The following changes since commit cb284914e749388eef402938bdb3115fe1f6d337:

net: ipa: Fix double free of the interrupt structure on config error (2026-10-30 19:04:37 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-26-11-02

for you to fetch changes up to f2cbeed50b68f547a70288e2aaa581bc6a366411:

netfilter: nat: zero newrange before filling it in (2026-11-02 01:20:11 +0100)

----------------------------------------------------------------
netfilter pull request 26-11-02

----------------------------------------------------------------
Cen Zhang (Microsoft) (1):
netfilter: xt_recent: do not call remove_proc_entry() under recent_lock

Chengfeng Ye (2):
ipvs: Defer application parent freeing until after RCU readers
ipvs: fix protocol data lifetime during namespace teardown

Darong Lu (1):
ipvs: wait grace period while reusing dest from trash

Fernando Fernandez Mancera (2):
netfilter: nft_reject: prevent unbounded recursion in output hooks
netfilter: x_tables: check target name before accessing verdict

Florian Westphal (2):
netfilter: nf_conntrack: limit expectation master chain depth
netfilter: nat: zero newrange before filling it in

Joas Antonio dos Santos (1):
netfilter: nf_conntrack_sip: fix OOB read in ct_sip_parse_transport()

Julian Anastasov (1):
ipvs: do not create conns from packets with port 0

Laveesh Bansal (1):
netfilter: bridge: use DEBUG_NET_WARN_ON_ONCE in nf_ct_bridge_refrag()

Michail Andreas Michalopoulos (1):
netfilter: flowtable: extend ct timeout of offloaded GRE flows

Pablo Neira Ayuso (1):
netfilter: nf_tables: fix memleak when rule deletion fails with hardware offload

Xingyuan Mo (1):
netfilter: nft_set_rbtree: check catchall_sync return before queue_done

Zihan Xi (1):
netfilter: nf_dup: preserve guard across NFQUEUE reinjection

 include/linux/netdevice_xmit.h              |   4 +-
 include/net/ip_vs.h                         |   4 +-
 include/net/netfilter/nf_conntrack_helper.h |  15 ++++
 include/net/netfilter/nf_dup_netdev.h       |  35 ---------
 include/net/netfilter/nf_queue.h            |   1 +
 include/net/netfilter/nf_recursion.h        |  42 +++++++++++
 net/bridge/netfilter/nf_conntrack_bridge.c  |   2 +-
 net/ipv4/netfilter/arp_tables.c             |   5 +-
 net/ipv4/netfilter/ip_tables.c              |   5 +-
 net/ipv4/netfilter/nf_reject_ipv4.c         |  12 +++
 net/ipv6/netfilter/ip6_tables.c             |   5 +-
 net/ipv6/netfilter/nf_reject_ipv6.c         |  13 ++++
 net/netfilter/ipvs/ip_vs_app.c              |   2 +-
 net/netfilter/ipvs/ip_vs_core.c             |  15 ++--
 net/netfilter/ipvs/ip_vs_ctl.c              | 109 ++++++++++++++++++++++------
 net/netfilter/ipvs/ip_vs_proto_sctp.c       |   5 ++
 net/netfilter/ipvs/ip_vs_proto_tcp.c        |   5 ++
 net/netfilter/ipvs/ip_vs_proto_udp.c        |   4 +
 net/netfilter/nf_conntrack_expect.c         |  15 +++-
 net/netfilter/nf_conntrack_netlink.c        |  36 ++++++---
 net/netfilter/nf_conntrack_sip.c            |   4 +-
 net/netfilter/nf_dup_netdev.c               |   1 +
 net/netfilter/nf_flow_table_core.c          |   1 +
 net/netfilter/nf_nat_masquerade.c           |   4 +-
 net/netfilter/nf_queue.c                    |   1 +
 net/netfilter/nf_tables_api.c               |  21 +++---
 net/netfilter/nf_tables_offload.c           |   3 +
 net/netfilter/nfnetlink_queue.c             |  17 ++++-
 net/netfilter/nft_fwd_netdev.c              |   1 +
 net/netfilter/nft_set_rbtree.c              |   3 +-
 net/netfilter/xt_NETMAP.c                   |   4 +-
 net/netfilter/xt_recent.c                   |   7 +-
 32 files changed, 288 insertions(+), 113 deletions(-)
 create mode 100644 include/net/netfilter/nf_recursion.h
author maintainer
#1 lore raw

PATCH 1/15 netfilter: nft_reject: prevent unbounded recursion in output hooks

From: Fernando Fernandez Mancera <[email protected]>

nftables payload-mangling rules can rewrite packet contents (such as TCP flags) before they are evaluated by reject targets. This defeats the content-based loop guards, allowing unbounded hook recursion that leads to kernel stack exhaustion and panics.

Fix this by extracting the per-CPU xmit recursion limit previously used by the netdev duplication/forwarding paths into a shared header, and apply it to the inet and inet6 reject transmit functions. It disables BH while transmitting the skb to address a possible migration to different CPU leading to imbalanced decrementation of the recursion counters.

Note that the dev_queue_xmit() path used when CONFIG_BRIDGE_NETFILTER is enabled does not require this recursion guard. In that scenario, the generated reset packet is transmitted directly at Layer 2. Because the packet egresses from a different hook, it cannot synchronously loop. In addition nf_send_unreach() and nf_send_unreach6() are safe as the ICMP transmit functions are protected against recursion by the icmp_xmit_lock() and icmpv6_xmit_lock() guards.

Fixes bee11dc78fc8 ("netfilter: nft_reject: support for IPv6 and TCP reset")
---
 include/linux/netdevice_xmit.h        |  4 +--
 include/net/netfilter/nf_dup_netdev.h | 35 ----------------------
 include/net/netfilter/nf_recursion.h  | 42 +++++++++++++++++++++++++++
 net/ipv4/netfilter/nf_reject_ipv4.c   | 12 ++++++++
 net/ipv6/netfilter/nf_reject_ipv6.c   | 13 +++++++++
 net/netfilter/nf_dup_netdev.c         |  1 +
 net/netfilter/nft_fwd_netdev.c        |  1 +
 7 files changed, 71 insertions(+), 37 deletions(-)
 create mode 100644 include/net/netfilter/nf_recursion.h
include/linux/netdevice_xmit.h +2 -2
index cc232508e695..286ae5a6101e 100644
@@ -18,8 +18,8 @@ struct netdev_xmit {
 	u8			sched_mirred_nest;
 	struct net_device	*sched_mirred_dev[MIRRED_NEST_LIMIT];
 #endif
-#if IS_ENABLED(CONFIG_NF_DUP_NETDEV)
-	u8 nf_dup_skb_recursion;
+#if IS_ENABLED(CONFIG_NETFILTER)
+	u8 nf_xmit_skb_recursion;
 #endif
 };
 
include/net/netfilter/nf_dup_netdev.h +0 -35
index f6b05bd80c3f..a39411264614 100644
@@ -9,41 +9,6 @@
 void nf_dup_netdev_egress(const struct nft_pktinfo *pkt, int oif);
 void nf_fwd_netdev_egress(const struct nft_pktinfo *pkt, int oif);
 
-#define NF_RECURSION_LIMIT	2
-
-#ifndef CONFIG_PREEMPT_RT
-static inline bool nf_dev_xmit_recursion(void)
-{
-	return unlikely(__this_cpu_read(softnet_data.xmit.nf_dup_skb_recursion) >
-			NF_RECURSION_LIMIT);
-}
-
-static inline void nf_dev_xmit_recursion_inc(void)
-{
-	__this_cpu_inc(softnet_data.xmit.nf_dup_skb_recursion);
-}
-
-static inline void nf_dev_xmit_recursion_dec(void)
-{
-	__this_cpu_dec(softnet_data.xmit.nf_dup_skb_recursion);
-}
-#else
-static inline bool nf_dev_xmit_recursion(void)
-{
-	return unlikely(current->net_xmit.nf_dup_skb_recursion > NF_RECURSION_LIMIT);
-}
-
-static inline void nf_dev_xmit_recursion_inc(void)
-{
-	current->net_xmit.nf_dup_skb_recursion++;
-}
-
-static inline void nf_dev_xmit_recursion_dec(void)
-{
-	current->net_xmit.nf_dup_skb_recursion--;
-}
-#endif
-
 struct nft_offload_ctx;
 struct nft_flow_rule;
 
include/net/netfilter/nf_recursion.h new file +42 -0

42 lines not on this page · raw message

net/ipv4/netfilter/nf_reject_ipv4.c +12 -0
index 7cb33af671e2..4082fa184af8 100644
@@ -10,6 +10,7 @@
 #include <net/dst.h>
 #include <net/dst_metadata.h>
 #include <net/netfilter/ipv4/nf_reject.h>
+#include <net/netfilter/nf_recursion.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter_bridge.h>
 
@@ -336,7 +337,18 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb,
 		dev_queue_xmit(nskb);
 	} else
 #endif
+	{
+		local_bh_disable();
+		if (nf_dev_xmit_recursion()) {
+			local_bh_enable();
+			goto free_nskb;
+		}
+
+		nf_dev_xmit_recursion_inc();
 		ip_local_out(net, nskb->sk, nskb);
+		nf_dev_xmit_recursion_dec();
+		local_bh_enable();
+	}
 
 	return;
 
net/ipv6/netfilter/nf_reject_ipv6.c +13 -0
index 5e08d8529cc8..7c9464184517 100644
@@ -10,6 +10,7 @@
 #include <net/ip6_checksum.h>
 #include <net/dst_metadata.h>
 #include <net/netfilter/ipv6/nf_reject.h>
+#include <net/netfilter/nf_recursion.h>
 #include <linux/netfilter_ipv6.h>
 #include <linux/netfilter_bridge.h>
 
@@ -409,7 +410,19 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb,
 		dev_queue_xmit(nskb);
 	} else
 #endif
+	{
+		local_bh_disable();
+		if (nf_dev_xmit_recursion()) {
+			local_bh_enable();
+			kfree_skb(nskb);
+			return;
+		}
+
+		nf_dev_xmit_recursion_inc();
 		ip6_local_out(net, sk, nskb);
+		nf_dev_xmit_recursion_dec();
+		local_bh_enable();
+	}
 }
 EXPORT_SYMBOL_GPL(nf_send_reset6);
 
net/netfilter/nf_dup_netdev.c +1 -0
index c6bd5c29bed6..918716629c15 100644
@@ -12,6 +12,7 @@
 #include <net/netfilter/nf_tables.h>
 #include <net/netfilter/nf_tables_offload.h>
 #include <net/netfilter/nf_dup_netdev.h>
+#include <net/netfilter/nf_recursion.h>
 
 static void nf_do_netdev_egress(struct sk_buff *skb, struct net_device *dev,
 				enum nf_dev_hooks hook)
net/netfilter/nft_fwd_netdev.c +1 -0
index a48c2f765bba..7447da931a95 100644
@@ -14,6 +14,7 @@
 #include <net/netfilter/nf_tables.h>
 #include <net/netfilter/nf_tables_offload.h>
 #include <net/netfilter/nf_dup_netdev.h>
+#include <net/netfilter/nf_recursion.h>
 #include <net/neighbour.h>
 #include <net/ip.h>
 
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH net 01/15] netfilter: nft_reject: prevent unbounded recursion in output hooks

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.

The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.

author maintainer
#3 lore raw

Re: [PATCH net 01/15] netfilter: nft_reject: prevent unbounded recursion in output hooks

Quoted 5 lines · On Mon, Nov 02, 2026 at 12:59:26AM +0000, [email protected] wrote:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Quoted 7 lines

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.

Regarding the automated request, this series was primarily identified through LLM-assisted analysis.

A summary of the discovery and triggering status follows:

Issues triggered and verified: Several issues were actively triggered and confirmed via automated testing. This includes KASAN reports for use-after-free and out-of-bounds access (patches 3, 4, 11), syzbot reports for warnings and panics (patches 8 and 10), and a confirmed sleeping function call in an atomic context (patch 14). Patch 12 was identified via LLM and subsequently verified using a userspace ASan harness.

Issues identified via LLM (Preventative):
The remaining patches were identified via LLM-assisted review. These address edge cases to prevent future issues such as unbounded recursion (patch 1), infinite loops (patch 2), stale connection growth (commit 5), chain depth exhaustion (patch 6), guard loss during reinjection (patch 7), NULL pointer dereferences (patch 9), memory leaks (patch 13), and uninitialized stack data (patch 15).

This is a LLM answer to this automated message.

author maintainer
#4 lore raw

PATCH 2/15 ipvs: wait grace period while reusing dest from trash

In reply to Pablo Neira Ayuso

From: Darong Lu <[email protected]>

Darong Lu and the VEGA team report a problem with the TWOS scheduler that manifests as a loop while traversing the list of destinations. The problem occurs if destinations are removed and re-added through the destination trash before an RCU grace period has elapsed. As destinations are re-added to a new service, CPUs traversing the old destination list may never reach the old list head and fail to terminate.

As the problem is not specific to the TWOS scheduler, use a general solution. Jiayuan Chen provided an initial solution based on get_state_synchronize_rcu() and cond_synchronize_rcu(), where the grace period cookie is saved after a destination is unlinked and moved into the destination trash. cond_synchronize_rcu() then ensures the grace period before the destination is reused.

Use a temporary list for destinations removed together from a service or during a flush. A single get_state_synchronize_rcu() call records the cookie for all destinations before the temporary list is spliced into the public destination trash. This also limits destination-trash locking to one acquisition for bulk removal.

Destination edits that remove and re-add an entry to the real-server hash table use the same grace-period mechanism. Destinations returned to the trash after an estimator failure are put back without recording a new cookie.

---
 include/net/ip_vs.h            |   4 +-
 net/netfilter/ipvs/ip_vs_ctl.c | 109 ++++++++++++++++++++++++++-------
 2 files changed, 90 insertions(+), 23 deletions(-)
include/net/ip_vs.h +3 -1
index 9a83bff32569..50a2999beb01 100644
@@ -1021,7 +1021,9 @@ struct ip_vs_dest {
 
 	struct rcu_head		rcu_head;
 	struct list_head	t_list;		/* in dest_trash */
-	unsigned int		in_rs_table:1;	/* we are in rs_table */
+	unsigned long		rcu_state;	/* GP cookie when trashed */
+	unsigned int		in_rs_table:1,	/* we are in rs_table */
+				need_gp:1;	/* Need GP on rehash */
 };
 
 /* The scheduler object */
net/netfilter/ipvs/ip_vs_ctl.c +87 -22

230 lines not on this page · raw message

Signature · 1 line
2.47.3
author maintainer
#5 lore raw

PATCH 3/15 ipvs: Defer application parent freeing until after RCU readers

In reply to Pablo Neira Ayuso

From: Chengfeng Ye <[email protected]>

unregister_ip_vs_app() removes each incarnation from its protocol list and uses call_rcu() to defer freeing it, but frees the parent application immediately. An RCU reader that already found an incarnation can still access the parent through inc->app in ip_vs_app_inc_get().

During FTP helper module unload, the following interleaving is possible:

CPU 0 (RCU reader) CPU 1 (module unload)
tcp_app_conn_bind()

    find inc in protocol list
                                     unregister_ip_vs_app()
                                       ip_vs_app_inc_release(inc)
                                         list_del_rcu(&inc->p_list)
                                         call_rcu(&inc->rcu_head, ...)
                                       kfree(a)
    ip_vs_app_inc_get(inc)
      try_module_get(inc->app->module)

The helper module is already going away, so try_module_get() would fail, but evaluating its argument first reads the freed parent. The subsequent rcu_barrier() in pernet unregistration cannot protect this earlier free. KASAN reported:

  BUG: KASAN: slab-use-after-free in ip_vs_app_inc_get+0x7c/0x90
  Call Trace:
   ip_vs_app_inc_get+0x7c/0x90
   tcp_app_conn_bind+0x1bc/0x290
   ip_vs_conn_new+0x1915/0x20d0
   ip_vs_schedule+0x697/0xea0
   tcp_conn_schedule+0x489/0x820
   ip_vs_in_hook+0x7bf/0x1f40
  Allocated by task 88:
   kmemdup_noprof+0x20/0x50
   register_ip_vs_app+0x12d/0x2c0
   __ip_vs_ftp_init+0x56/0x160 [ip_vs_ftp]
  Freed by task 104:
   kfree+0x131/0x3c0
   unregister_ip_vs_app+0x2f4/0x5b0
   unregister_pernet_operations+0x232/0x490
   unregister_pernet_subsys+0x1c/0x30
   __do_sys_delete_module+0x346/0x510

Use kfree_rcu() with the existing rcu_head to keep the parent alive until these readers finish. Successful helper references already prevent normal module unload, and incarnation RCU callbacks do not access the parent.

Fixes 363c97d7435e ("ipvs: convert app locks")
---
 net/netfilter/ipvs/ip_vs_app.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_app.c +1 -1
index 11cbdbaf561d..2c1b47702da2 100644
@@ -242,7 +242,7 @@ void unregister_ip_vs_app(struct netns_ipvs *ipvs, struct ip_vs_app *app)
 		}
 
 		list_del(&a->a_list);
-		kfree(a);
+		kfree_rcu(a, rcu_head);
 
 		/* decrease the module use count */
 		ip_vs_use_count_dec();
Signature · 1 line
2.47.3
author maintainer
#6 lore raw

PATCH 4/15 ipvs: fix protocol data lifetime during namespace teardown

In reply to Pablo Neira Ayuso

From: Chengfeng Ye <[email protected]>

IPVS frees its per-net protocol data before control cleanup cancels defense work and unregisters the sysctl table. A defense worker can load a protocol data pointer, then namespace cleanup can unlink and free that object before the worker dereferences pd->pp or pd->next. The worker's securetcp_lock does not serialize with protocol cleanup. A concurrent defense-mode sysctl write can reach the same timeout update path.

KASAN reported:

  BUG: KASAN: slab-use-after-free in ip_vs_protocol_timeout_change
  Workqueue: events_long defense_work_handler
  Call Trace:
   ip_vs_protocol_timeout_change+0x1b4/0x1e0
   update_defense_level+0x63e/0xd80
   defense_work_handler+0x1e/0xc0
  Allocated by task 125:
   ip_vs_protocol_net_init+0xda/0x2f0
   __ip_vs_init+0x16b/0x240
   setup_net+0xfc/0x310
  Freed by task 12:
   ip_vs_protocol_net_cleanup+0x1d6/0x2e0
   __ip_vs_cleanup_batch+0x7d/0x100
   cleanup_net+0x38c/0x770

Run control cleanup before protocol cleanup so that defense work and active sysctl handlers have finished before their protocol data is freed. Initialize protocols before exposing the control interface, and unwind in reverse order, to enforce the same lifetime on initialization failure. Protocol initialization and exit do not depend on control state.

Fixes 9330419d9aa4 ("IPVS: netns, use ip_vs_proto_data as param.")
---
 net/netfilter/ipvs/ip_vs_core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
net/netfilter/ipvs/ip_vs_core.c +6 -6
index fd503f0efb57..8a3c880fdb26 100644
@@ -2502,12 +2502,12 @@ static int __net_init __ip_vs_init(struct net *net)
 	if (ip_vs_estimator_net_init(ipvs) < 0)
 		goto estimator_fail;
 
-	if (ip_vs_control_net_init(ipvs) < 0)
-		goto control_fail;
-
 	if (ip_vs_protocol_net_init(ipvs) < 0)
 		goto protocol_fail;
 
+	if (ip_vs_control_net_init(ipvs) < 0)
+		goto control_fail;
+
 	if (ip_vs_app_net_init(ipvs) < 0)
 		goto app_fail;
 
@@ -2527,10 +2527,10 @@ static int __net_init __ip_vs_init(struct net *net)
 conn_fail:
 	ip_vs_app_net_cleanup(ipvs);
 app_fail:
-	ip_vs_protocol_net_cleanup(ipvs);
-protocol_fail:
 	ip_vs_control_net_cleanup(ipvs);
 control_fail:
+	ip_vs_protocol_net_cleanup(ipvs);
+protocol_fail:
 	ip_vs_estimator_net_cleanup(ipvs);
 estimator_fail:
 	net->ipvs = NULL;
@@ -2547,8 +2547,8 @@ static void __net_exit __ip_vs_cleanup_batch(struct list_head *net_list)
 		ipvs = net_ipvs(net);
 		ip_vs_conn_net_cleanup(ipvs);
 		ip_vs_app_net_cleanup(ipvs);
-		ip_vs_protocol_net_cleanup(ipvs);
 		ip_vs_control_net_cleanup(ipvs);
+		ip_vs_protocol_net_cleanup(ipvs);
 		ip_vs_estimator_net_cleanup(ipvs);
 		IP_VS_DBG(2, "ipvs netns %d released\n", ipvs->gen);
 		net->ipvs = NULL;
Signature · 1 line
2.47.3
author maintainer
#7 lore raw

PATCH 5/15 ipvs: do not create conns from packets with port 0

In reply to Pablo Neira Ayuso

From: Julian Anastasov <[email protected]>

We should disallow normal connections with cport 0 to be created from packets by the scheduler (from clients) or by ip_vs_new_conn_out (from real servers) because later such traffic can not hit the connection due to the NO_CPORT requirement. As result, it can lead to duplicate connection for every packet. Do the same for vport 0.

---
 net/netfilter/ipvs/ip_vs_core.c       | 3 ++-
 net/netfilter/ipvs/ip_vs_proto_sctp.c | 5 +++++
 net/netfilter/ipvs/ip_vs_proto_tcp.c  | 5 +++++
 net/netfilter/ipvs/ip_vs_proto_udp.c  | 4 ++++
 4 files changed, 16 insertions(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_core.c +2 -1
index 8a3c880fdb26..f3eb72e95024 100644
@@ -1305,6 +1305,7 @@ static inline bool is_new_conn_expected(const struct ip_vs_conn *cp,
  *    In fwmark-VS actual vaddr and vport are unknown to IPVS
  * 2) Real Server and Virtual Service were NOT configured without port:
  *    This is to allow match of different VS to the same RS ip-addr
+ * 3) Client port is not 0
  */
 struct ip_vs_conn *ip_vs_new_conn_out(struct ip_vs_service *svc,
 				      struct ip_vs_dest *dest,
@@ -1328,7 +1329,7 @@ struct ip_vs_conn *ip_vs_new_conn_out(struct ip_vs_service *svc,
 	/* check pre-requisites are satisfied */
 	if (svc->fwmark)
 		return NULL;
-	if (!vport || !dport)
+	if (!vport || !dport || !cport)
 		return NULL;
 
 	/* for persistent service first create connection template */
net/netfilter/ipvs/ip_vs_proto_sctp.c +5 -0
index fb8af6b15a39..83d1443ebe01 100644
@@ -30,6 +30,7 @@ sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 			sch = skb_header_pointer(skb, iph->len + sizeof(_sctph),
 						 sizeof(_schunkh), &_schunkh);
 			if (sch) {
+				/* Accept packet without scheduling? */
 				if (sch->type == SCTP_CID_ABORT ||
 				    !(sysctl_sloppy_sctp(ipvs) ||
 				      sch->type == SCTP_CID_INIT))
@@ -47,6 +48,10 @@ sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 		return 0;
 	}
 
+	/* Do not create connection for port 0, skip the packet */
+	if (!ports[0] || !ports[1])
+		return 1;
+
 	if (likely(!ip_vs_iph_inverse(iph)))
 		svc = ip_vs_service_find(ipvs, af, skb->mark, iph->protocol,
 					 &iph->daddr, ports[1]);
net/netfilter/ipvs/ip_vs_proto_tcp.c +5 -0
index fec0e8b47b71..2e55b62445c6 100644
@@ -48,6 +48,7 @@ tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 	if (likely(!ip_vs_iph_icmp(iph))) {
 		th = skb_header_pointer(skb, iph->len, sizeof(_tcph), &_tcph);
 		if (th) {
+			/* Accept packet without scheduling? */
 			if (th->rst || !(sysctl_sloppy_tcp(ipvs) || th->syn))
 				return 1;
 			ports = &th->source;
@@ -62,6 +63,10 @@ tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 		return 0;
 	}
 
+	/* Do not create connection for port 0, skip the packet */
+	if (!ports[0] || !ports[1])
+		return 1;
+
 	/* No !th->ack check to allow scheduling on SYN+ACK for Active FTP */
 
 	if (likely(!ip_vs_iph_inverse(iph)))
net/netfilter/ipvs/ip_vs_proto_udp.c +4 -0
index f32785682402..92c0b76c1a02 100644
@@ -52,6 +52,10 @@ udp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 		return 0;
 	}
 
+	/* Do not create connection for port 0, skip the packet */
+	if (!ports[0] || !ports[1])
+		return 1;
+
 	if (likely(!ip_vs_iph_inverse(iph)))
 		svc = ip_vs_service_find(ipvs, af, skb->mark, iph->protocol,
 					 &iph->daddr, ports[1]);
Signature · 1 line
2.47.3
author maintainer
#8 lore raw

PATCH 6/15 netfilter: nf_conntrack: limit expectation master chain depth

In reply to Pablo Neira Ayuso

From: Florian Westphal <[email protected]>

A conntrack can point to a master conntrack, which itself may point to another master, and so on. There is currently no bound on how deep this chain can grow.

Force a max depth in nf_ct_expect_alloc(): walk the master chain and reject allocation if it would exceed 2 levels of nesting.

Also add ctnetlink_find_get_master and use it so that ctnetlink create paths return -EMLINK instead of falling through to nf_ct_expect_alloc() and returning a misleading -ENOMEM.

This prevents unbounded ct->master->master->... chains.

---
 include/net/netfilter/nf_conntrack_helper.h | 15 +++++++++
 net/netfilter/nf_conntrack_expect.c         | 15 +++++++--
 net/netfilter/nf_conntrack_netlink.c        | 36 +++++++++++++++------
 3 files changed, 53 insertions(+), 13 deletions(-)
include/net/netfilter/nf_conntrack_helper.h +15 -0
index 335b8c43694f..617178fd4d8b 100644
@@ -29,6 +29,8 @@ enum nf_ct_helper_flags {
 
 #define NF_CT_HELPER_NAME_LEN	16
 
+#define NF_CT_MAX_EXPECT_CHAIN_LEN	2
+
 /* Must be kept in sync with the classes defined by helpers */
 #define NF_CT_MAX_EXPECT_CLASSES	4
 
@@ -159,6 +161,19 @@ static inline void nf_ct_help_put(const struct nf_conn *ct)
 		kfree_rcu(helper, rcu);
 }
 
+static inline bool nf_ct_master_acceptable(const struct nf_conn *m)
+{
+	unsigned int depth = 0;
+
+	while (m->master) {
+		if (++depth >= NF_CT_MAX_EXPECT_CHAIN_LEN)
+			return false;
+		m = m->master;
+	}
+
+	return true;
+}
+
 int nf_conntrack_helper_init(void);
 void nf_conntrack_helper_fini(void);
 
net/netfilter/nf_conntrack_expect.c +12 -3
index 06242c86e1dc..e9e796bda577 100644
@@ -299,13 +299,22 @@ void nf_ct_unexpect_related(struct nf_conntrack_expect *exp)
 }
 EXPORT_SYMBOL_GPL(nf_ct_unexpect_related);
 
-/* We don't increase the master conntrack refcount for non-fulfilled
- * conntracks. During the conntrack destruction, the expectations are
- * always killed before the conntrack itself */
+/**
+ * nf_ct_expect_alloc - allocate a new conntrack expectation
+ * @me: The conntrack to be used as master.
+ *
+ * The master conntrack refcount is not incremented; expectations
+ * are always killed before the master conntrack is destroyed.
+ *
+ * Returns a new expectation on success or NULL on failure.
+ */
 struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me)
 {
 	struct nf_conntrack_expect *new;
 
+	if (!nf_ct_master_acceptable(me))
+		return NULL;
+
 	new = kmem_cache_zalloc(nf_ct_expect_cachep, GFP_ATOMIC);
 	if (!new)
 		return NULL;
net/netfilter/nf_conntrack_netlink.c +26 -10
index 1f8d94a05240..30428d520e43 100644
@@ -2231,6 +2231,26 @@ ctnetlink_change_conntrack(struct nf_conn *ct,
 	return 0;
 }
 
+static struct nf_conn *
+ctnetlink_find_get_master(struct net *net, const struct nf_conntrack_zone *zone,
+			  const struct nf_conntrack_tuple *tuple)
+{
+	struct nf_conntrack_tuple_hash *master_h;
+	struct nf_conn *master_ct;
+
+	master_h = nf_conntrack_find_get(net, zone, tuple);
+	if (!master_h)
+		return ERR_PTR(-ENOENT);
+
+	master_ct = nf_ct_tuplehash_to_ctrack(master_h);
+	if (!nf_ct_master_acceptable(master_ct)) {
+		nf_ct_put(master_ct);
+		return ERR_PTR(-EMLINK);
+	}
+
+	return master_ct;
+}
+
 static struct nf_conn *
 ctnetlink_create_conntrack(struct net *net,
 			   const struct nf_conntrack_zone *zone,
@@ -2356,7 +2376,6 @@ ctnetlink_create_conntrack(struct net *net,
 	/* setup master conntrack: this is a confirmed expectation */
 	if (cda[CTA_TUPLE_MASTER]) {
 		struct nf_conntrack_tuple master;
-		struct nf_conntrack_tuple_hash *master_h;
 		struct nf_conn *master_ct;
 
 		err = ctnetlink_parse_tuple(cda, &master, CTA_TUPLE_MASTER,
@@ -2364,12 +2383,11 @@ ctnetlink_create_conntrack(struct net *net,
 		if (err < 0)
 			goto err2;
 
-		master_h = nf_conntrack_find_get(net, zone, &master);
-		if (master_h == NULL) {
-			err = -ENOENT;
+		master_ct = ctnetlink_find_get_master(net, zone, &master);
+		if (IS_ERR(master_ct)) {
+			err = PTR_ERR(master_ct);
 			goto err2;
 		}
-		master_ct = nf_ct_tuplehash_to_ctrack(master_h);
 		__set_bit(IPS_EXPECTED_BIT, &ct->status);
 		ct->master = master_ct;
 	}
@@ -3613,7 +3631,6 @@ ctnetlink_create_expect(struct net *net,
 			u_int8_t u3, u32 portid, int report)
 {
 	struct nf_conntrack_tuple tuple, mask, master_tuple;
-	struct nf_conntrack_tuple_hash *h = NULL;
 	struct nf_conntrack_expect *exp;
 	struct nf_conn *ct;
 	int err;
@@ -3633,10 +3650,9 @@ ctnetlink_create_expect(struct net *net,
 		return err;
 
 	/* Look for master conntrack of this expectation */
-	h = nf_conntrack_find_get(net, zone, &master_tuple);
-	if (!h)
-		return -ENOENT;
-	ct = nf_ct_tuplehash_to_ctrack(h);
+	ct = ctnetlink_find_get_master(net, zone, &master_tuple);
+	if (IS_ERR(ct))
+		return PTR_ERR(ct);
 
 	rcu_read_lock();
 	exp = ctnetlink_alloc_expect(cda, ct, NULL, &tuple, &mask);
Signature · 1 line
2.47.3
author maintainer
#9 lore raw

PATCH 7/15 netfilter: nf_dup: preserve guard across NFQUEUE reinjection

In reply to Pablo Neira Ayuso

From: Zihan Xi <[email protected]>

NFQUEUE can suspend traversal of a duplicated packet while the task-local duplication guard is set. The output call then returns and clears the guard before a later verdict resumes hook traversal.

Save the guard in the queue entry and restore it while reinjection continues hook traversal. Preserve and restore the verdict task's prior state, including nested synchronous reinjection.

Fixes cd58bcd9787e ("netfilter: xt_TEE: have cloned packet travel through Xtables too")
Assisted-by LLM
---
 include/net/netfilter/nf_queue.h |  1 +
 net/netfilter/nf_queue.c         |  1 +
 net/netfilter/nfnetlink_queue.c  | 17 ++++++++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)
include/net/netfilter/nf_queue.h +1 -0
index 86021c55ba3c..4a8cefd8398d 100644
@@ -23,6 +23,7 @@ struct nf_queue_entry {
 	struct net_device	*physout;
 #endif
 	struct nf_hook_state	state;
+	bool			in_nf_duplicate;
 	bool			nf_ct_is_unconfirmed;
 	u16			size; /* sizeof(entry) + saved route keys */
 
net/netfilter/nf_queue.c +1 -0
index 166d05e994ac..bd603e3a99a5 100644
@@ -219,6 +219,7 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
 	*entry = (struct nf_queue_entry) {
 		.skb	= skb,
 		.skb_dev = skb->dev,
+		.in_nf_duplicate = current->in_nf_duplicate,
 		.state	= *state,
 		.hook_index = index,
 		.size	= sizeof(*entry) + route_key_size,
net/netfilter/nfnetlink_queue.c +14 -3
index 90d887546f7d..a8aa7ad832c3 100644
@@ -44,6 +44,7 @@
 #include <net/sock.h>
 #include <net/tcp_states.h>
 #include <net/netfilter/nf_queue.h>
+#include <net/net_debug.h>
 #include <net/netns/generic.h>
 
 #include <linux/atomic.h>
@@ -365,21 +366,30 @@ static void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
 	const struct nf_hook_entry *hook_entry;
 	const struct nf_hook_entries *hooks;
 	struct sk_buff *skb = entry->skb;
+	bool old_in_nf_duplicate;
 	const struct net *net;
 	unsigned int i;
 	int err;
 	u8 pf;
 
+	DEBUG_NET_WARN_ONCE(current->in_nf_duplicate &&
+			    !entry->in_nf_duplicate,
+			    "%s called with unexpected duplication guard",
+			    __func__);
+	local_bh_disable();
+	old_in_nf_duplicate = current->in_nf_duplicate;
+
 	net = entry->state.net;
 	pf = entry->state.pf;
 
+	current->in_nf_duplicate = entry->in_nf_duplicate;
 	hooks = nf_hook_entries_head(net, pf, entry->state.hook);
 
 	i = entry->hook_index;
 	if (!hooks || i >= hooks->num_hook_entries) {
 		kfree_skb_reason(skb, SKB_DROP_REASON_NETFILTER_DROP);
 		nf_queue_entry_free(entry);
-		return;
+		goto out;
 	}
 
 	hook_entry = &hooks->hooks[i];
@@ -402,9 +412,7 @@ static void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
 	switch (verdict & NF_VERDICT_MASK) {
 	case NF_ACCEPT:
 	case NF_STOP:
-		local_bh_disable();
 		entry->state.okfn(entry->state.net, entry->state.sk, skb);
-		local_bh_enable();
 		break;
 	case NF_QUEUE:
 		err = nf_queue(skb, &entry->state, i, verdict);
@@ -418,6 +426,9 @@ static void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
 	}
 
 	nf_queue_entry_free(entry);
+out:
+	current->in_nf_duplicate = old_in_nf_duplicate;
+	local_bh_enable();
 }
 
 /* return true if the entry has an unconfirmed conntrack attached that isn't owned by us
Signature · 1 line
2.47.3
author maintainer
#10 lore raw

PATCH 8/15 netfilter: flowtable: extend ct timeout of offloaded GRE flows

In reply to Pablo Neira Ayuso

From: Michail Andreas Michalopoulos <[email protected]>

Since commit 03428ca5cee9 ("netfilter: conntrack: rework offload nf_conn timeout extension logic"), the flowtable gc worker extends the timeout of an offloaded conntrack entry from nf_flow_table_extend_ct_timeout() once it falls below 5 minutes. That function only knows about TCP and UDP and hits WARN_ON_ONCE() for any other layer 4 protocol. However, GRE flows can be offloaded too, both via nft_flow_offload and act_ct, since commit 4e8d9584d154 ("netfilter: flowtable: Support GRE").

The timeout of an offloaded GRE entry drops below that threshold as soon as a packet of the flow still goes through conntrack. With ip6gre tunnels using the default encapsulation limit this is ordinary traffic:
the flowtable does not parse the Destination Options header in front of GRE, so every packet of the flow takes the classic forwarding path. It also happens for a packet with ttl <= 1, which the flowtable fast path passes up to the classic forwarding path. nf_conntrack_gre_packet() then refreshes ct->timeout to the GRE stream timeout (180 seconds by default), and the next gc run triggers, as reported by syzbot:

  WARNING: net/netfilter/nf_flow_table_core.c:553 at nf_flow_table_extend_ct_timeout+0x1ee/0x2f0
  Workqueue: events_power_efficient nf_flow_offload_work_gc
  Call Trace:
   nf_flow_offload_gc_step+0x545/0x7b0
   nf_flow_table_iterate+0x13c/0x1f0
   nf_flow_offload_work_gc+0x22/0x70
   process_scheduled_works+0xc3d/0x1630
   worker_thread+0xa47/0xfb0
   kthread+0x38b/0x480

Besides the splat, which panics the machine with panic_on_warn, the default branch sets the new timeout to 1 jiffy, so the conntrack entry expires right away and the offloaded flow is torn down.

Handle GRE like UDP and extend the timeout to NF_CT_DAY. GRE conntrack has no protocol state to take into account, and NF_CT_DAY is also what flow_offload_add() already sets for every offloaded entry, GRE included. This also restores the behaviour from before commit 03428ca5cee9, when the conntrack gc worker extended offloaded entries of any protocol to NF_CT_DAY.

Fixes 03428ca5cee9 ("netfilter: conntrack: rework offload nf_conn timeout extension logic")
Reported-by [email protected]
Assisted-by LLM
---
 net/netfilter/nf_flow_table_core.c | 1 +
 1 file changed, 1 insertion(+)
net/netfilter/nf_flow_table_core.c +1 -0
index 0d72dc8ae47a..2aa2647ed9df 100644
@@ -544,6 +544,7 @@ static void nf_flow_table_extend_ct_timeout(struct nf_conn *ct)
 
 		switch (l4proto) {
 		case IPPROTO_UDP:
+		case IPPROTO_GRE:
 			new_timeout = NF_CT_DAY;
 			break;
 		case IPPROTO_TCP:
Signature · 1 line
2.47.3
author maintainer
#11 lore raw

PATCH 9/15 netfilter: nft_set_rbtree: check catchall_sync return before queue_done

In reply to Pablo Neira Ayuso

From: Xingyuan Mo <[email protected]>

nft_rbtree_gc_queue() passes the result of nft_trans_gc_catchall_sync() straight to nft_trans_gc_queue_sync_done(). When the catchall path flushes a full GC batch and nft_trans_gc_alloc() fails, catchall_sync returns NULL and queue_sync_done dereferences trans->net (NULL+0x10). Guard the call like the pipapo GC path already does.

Fixes 7d259f021aaa ("netfilter: nft_set_rbtree: prefer sync gc to async worker")
Assisted-by opencode:deepseek-v4
---
 net/netfilter/nft_set_rbtree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nft_set_rbtree.c +2 -1
index fbe1750f1ca2..9d685899da70 100644
@@ -953,7 +953,8 @@ static void nft_rbtree_gc_queue(struct nft_set *set)
 	}
 
 	gc = nft_trans_gc_catchall_sync(gc);
-	nft_trans_gc_queue_sync_done(gc);
+	if (gc)
+		nft_trans_gc_queue_sync_done(gc);
 }
 
 static u64 nft_rbtree_privsize(const struct nlattr * const nla[],
Signature · 1 line
2.47.3
author maintainer
#12 lore raw

PATCH 10/15 netfilter: bridge: use DEBUG_NET_WARN_ON_ONCE in nf_ct_bridge_refrag()

In reply to Pablo Neira Ayuso

From: Laveesh Bansal <[email protected]>

nf_ct_bridge_refrag() warns when skb->protocol is neither IPv4 nor IPv6. A vlan filtering bridge can get there with a vlan ethertype: if the protocol of the tag of a frame differs from the vlan_protocol of the bridge, br_allowed_ingress() moves the tag back into the packet after NF_BR_PRE_ROUTING, where bridge conntrack has already defragmented it.

Anyone who can send fragments into a port of such a bridge can trigger the warning, which takes the machine down with panic_on_warn. The packet is dropped either way, so only warn on kernels built with CONFIG_DEBUG_NET.

This only avoids the warning. Such fragmented packets are still dropped. syzbot reported the warning. It keeps triggering on CONFIG_DEBUG_NET kernels until the vlan tag is handled, which is left for a follow-up:

https://syzkaller.appspot.com/bug?extid=a8ba738fe2db6b4bb27f

Fixes 3c171f496ef5 ("netfilter: bridge: add connection tracking system")
Assisted-by LLM
---
 net/bridge/netfilter/nf_conntrack_bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bridge/netfilter/nf_conntrack_bridge.c +1 -1
index b5444335b86f..8c83dc05114b 100644
@@ -358,7 +358,7 @@ nf_ct_bridge_refrag(struct sk_buff *skb, const struct nf_hook_state *state,
 		nf_br_ip6_fragment(state->net, state->sk, skb, &data, output);
 		break;
 	default:
-		WARN_ON_ONCE(1);
+		DEBUG_NET_WARN_ON_ONCE(1);
 		return NF_DROP;
 	}
 
Signature · 1 line
2.47.3
author maintainer
#13 lore raw

PATCH 11/15 netfilter: x_tables: check target name before accessing verdict

In reply to Pablo Neira Ayuso

From: Fernando Fernandez Mancera <[email protected]>

Non-standard targets may contain only struct xt_entry_target. mark_source_chains() nevertheless reads the target as an xt_standard_target before checking its name, potentially reading four bytes beyond a header-only target.

Check that the target is standard before reading its verdict. Non-standard targets remain handled as fallthrough rules.

See the following KASAN trace:

BUG: KASAN: slab-out-of-bounds in translate_table+0x1660/0x1a40 [ip6_tables]
Read of size 4 at addr ffff88800ed56ff8 by task rep/432

Call Trace:
 kasan_report+0xfa/0x120
 translate_table+0x1660/0x1a40 [ip6_tables]
 do_ip6t_set_ctl+0x667/0xa76 [ip6_tables]
 nf_setsockopt+0x77/0xd0
 do_sock_setsockopt+0x118/0x490
 __sys_setsockopt+0xe4/0x160
 __x64_sys_setsockopt+0xbd/0x190
 do_syscall_64+0xde/0x4f0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Allocated by task 432:
 kasan_save_stack+0x2f/0x50
 __kasan_kmalloc+0x7f/0x90
 __kvmalloc_node_noprof+0x1b1/0x5c0
 xt_alloc_table_info+0x3c/0xa0
 do_ip6t_set_ctl+0x5ee/0xa76 [ip6_tables]
 nf_setsockopt+0x77/0xd0
 do_sock_setsockopt+0x118/0x490
 __sys_setsockopt+0xe4/0x160
 __x64_sys_setsockopt+0xbd/0x190
 do_syscall_64+0xde/0x4f0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 net/ipv4/netfilter/arp_tables.c | 5 +++--
 net/ipv4/netfilter/ip_tables.c  | 5 +++--
 net/ipv6/netfilter/ip6_tables.c | 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)
net/ipv4/netfilter/arp_tables.c +3 -2
index cf747e1e17a3..7ff3d1f0ffd4 100644
@@ -371,11 +371,12 @@ static int mark_source_chains(const struct xt_table_info *newinfo,
 				e->counters.pcnt = pos;
 				pos += size;
 			} else {
-				int newpos = t->verdict;
+				int newpos;
 
 				if (strcmp(t->target.u.user.name,
 					   XT_STANDARD_TARGET) == 0 &&
-				    newpos >= 0) {
+				    t->verdict >= 0) {
+					newpos = t->verdict;
 					/* This a jump; chase it. */
 					if (!xt_find_jump_offset(offsets, newpos,
 								 newinfo->number))
net/ipv4/netfilter/ip_tables.c +3 -2
index 809441cedced..b302bd77180a 100644
@@ -422,11 +422,12 @@ mark_source_chains(const struct xt_table_info *newinfo,
 				e->counters.pcnt = pos;
 				pos += size;
 			} else {
-				int newpos = t->verdict;
+				int newpos;
 
 				if (strcmp(t->target.u.user.name,
 					   XT_STANDARD_TARGET) == 0 &&
-				    newpos >= 0) {
+				    t->verdict >= 0) {
+					newpos = t->verdict;
 					/* This a jump; chase it. */
 					if (!xt_find_jump_offset(offsets, newpos,
 								 newinfo->number))
net/ipv6/netfilter/ip6_tables.c +3 -2
index 313c4aac377a..010baaa60665 100644
@@ -440,11 +440,12 @@ mark_source_chains(const struct xt_table_info *newinfo,
 				e->counters.pcnt = pos;
 				pos += size;
 			} else {
-				int newpos = t->verdict;
+				int newpos;
 
 				if (strcmp(t->target.u.user.name,
 					   XT_STANDARD_TARGET) == 0 &&
-				    newpos >= 0) {
+				    t->verdict >= 0) {
+					newpos = t->verdict;
 					/* This a jump; chase it. */
 					if (!xt_find_jump_offset(offsets, newpos,
 								 newinfo->number))
Signature · 1 line
2.47.3
author maintainer
#14 lore raw

PATCH 12/15 netfilter: nf_conntrack_sip: fix OOB read in ct_sip_parse_transport()

In reply to Pablo Neira Ayuso

From: Joas Antonio dos Santos <[email protected]>

ct_sip_parse_transport() compares the value of the "transport=" header parameter against "TCP"/"UDP" with strncasecmp(..., 3), but it never checks that the parsed value is at least 3 bytes long.

ct_sip_parse_param() returns matchlen = end - start, where end is the next ';' or, when there is no ';', the end of the payload buffer (limit = dptr + datalen). If the "transport=" value is only 1 or 2 bytes long and runs exactly to the end of the payload (e.g. a REGISTER request whose Contact header ends in ";transport=T" with no trailing CRLF), matchlen is less than 3 while strncasecmp() still reads up to 3 bytes, reading 1-2 bytes past the end of the linearized skb data.

Add a matchlen check before the comparison, mirroring the sdp_media_type() pattern a few lines below, so short values cannot reach strncasecmp().

The bug was found by LLM-assisted manual review of the SIP helper's parsers and confirmed with a userspace ASan harness built from the verbatim parser functions, which reports a heap-buffer-overflow read of size 2 in strncasecmp() called from ct_sip_parse_transport().

Fixes ea45f12a2766d ("[NETFILTER]: nf_conntrack_sip: parse SIP headers properly")
Assisted-by Claude:claude-opus-5-5
---
 net/netfilter/nf_conntrack_sip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_sip.c +2 -2
index 64bc440b1181..b05dc8858d09 100644
@@ -701,9 +701,9 @@ static int ct_sip_parse_transport(struct nf_conn *ct, const char *dptr,
 
 	if (ct_sip_parse_param(ct, dptr, dataoff, datalen, "transport=",
 			       &matchoff, &matchlen)) {
-		if (!strncasecmp(dptr + matchoff, "TCP", strlen("TCP")))
+		if (matchlen >= 3 && !strncasecmp(dptr + matchoff, "TCP", 3))
 			*proto = IPPROTO_TCP;
-		else if (!strncasecmp(dptr + matchoff, "UDP", strlen("UDP")))
+		else if (matchlen >= 3 && !strncasecmp(dptr + matchoff, "UDP", 3))
 			*proto = IPPROTO_UDP;
 		else
 			return 0;
Signature · 1 line
2.47.3
author maintainer
#15 lore raw

PATCH 13/15 netfilter: nf_tables: fix memleak when rule deletion fails with hardware offload

In reply to Pablo Neira Ayuso

Allocate flow rule object after transaction has been allocation and rule deactivation has been performed, otherwise memleak is possible. Let the transaction unwind the existing rule deactivation from the abort path, this needs to update nft_flow_rule_destroy() to skip release if flow_rule is null.

While at this, remove check for non-null flow_rule in newrule error path now that nft_flow_rule_destroy() is skipped if flow_rule is null.

Fixes 63b48c73ff56 ("netfilter: nf_tables_offload: undo updates if transaction fails")
---
 net/netfilter/nf_tables_api.c     | 21 +++++++++------------
 net/netfilter/nf_tables_offload.c |  3 +++
 2 files changed, 12 insertions(+), 12 deletions(-)
net/netfilter/nf_tables_api.c +9 -12
index 59ac623e6805..8b94b5e7dbdb 100644
@@ -760,16 +760,6 @@ static int nft_delrule(struct nft_ctx *ctx, struct nft_rule *rule)
 	if (trans == NULL)
 		return -ENOMEM;
 
-	if (ctx->chain->flags & NFT_CHAIN_HW_OFFLOAD) {
-		flow = nft_flow_rule_create(ctx->net, rule);
-		if (IS_ERR(flow)) {
-			nft_trans_destroy(trans);
-			return PTR_ERR(flow);
-		}
-
-		nft_trans_flow_rule(trans) = flow;
-	}
-
 	err = nf_tables_delrule_deactivate(ctx, rule);
 	if (err < 0) {
 		nft_trans_destroy(trans);
@@ -777,6 +767,14 @@ static int nft_delrule(struct nft_ctx *ctx, struct nft_rule *rule)
 	}
 	nft_rule_expr_deactivate(ctx, rule, NFT_TRANS_PREPARE);
 
+	if (ctx->chain->flags & NFT_CHAIN_HW_OFFLOAD) {
+		flow = nft_flow_rule_create(ctx->net, rule);
+		if (IS_ERR(flow))
+			return PTR_ERR(flow);
+
+		nft_trans_flow_rule(trans) = flow;
+	}
+
 	return 0;
 }
 
@@ -4570,8 +4568,7 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
 err_destroy_flow_rule:
 	nft_use_dec_restore(&chain->use);
 err_destroy_flow:
-	if (flow)
-		nft_flow_rule_destroy(flow);
+	nft_flow_rule_destroy(flow);
 err_release_rule:
 	nft_rule_expr_deactivate(&ctx, rule, NFT_TRANS_PREPARE_ERROR);
 	nf_tables_rule_destroy(&ctx, rule);
net/netfilter/nf_tables_offload.c +3 -0
index 0ac3c26dfb3d..48b9e58e0c44 100644
@@ -148,6 +148,9 @@ void nft_flow_rule_destroy(struct nft_flow_rule *flow)
 	struct flow_action_entry *entry;
 	int i;
 
+	if (!flow)
+		return;
+
 	flow_action_for_each(i, entry, &flow->rule->action) {
 		switch (entry->id) {
 		case FLOW_ACTION_REDIRECT:
Signature · 1 line
2.47.3
author maintainer
#16 lore raw

PATCH 14/15 netfilter: xt_recent: do not call remove_proc_entry() under recent_lock

In reply to Pablo Neira Ayuso

From: "Cen Zhang (Microsoft)" <[email protected]>

recent_proc_net_exit() removes the /proc/net/xt_recent/<name> entries of a dying network namespace while holding spin_lock_bh(&recent_lock). remove_proc_entry() may sleep: proc_entry_rundown() waits until every task that is still inside the entry's file operations has left. A reader of such an entry is counted in by proc_reg_read() before recent_seq_start() takes recent_lock. So if a read is in flight when the namespace is torn down, cleanup_net() sleeps in atomic context holding the spinlock that the reader is spinning on, and neither side can ever make progress.

An unprivileged user can trigger this from a user namespace by adding a rule with the "recent" match and reading its proc file while the namespace is being destroyed. As recent_lock is global, every later attempt to take it spins forever too: the spinning can spread to all CPUs, and network namespace teardown stops system-wide.

  BUG: sleeping function called from invalid context at
    kernel/sched/completion.c:116
   #3: (recent_lock){+...}-{3:3}, at: recent_net_exit+0x2b/0x140
  Workqueue: netns cleanup_net
  Call Trace:
   proc_entry_rundown+0x185/0x1b0
   remove_proc_entry+0x21a/0x520
   recent_net_exit+0x7f/0x140
   cleanup_net+0x414/0x8f0
  ...
  rcu: INFO: rcu_preempt self-detected stall on CPU
  Call Trace:
   queued_spin_lock_slowpath+0x313/0xc20
   recent_seq_start+0x87/0x1b0
   seq_read_iter+0x265/0x11e0
   proc_reg_read+0x1ab/0x270

Fix by taking recent_mutex instead of recent_lock. According to commit a0e889bb1bdc ("[NETFILTER]: recent match: fix "sleeping function called from invalid context""), recent_mutex is the lock to use here: it protects recent_net->tables and was introduced so that proc entries are created and removed without recent_lock held, because those calls may sleep. hashlimit_proc_net_exit() does the same for xt_hashlimit.

Fixes 665e205c16c1 ("netfilter: xt_recent: fix namespace destroy path")
---
 net/netfilter/xt_recent.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/netfilter/xt_recent.c +4 -3
index 55f1f2d89952..00cccf003cff 100644
@@ -650,14 +650,15 @@ static void __net_exit recent_proc_net_exit(struct net *net)
 
 	/* recent_net_exit() is called before recent_mt_destroy(). Make sure
 	 * that the parent xt_recent proc entry is empty before trying to
-	 * remove it.
+	 * remove it. Use recent_mutex instead of recent_lock since
+	 * remove_proc_entry() may sleep.
 	 */
-	spin_lock_bh(&recent_lock);
+	mutex_lock(&recent_mutex);
 	list_for_each_entry(t, &recent_net->tables, list)
 	        remove_proc_entry(t->name, recent_net->xt_recent);
 
 	recent_net->xt_recent = NULL;
-	spin_unlock_bh(&recent_lock);
+	mutex_unlock(&recent_mutex);
 
 	remove_proc_entry("xt_recent", net->proc_net);
 }
Signature · 1 line
2.47.3
author maintainer
#17 lore raw

PATCH 15/15 netfilter: nat: zero newrange before filling it in

In reply to Pablo Neira Ayuso

From: Florian Westphal <[email protected]>

nf_nat_masquerade_ipv4(), nf_nat_masquerade_ipv6(), netmap_tg4() and netmap_tg6() each build a stack-local struct nf_nat_range2 from the caller-supplied range, inheriting range->flags unmodified. Two of them only memset() the min_addr/max_addr members, the other two don't memset() anything at all, so newrange.base_proto is left as stack garbage.

If the inherited flags include NF_NAT_RANGE_PROTO_OFFSET, nf_nat_l4proto_unique_tuple() reads range->base_proto.all to compute the NAT port offset. Neither the NETMAP nor the MASQUERADE targets mask the flags field in their checkentry callback, so this uninitialized stack value can end up feeding the NAT port selection.

The per-member memset()s are not enough: they have to enumerate every field that must be cleared, and base_proto was missed when NF_NAT_RANGE_PROTO_OFFSET/base_proto was added to the struct. memset() the whole struct instead, so every member is covered regardless of which ones get explicitly assigned afterwards.

There are other places that miss this, but those hardcode .flags so nat core won't read from the uninitialized fields.

C99 initializers would be preferrable, but this is a more intrusive change. Lets followup in nf-next and convert others as well.

This is an LLM finding.

Fixes 2eb0f624b709 ("netfilter: add NAT support for shifted portmap ranges")
---
 net/netfilter/nf_nat_masquerade.c | 4 ++--
 net/netfilter/xt_NETMAP.c         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_nat_masquerade.c +2 -2
index 4de6e0a51701..c2a85bd84af1 100644
@@ -62,8 +62,7 @@ nf_nat_masquerade_ipv4(struct sk_buff *skb, unsigned int hooknum,
 		nat->masq_index = out->ifindex;
 
 	/* Transfer from original range. */
-	memset(&newrange.min_addr, 0, sizeof(newrange.min_addr));
-	memset(&newrange.max_addr, 0, sizeof(newrange.max_addr));
+	memset(&newrange, 0, sizeof(newrange));
 	newrange.flags       = range->flags | NF_NAT_RANGE_MAP_IPS;
 	newrange.min_addr.ip = newsrc;
 	newrange.max_addr.ip = newsrc;
@@ -242,6 +241,7 @@ nf_nat_masquerade_ipv6(struct sk_buff *skb, const struct nf_nat_range2 *range,
 	if (nat)
 		nat->masq_index = out->ifindex;
 
+	memset(&newrange, 0, sizeof(newrange));
 	newrange.flags		= range->flags | NF_NAT_RANGE_MAP_IPS;
 	newrange.min_addr.in6	= src;
 	newrange.max_addr.in6	= src;
net/netfilter/xt_NETMAP.c +2 -2
index 7da065a472e0..8bcb3f716d68 100644
@@ -44,6 +44,7 @@ netmap_tg6(struct sk_buff *skb, const struct xt_action_param *par)
 				   netmask.ip6[i];
 	}
 
+	memset(&newrange, 0, sizeof(newrange));
 	newrange.flags	= range->flags | NF_NAT_RANGE_MAP_IPS;
 	newrange.min_addr	= new_addr;
 	newrange.max_addr	= new_addr;
@@ -91,8 +92,7 @@ netmap_tg4(struct sk_buff *skb, const struct xt_action_param *par)
 		new_ip = ip_hdr(skb)->saddr & ~netmask;
 	new_ip |= mr->range[0].min_ip & netmask;
 
-	memset(&newrange.min_addr, 0, sizeof(newrange.min_addr));
-	memset(&newrange.max_addr, 0, sizeof(newrange.max_addr));
+	memset(&newrange, 0, sizeof(newrange));
 	newrange.flags	     = mr->range[0].flags | NF_NAT_RANGE_MAP_IPS;
 	newrange.min_addr.ip = new_ip;
 	newrange.max_addr.ip = new_ip;
Signature · 1 line
2.47.3
maintainer
#18 lore raw
In reply to Pablo Neira Ayuso
Quoted 47 lines · Pablo Neira Ayuso

Hi,

The following batch contains Netfilter/IPVS fixes for net:

1) Add recursion count to nf_reject infrastructure to prevent stack overflow, from Fernando F. Mancera.

2) Address a infinite loop in RCU list traversal with the TWOS IPVS scheduler, from Darong Lu and Julian Anastasov.

3) Use kfree_rcu() to release IPVS parent application to fix UaF, from Chengfeng Ye.

4) Fix UaF in IPVS netns removal path due to releasing per-net protocol data too early, from Chengfeng Ye.

5) Fix unbounded growth of stale, unmatchable IPVS connection entries, from Julian Anastasov.

6) Restrict maximum master conntrack chain depth in ctnetlink, from Florian Westphal.

7) Preserve recursion count on nfqueue reinjection, from Zihan Xi.

8) Restore GRE timeout in the flowtable, otherwise, WARN_ON_ONCE() is reachable, from Michail Andreas Michalopoulos.

9) Check non-null gc transaction in nft_rbtree before queuing it for processing, from Xingyuan Mo.

10) Replace WARN_ON_ONCE() by DEBUG_NET_WARN_ON_ONCE() in nf_conntrack_bridge which is reachable if the protocol of the tag of a frame differs from the vlan_protocol of the bridge. From Laveesh Bansal.

11) Check x_tables target name is non-null before accessing it when building a new table, from Fernando F. Mancera.

12) Fix out-of-bound memory read in nf_conntrack_sip, from Joas Antonio Dos Santos.

13) Fix a memleak in nf_tables hardware offload when double deleting the same rule, in the same batch.

14) Use a mutex in xt_recent netns exit path instead of spinlock, since proc unregistration might sleep. From Cen Zhang.

Quoted 7 lines

15) Zero the nf_nat_range2 struct before filling it up, to avoid using stale uninitialized stack data to configure NAT with an esoteric NAT flags combination. From Florian Westphal.

Please, pull these changes from:

   git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-26-11-02

I'm sorry, but something went very wrong on the nipa side: the tools did not pick this PR. Do you mind repost it verbatim?

Thank you!

Paolo

#19 lore raw

Hi Paolo, Pablo,

Quoted 52 lines · Paolo Abeni
Quoted 51 lines · Pablo Neira Ayuso

Hi,

The following batch contains Netfilter/IPVS fixes for net:

1) Add recursion count to nf_reject infrastructure to prevent stack overflow, from Fernando F. Mancera.

2) Address a infinite loop in RCU list traversal with the TWOS IPVS scheduler, from Darong Lu and Julian Anastasov.

3) Use kfree_rcu() to release IPVS parent application to fix UaF, from Chengfeng Ye.

4) Fix UaF in IPVS netns removal path due to releasing per-net protocol data too early, from Chengfeng Ye.

5) Fix unbounded growth of stale, unmatchable IPVS connection entries, from Julian Anastasov.

6) Restrict maximum master conntrack chain depth in ctnetlink, from Florian Westphal.

7) Preserve recursion count on nfqueue reinjection, from Zihan Xi.

8) Restore GRE timeout in the flowtable, otherwise, WARN_ON_ONCE() is reachable, from Michail Andreas Michalopoulos.

9) Check non-null gc transaction in nft_rbtree before queuing it for processing, from Xingyuan Mo.

10) Replace WARN_ON_ONCE() by DEBUG_NET_WARN_ON_ONCE() in nf_conntrack_bridge which is reachable if the protocol of the tag of a frame differs from the vlan_protocol of the bridge. From Laveesh Bansal.

11) Check x_tables target name is non-null before accessing it when building a new table, from Fernando F. Mancera.

12) Fix out-of-bound memory read in nf_conntrack_sip, from Joas Antonio Dos Santos.

13) Fix a memleak in nf_tables hardware offload when double deleting the same rule, in the same batch.

14) Use a mutex in xt_recent netns exit path instead of spinlock, since proc unregistration might sleep. From Cen Zhang.

15) Zero the nf_nat_range2 struct before filling it up, to avoid using stale uninitialized stack data to configure NAT with an esoteric NAT flags combination. From Florian Westphal.

Quoted 6 lines
Quoted 4 lines

Please, pull these changes from:

   git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git
nf-26-11-02

I'm sorry, but something went very wrong on the nipa side: the tools did not pick this PR. Do you mind repost it verbatim?

It looks like the patches have not been tested, because of the kdoc issue on patch 6/15:

https://netdev-ctrl.bots.linux.dev/logview.html?f=/logs/build/1198360/14931104/kdoc/stdout

I guess this will need to be fixed in the v2. If it is a false positive, please ping me.

Cheers,
Matt

author maintainer
#21 lore raw
Quoted 10 lines · Florian Westphal
Quoted 7 lines · Matthieu Baerts

It looks like the patches have not been tested, because of the kdoc issue on patch 6/15:

https://netdev-ctrl.bots.linux.dev/logview.html?f=/logs/build/1198360/14931104/kdoc/stdout

I guess this will need to be fixed in the v2. If it is a false positive, please ping me.

The only effect this test has is that I will stop making kdoc comments.

For the record, I have restored the original comment here to please the robot.

#22 lore raw
In reply to Florian Westphal

Hi Florian,

Quoted 11 lines · Florian Westphal
Quoted 8 lines · Matthieu Baerts

It looks like the patches have not been tested, because of the kdoc issue on patch 6/15:

https://netdev-ctrl.bots.linux.dev/logview.html?f=/logs/build/1198360/14931104/kdoc/stdout

I guess this will need to be fixed in the v2. If it is a false positive, please ping me.

The only effect this test has is that I will stop making kdoc comments.

Yeah, same on MPTCP side after I got bitten once by that. But then I realised checking for errors was very quick, and I added a check on our CI side.

./scripts/kernel-doc -Werror -Wall -none <directories/files>

I guess this check has been added to avoid all these small patches just fixing kdoc warnings :-/

Cheers,
Matt

author maintainer
#23 lore raw
In reply to Matthieu Baerts
Quoted 59 lines · Matthieu Baerts

Hi Paolo, Pablo,

Quoted 56 lines · Paolo Abeni
Quoted 55 lines · Pablo Neira Ayuso

Hi,

The following batch contains Netfilter/IPVS fixes for net:

1) Add recursion count to nf_reject infrastructure to prevent stack overflow, from Fernando F. Mancera.

2) Address a infinite loop in RCU list traversal with the TWOS IPVS scheduler, from Darong Lu and Julian Anastasov.

3) Use kfree_rcu() to release IPVS parent application to fix UaF, from Chengfeng Ye.

4) Fix UaF in IPVS netns removal path due to releasing per-net protocol data too early, from Chengfeng Ye.

5) Fix unbounded growth of stale, unmatchable IPVS connection entries, from Julian Anastasov.

6) Restrict maximum master conntrack chain depth in ctnetlink, from Florian Westphal.

7) Preserve recursion count on nfqueue reinjection, from Zihan Xi.

8) Restore GRE timeout in the flowtable, otherwise, WARN_ON_ONCE() is reachable, from Michail Andreas Michalopoulos.

9) Check non-null gc transaction in nft_rbtree before queuing it for processing, from Xingyuan Mo.

10) Replace WARN_ON_ONCE() by DEBUG_NET_WARN_ON_ONCE() in nf_conntrack_bridge which is reachable if the protocol of the tag of a frame differs from the vlan_protocol of the bridge. From Laveesh Bansal.

11) Check x_tables target name is non-null before accessing it when building a new table, from Fernando F. Mancera.

12) Fix out-of-bound memory read in nf_conntrack_sip, from Joas Antonio Dos Santos.

13) Fix a memleak in nf_tables hardware offload when double deleting the same rule, in the same batch.

14) Use a mutex in xt_recent netns exit path instead of spinlock, since proc unregistration might sleep. From Cen Zhang.

15) Zero the nf_nat_range2 struct before filling it up, to avoid using stale uninitialized stack data to configure NAT with an esoteric NAT flags combination. From Florian Westphal.

Please, pull these changes from:

   git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git
nf-26-11-02

Quoted 7 lines
Quoted 2 lines

I'm sorry, but something went very wrong on the nipa side: the tools did not pick this PR. Do you mind repost it verbatim?

It looks like the patches have not been tested, because of the kdoc issue on patch 6/15:

https://netdev-ctrl.bots.linux.dev/logview.html?f=/logs/build/1198360/14931104/kdoc/stdout

I routinely run checkpath.pl, I will re-check what happened here.

author maintainer
#24 lore raw
Quoted 63 lines · Pablo Neira Ayuso
Quoted 62 lines · Matthieu Baerts

Hi Paolo, Pablo,

Quoted 58 lines · Paolo Abeni
Quoted 47 lines · Pablo Neira Ayuso

Hi,

The following batch contains Netfilter/IPVS fixes for net:

1) Add recursion count to nf_reject infrastructure to prevent stack overflow, from Fernando F. Mancera.

2) Address a infinite loop in RCU list traversal with the TWOS IPVS scheduler, from Darong Lu and Julian Anastasov.

3) Use kfree_rcu() to release IPVS parent application to fix UaF, from Chengfeng Ye.

4) Fix UaF in IPVS netns removal path due to releasing per-net protocol data too early, from Chengfeng Ye.

5) Fix unbounded growth of stale, unmatchable IPVS connection entries, from Julian Anastasov.

6) Restrict maximum master conntrack chain depth in ctnetlink, from Florian Westphal.

7) Preserve recursion count on nfqueue reinjection, from Zihan Xi.

8) Restore GRE timeout in the flowtable, otherwise, WARN_ON_ONCE() is reachable, from Michail Andreas Michalopoulos.

9) Check non-null gc transaction in nft_rbtree before queuing it for processing, from Xingyuan Mo.

10) Replace WARN_ON_ONCE() by DEBUG_NET_WARN_ON_ONCE() in nf_conntrack_bridge which is reachable if the protocol of the tag of a frame differs from the vlan_protocol of the bridge. From Laveesh Bansal.

11) Check x_tables target name is non-null before accessing it when building a new table, from Fernando F. Mancera.

12) Fix out-of-bound memory read in nf_conntrack_sip, from Joas Antonio Dos Santos.

13) Fix a memleak in nf_tables hardware offload when double deleting the same rule, in the same batch.

14) Use a mutex in xt_recent netns exit path instead of spinlock, since proc unregistration might sleep. From Cen Zhang.

Quoted 8 lines

15) Zero the nf_nat_range2 struct before filling it up, to avoid using stale uninitialized stack data to configure NAT with an esoteric NAT flags combination. From Florian Westphal.

Please, pull these changes from:

   git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git
nf-26-11-02

I'm sorry, but something went very wrong on the nipa side: the tools did not pick this PR. Do you mind repost it verbatim?

Quoted 6 lines
Quoted 4 lines

It looks like the patches have not been tested, because of the kdoc issue on patch 6/15:

https://netdev-ctrl.bots.linux.dev/logview.html?f=/logs/build/1198360/14931104/kdoc/stdout

I routinely run checkpath.pl, I will re-check what happened here.

Well, here I have a script that contains checkpatch.pl and the following call as well:

$ scripts/kernel-doc -none net/netfilter/nf_conntrack_expect.c

but it shows nothing here.

#25 lore raw

Hi Pablo,

Quoted 69 lines · Pablo Neira Ayuso
Quoted 68 lines · Pablo Neira Ayuso
Quoted 66 lines · Matthieu Baerts

Hi Paolo, Pablo,

Quoted 52 lines · Paolo Abeni
Quoted 51 lines · Pablo Neira Ayuso

Hi,

The following batch contains Netfilter/IPVS fixes for net:

1) Add recursion count to nf_reject infrastructure to prevent stack overflow, from Fernando F. Mancera.

2) Address a infinite loop in RCU list traversal with the TWOS IPVS scheduler, from Darong Lu and Julian Anastasov.

3) Use kfree_rcu() to release IPVS parent application to fix UaF, from Chengfeng Ye.

4) Fix UaF in IPVS netns removal path due to releasing per-net protocol data too early, from Chengfeng Ye.

5) Fix unbounded growth of stale, unmatchable IPVS connection entries, from Julian Anastasov.

6) Restrict maximum master conntrack chain depth in ctnetlink, from Florian Westphal.

7) Preserve recursion count on nfqueue reinjection, from Zihan Xi.

8) Restore GRE timeout in the flowtable, otherwise, WARN_ON_ONCE() is reachable, from Michail Andreas Michalopoulos.

9) Check non-null gc transaction in nft_rbtree before queuing it for processing, from Xingyuan Mo.

10) Replace WARN_ON_ONCE() by DEBUG_NET_WARN_ON_ONCE() in nf_conntrack_bridge which is reachable if the protocol of the tag of a frame differs from the vlan_protocol of the bridge. From Laveesh Bansal.

11) Check x_tables target name is non-null before accessing it when building a new table, from Fernando F. Mancera.

12) Fix out-of-bound memory read in nf_conntrack_sip, from Joas Antonio Dos Santos.

13) Fix a memleak in nf_tables hardware offload when double deleting the same rule, in the same batch.

14) Use a mutex in xt_recent netns exit path instead of spinlock, since proc unregistration might sleep. From Cen Zhang.

15) Zero the nf_nat_range2 struct before filling it up, to avoid using stale uninitialized stack data to configure NAT with an esoteric NAT flags combination. From Florian Westphal.

Quoted 6 lines
Quoted 4 lines

Please, pull these changes from:

   git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git
nf-26-11-02

I'm sorry, but something went very wrong on the nipa side: the tools did not pick this PR. Do you mind repost it verbatim?

It looks like the patches have not been tested, because of the kdoc issue on patch 6/15:

https://netdev-ctrl.bots.linux.dev/logview.html?f=/logs/build/1198360/14931104/kdoc/stdout

Quoted 8 lines
Quoted 1 line

I routinely run checkpath.pl, I will re-check what happened here.

Well, here I have a script that contains checkpatch.pl and the following call as well:

$ scripts/kernel-doc -none net/netfilter/nf_conntrack_expect.c

but it shows nothing here.

NIPA uses "-Wall". With it, we can see the issue:

  $ scripts/kernel-doc -Wall -none net/netfilter/nf_conntrack_expect.c
  Warning: net/netfilter/nf_conntrack_expect.c:311 No description found for return value of 'nf_ct_expect_alloc'
  Warning: net/netfilter/nf_conntrack_expect.c:311 No description found for return value of 'nf_ct_expect_alloc'

(And with -Werror, the script returns a non-zero RC code.)

Cheers,
Matt