Commit 2b4a32da authored by Paolo Abeni's avatar Paolo Abeni

Merge tag 'nf-24-07-31' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf

Pablo Neira Ayuso says:

====================
Netfilter fixes for net

The following patchset contains Netfilter fixes for net:

Fix a possible null-ptr-deref sometimes triggered by iptables-restore at
boot time. Register iptables {ipv4,ipv6} nat table pernet in first place
to fix this issue. Patch #1 and #2 from Kuniyuki Iwashima.

netfilter pull request 24-07-31

* tag 'nf-24-07-31' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf:
  netfilter: iptables: Fix potential null-ptr-deref in ip6table_nat_table_init().
  netfilter: iptables: Fix null-ptr-deref in iptable_nat_table_init().
====================

Link: https://patch.msgid.link/20240731213046.6194-1-pablo@netfilter.orgSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents a46c68de c22921df
...@@ -145,25 +145,27 @@ static struct pernet_operations iptable_nat_net_ops = { ...@@ -145,25 +145,27 @@ static struct pernet_operations iptable_nat_net_ops = {
static int __init iptable_nat_init(void) static int __init iptable_nat_init(void)
{ {
int ret = xt_register_template(&nf_nat_ipv4_table, int ret;
iptable_nat_table_init);
/* net->gen->ptr[iptable_nat_net_id] must be allocated
* before calling iptable_nat_table_init().
*/
ret = register_pernet_subsys(&iptable_nat_net_ops);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = register_pernet_subsys(&iptable_nat_net_ops); ret = xt_register_template(&nf_nat_ipv4_table,
if (ret < 0) { iptable_nat_table_init);
xt_unregister_template(&nf_nat_ipv4_table); if (ret < 0)
return ret; unregister_pernet_subsys(&iptable_nat_net_ops);
}
return ret; return ret;
} }
static void __exit iptable_nat_exit(void) static void __exit iptable_nat_exit(void)
{ {
unregister_pernet_subsys(&iptable_nat_net_ops);
xt_unregister_template(&nf_nat_ipv4_table); xt_unregister_template(&nf_nat_ipv4_table);
unregister_pernet_subsys(&iptable_nat_net_ops);
} }
module_init(iptable_nat_init); module_init(iptable_nat_init);
......
...@@ -147,23 +147,27 @@ static struct pernet_operations ip6table_nat_net_ops = { ...@@ -147,23 +147,27 @@ static struct pernet_operations ip6table_nat_net_ops = {
static int __init ip6table_nat_init(void) static int __init ip6table_nat_init(void)
{ {
int ret = xt_register_template(&nf_nat_ipv6_table, int ret;
ip6table_nat_table_init);
/* net->gen->ptr[ip6table_nat_net_id] must be allocated
* before calling ip6t_nat_register_lookups().
*/
ret = register_pernet_subsys(&ip6table_nat_net_ops);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = register_pernet_subsys(&ip6table_nat_net_ops); ret = xt_register_template(&nf_nat_ipv6_table,
ip6table_nat_table_init);
if (ret) if (ret)
xt_unregister_template(&nf_nat_ipv6_table); unregister_pernet_subsys(&ip6table_nat_net_ops);
return ret; return ret;
} }
static void __exit ip6table_nat_exit(void) static void __exit ip6table_nat_exit(void)
{ {
unregister_pernet_subsys(&ip6table_nat_net_ops);
xt_unregister_template(&nf_nat_ipv6_table); xt_unregister_template(&nf_nat_ipv6_table);
unregister_pernet_subsys(&ip6table_nat_net_ops);
} }
module_init(ip6table_nat_init); module_init(ip6table_nat_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment