Messages in this thread Patch in this message |  | | From | Tristan Madani <> | | Subject | [PATCH v2 1/2] netfilter: ip_tables: guard ipt_unregister_table_pre_exit against NULL ops | | Date | Wed, 29 Apr 2026 23:19:03 -0000 |
| |
ipt_register_table() adds the table to the per-netns list via xt_register_table() before assigning the per-net ops copy to new_table->ops. If cleanup_net runs during this window, ipt_unregister_table_pre_exit() finds the table via xt_find_table() and passes the NULL ops pointer to nf_unregister_net_hooks(), causing a general protection fault.
Guard against this by checking table->ops before calling nf_unregister_net_hooks(). If ops is NULL the table is still being set up; the register path will either complete and register the hooks normally, or fail and clean up via __ipt_unregister_table().
Fixes: ae689334225f ("netfilter: xtables: Bring back xt_register_table()") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani <tristan@talencesecurity.com> --- net/ipv4/netfilter/ip_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index XXXXXXX..XXXXXXX 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1795,7 +1795,7 @@ void ipt_unregister_table_pre_exit(struct net *net, const char *name) { struct xt_table *table = xt_find_table(net, NFPROTO_IPV4, name);
- if (table) + if (table && table->ops) nf_unregister_net_hooks(net, table->ops, hweight32(table->valid_hooks)); }
|  |