public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] netfilter: fix NULL ops race in iptable lazy init
@ 2026-04-29 17:56 Tristan Madani
  2026-04-29 17:56 ` [PATCH 1/2] netfilter: ip_tables: allocate hook ops before making table visible Tristan Madani
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Tristan Madani @ 2026-04-29 17:56 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Florian Westphal, Phil Sutter, netfilter-devel, netdev, stable,
	linux-kernel, Tristan Madani

From: Tristan Madani <tristan@talencesecurity.com>

ipt_register_table() and ip6t_register_table() call xt_register_table()
which adds the new table to the per-netns list, making it visible to
other code paths.  Only afterwards do they allocate the per-net copy of
hook ops via kmemdup_array().  This leaves a window where the table is
findable via xt_find_table() but has ops=NULL.

If cleanup_net runs during this window (racing namespace teardown against
lazy table init), ipt_unregister_table_pre_exit() /
ip6t_unregister_table_pre_exit() finds the table and passes the NULL ops
pointer to nf_unregister_net_hooks(), causing a general protection fault.

Fix both ip_tables.c and ip6_tables.c by moving the ops allocation
before xt_register_table(), so the table is never in the list with a
NULL ops pointer.

Tristan Madani (2):
  netfilter: ip_tables: allocate hook ops before making table visible
  netfilter: ip6_tables: allocate hook ops before making table visible

 net/ipv4/netfilter/ip_tables.c  | 31 ++++++++++++++++---------------
 net/ipv6/netfilter/ip6_tables.c | 28 ++++++++++++++++------------
 2 files changed, 32 insertions(+), 27 deletions(-)

-- 
2.47.3

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-05-01 22:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 17:56 [PATCH 0/2] netfilter: fix NULL ops race in iptable lazy init Tristan Madani
2026-04-29 17:56 ` [PATCH 1/2] netfilter: ip_tables: allocate hook ops before making table visible Tristan Madani
2026-04-29 17:56 ` [PATCH 2/2] netfilter: ip6_tables: " Tristan Madani
2026-04-29 18:17 ` [PATCH 0/2] netfilter: fix NULL ops race in iptable lazy init Phil Sutter
2026-04-29 21:03 ` Tristan Madani
2026-04-29 23:18 ` [PATCH v2 0/2] netfilter: fix NULL ops dereference " Tristan Madani
2026-04-29 23:19   ` [PATCH v2 1/2] netfilter: ip_tables: guard ipt_unregister_table_pre_exit against NULL ops Tristan Madani
2026-04-30 13:27     ` Florian Westphal
2026-04-30 21:49       ` Tristan Madani
2026-04-30 22:16         ` Florian Westphal
2026-05-01 20:41           ` Tristan Madani
2026-05-01 22:00             ` Florian Westphal
2026-04-29 23:19   ` [PATCH v2 2/2] netfilter: ip6_tables: guard ip6t_unregister_table_pre_exit " Tristan Madani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox