* [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference.
@ 2020-06-22 17:10 David Wilder
2020-06-22 17:10 ` [PATCH v1 1/4] netfilter: Split ipt_unregister_table() into pre_exit and exit helpers David Wilder
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: David Wilder @ 2020-06-22 17:10 UTC (permalink / raw)
To: netdev; +Cc: netfilter-devel, fw, wilder, mkubecek
A crash happened on ppc64le when running ltp network tests triggered by "rmmod iptable_mangle".
See previous discussion in this thread: https://lists.openwall.net/netdev/2020/06/03/161 .
In the crash I found in iptable_mangle_hook() that state->net->ipv4.iptable_mangle=NULL causing a NULL pointer dereference. net->ipv4.iptable_mangle is set to NULL in iptable_mangle_net_exit() and called when ip_mangle modules is unloaded. A rmmod task was found running in the crash dump. A 2nd crash showed the same problem when running "rmmod iptable_filter" (net->ipv4.iptable_filter=NULL).
To fix this I added .pre_exit hook in all iptable_foo.c. The pre_exit will un-register the underlying hook and exit would do the table freeing. The netns core does an unconditional synchronize_rcu after the pre_exit hooks insuring no packets are in flight that have picked up the pointer before completing the un-register.
These patches include changes for both iptables and ip6tables.
We tested this fix with ltp running iptables01.sh and iptables01.sh -6 a loop for 72 hours.
Signed-off-by: David Wilder <dwilder@us.ibm.com>
David Wilder (4):
netfilter: Split ipt_unregister_table() into pre_exit and exit
helpers.
netfilter: Add a .pre_exit hook in all iptable_foo.c.
netfilter: Split ip6t_unregister_table() into pre_exit and exit
helpers.
netfilter: Add a .pre_exit hook in all ip6table_foo.c.
include/linux/netfilter_ipv4/ip_tables.h | 6 ++++++
include/linux/netfilter_ipv6/ip6_tables.h | 3 +++
net/ipv4/netfilter/ip_tables.c | 15 ++++++++++++++-
net/ipv4/netfilter/iptable_filter.c | 10 +++++++++-
net/ipv4/netfilter/iptable_mangle.c | 10 +++++++++-
net/ipv4/netfilter/iptable_nat.c | 10 ++++++++--
net/ipv4/netfilter/iptable_raw.c | 10 +++++++++-
net/ipv4/netfilter/iptable_security.c | 11 +++++++++--
net/ipv6/netfilter/ip6_tables.c | 15 ++++++++++++++-
net/ipv6/netfilter/ip6table_filter.c | 10 +++++++++-
net/ipv6/netfilter/ip6table_mangle.c | 10 +++++++++-
net/ipv6/netfilter/ip6table_nat.c | 10 ++++++++--
net/ipv6/netfilter/ip6table_raw.c | 10 +++++++++-
net/ipv6/netfilter/ip6table_security.c | 10 +++++++++-
14 files changed, 125 insertions(+), 15 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 1/4] netfilter: Split ipt_unregister_table() into pre_exit and exit helpers.
2020-06-22 17:10 [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference David Wilder
@ 2020-06-22 17:10 ` David Wilder
2020-06-22 17:10 ` [PATCH v1 2/4] netfilter: Add a .pre_exit hook in all iptable_foo.c David Wilder
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Wilder @ 2020-06-22 17:10 UTC (permalink / raw)
To: netdev; +Cc: netfilter-devel, fw, wilder, mkubecek
The pre_exit will un-register the underlying hook and .exit will do the
table freeing. The netns core does an unconditional synchronize_rcu after
the pre_exit hooks insuring no packets are in flight that have picked up
the pointer before completing the un-register.
Signed-off-by: David Wilder <dwilder@us.ibm.com>
---
include/linux/netfilter_ipv4/ip_tables.h | 6 ++++++
net/ipv4/netfilter/ip_tables.c | 15 ++++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index b394bd4..c4676d6 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -25,6 +25,12 @@
int ipt_register_table(struct net *net, const struct xt_table *table,
const struct ipt_replace *repl,
const struct nf_hook_ops *ops, struct xt_table **res);
+
+void ipt_unregister_table_pre_exit(struct net *net, struct xt_table *table,
+ const struct nf_hook_ops *ops);
+
+void ipt_unregister_table_exit(struct net *net, struct xt_table *table);
+
void ipt_unregister_table(struct net *net, struct xt_table *table,
const struct nf_hook_ops *ops);
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index c2670ea..5bf9fa0 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -1797,11 +1797,22 @@ int ipt_register_table(struct net *net, const struct xt_table *table,
return ret;
}
+void ipt_unregister_table_pre_exit(struct net *net, struct xt_table *table,
+ const struct nf_hook_ops *ops)
+{
+ nf_unregister_net_hooks(net, ops, hweight32(table->valid_hooks));
+}
+
+void ipt_unregister_table_exit(struct net *net, struct xt_table *table)
+{
+ __ipt_unregister_table(net, table);
+}
+
void ipt_unregister_table(struct net *net, struct xt_table *table,
const struct nf_hook_ops *ops)
{
if (ops)
- nf_unregister_net_hooks(net, ops, hweight32(table->valid_hooks));
+ ipt_unregister_table_pre_exit(net, table, ops);
__ipt_unregister_table(net, table);
}
@@ -1958,6 +1969,8 @@ static void __exit ip_tables_fini(void)
EXPORT_SYMBOL(ipt_register_table);
EXPORT_SYMBOL(ipt_unregister_table);
+EXPORT_SYMBOL(ipt_unregister_table_pre_exit);
+EXPORT_SYMBOL(ipt_unregister_table_exit);
EXPORT_SYMBOL(ipt_do_table);
module_init(ip_tables_init);
module_exit(ip_tables_fini);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/4] netfilter: Add a .pre_exit hook in all iptable_foo.c.
2020-06-22 17:10 [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference David Wilder
2020-06-22 17:10 ` [PATCH v1 1/4] netfilter: Split ipt_unregister_table() into pre_exit and exit helpers David Wilder
@ 2020-06-22 17:10 ` David Wilder
2020-06-22 17:10 ` [PATCH v1 3/4] netfilter: Split ip6t_unregister_table() into pre_exit and exit helpers David Wilder
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Wilder @ 2020-06-22 17:10 UTC (permalink / raw)
To: netdev; +Cc: netfilter-devel, fw, wilder, mkubecek
Using new helpers ipt_unregister_table_pre_exit() and
ipt_unregister_table_exit().
Signed-off-by: David Wilder <dwilder@us.ibm.com>
---
net/ipv4/netfilter/iptable_filter.c | 10 +++++++++-
net/ipv4/netfilter/iptable_mangle.c | 10 +++++++++-
net/ipv4/netfilter/iptable_nat.c | 10 ++++++++--
net/ipv4/netfilter/iptable_raw.c | 10 +++++++++-
net/ipv4/netfilter/iptable_security.c | 11 +++++++++--
5 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
index 9d54b40..8f7bc1e 100644
--- a/net/ipv4/netfilter/iptable_filter.c
+++ b/net/ipv4/netfilter/iptable_filter.c
@@ -72,16 +72,24 @@ static int __net_init iptable_filter_net_init(struct net *net)
return 0;
}
+static void __net_exit iptable_filter_net_pre_exit(struct net *net)
+{
+ if (net->ipv4.iptable_filter)
+ ipt_unregister_table_pre_exit(net, net->ipv4.iptable_filter,
+ filter_ops);
+}
+
static void __net_exit iptable_filter_net_exit(struct net *net)
{
if (!net->ipv4.iptable_filter)
return;
- ipt_unregister_table(net, net->ipv4.iptable_filter, filter_ops);
+ ipt_unregister_table_exit(net, net->ipv4.iptable_filter);
net->ipv4.iptable_filter = NULL;
}
static struct pernet_operations iptable_filter_net_ops = {
.init = iptable_filter_net_init,
+ .pre_exit = iptable_filter_net_pre_exit,
.exit = iptable_filter_net_exit,
};
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
index bb9266e..f703a71 100644
--- a/net/ipv4/netfilter/iptable_mangle.c
+++ b/net/ipv4/netfilter/iptable_mangle.c
@@ -100,15 +100,23 @@ static int __net_init iptable_mangle_table_init(struct net *net)
return ret;
}
+static void __net_exit iptable_mangle_net_pre_exit(struct net *net)
+{
+ if (net->ipv4.iptable_mangle)
+ ipt_unregister_table_pre_exit(net, net->ipv4.iptable_mangle,
+ mangle_ops);
+}
+
static void __net_exit iptable_mangle_net_exit(struct net *net)
{
if (!net->ipv4.iptable_mangle)
return;
- ipt_unregister_table(net, net->ipv4.iptable_mangle, mangle_ops);
+ ipt_unregister_table_exit(net, net->ipv4.iptable_mangle);
net->ipv4.iptable_mangle = NULL;
}
static struct pernet_operations iptable_mangle_net_ops = {
+ .pre_exit = iptable_mangle_net_pre_exit,
.exit = iptable_mangle_net_exit,
};
diff --git a/net/ipv4/netfilter/iptable_nat.c b/net/ipv4/netfilter/iptable_nat.c
index ad33687..b0143b1 100644
--- a/net/ipv4/netfilter/iptable_nat.c
+++ b/net/ipv4/netfilter/iptable_nat.c
@@ -113,16 +113,22 @@ static int __net_init iptable_nat_table_init(struct net *net)
return ret;
}
+static void __net_exit iptable_nat_net_pre_exit(struct net *net)
+{
+ if (net->ipv4.nat_table)
+ ipt_nat_unregister_lookups(net);
+}
+
static void __net_exit iptable_nat_net_exit(struct net *net)
{
if (!net->ipv4.nat_table)
return;
- ipt_nat_unregister_lookups(net);
- ipt_unregister_table(net, net->ipv4.nat_table, NULL);
+ ipt_unregister_table_exit(net, net->ipv4.nat_table);
net->ipv4.nat_table = NULL;
}
static struct pernet_operations iptable_nat_net_ops = {
+ .pre_exit = iptable_nat_net_pre_exit,
.exit = iptable_nat_net_exit,
};
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c
index 69697eb..9abfe6b 100644
--- a/net/ipv4/netfilter/iptable_raw.c
+++ b/net/ipv4/netfilter/iptable_raw.c
@@ -67,15 +67,23 @@ static int __net_init iptable_raw_table_init(struct net *net)
return ret;
}
+static void __net_exit iptable_raw_net_pre_exit(struct net *net)
+{
+ if (net->ipv4.iptable_raw)
+ ipt_unregister_table_pre_exit(net, net->ipv4.iptable_raw,
+ rawtable_ops);
+}
+
static void __net_exit iptable_raw_net_exit(struct net *net)
{
if (!net->ipv4.iptable_raw)
return;
- ipt_unregister_table(net, net->ipv4.iptable_raw, rawtable_ops);
+ ipt_unregister_table_exit(net, net->ipv4.iptable_raw);
net->ipv4.iptable_raw = NULL;
}
static struct pernet_operations iptable_raw_net_ops = {
+ .pre_exit = iptable_raw_net_pre_exit,
.exit = iptable_raw_net_exit,
};
diff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c
index ac633c1..415c197 100644
--- a/net/ipv4/netfilter/iptable_security.c
+++ b/net/ipv4/netfilter/iptable_security.c
@@ -62,16 +62,23 @@ static int __net_init iptable_security_table_init(struct net *net)
return ret;
}
+static void __net_exit iptable_security_net_pre_exit(struct net *net)
+{
+ if (net->ipv4.iptable_security)
+ ipt_unregister_table_pre_exit(net, net->ipv4.iptable_security,
+ sectbl_ops);
+}
+
static void __net_exit iptable_security_net_exit(struct net *net)
{
if (!net->ipv4.iptable_security)
return;
-
- ipt_unregister_table(net, net->ipv4.iptable_security, sectbl_ops);
+ ipt_unregister_table_exit(net, net->ipv4.iptable_security);
net->ipv4.iptable_security = NULL;
}
static struct pernet_operations iptable_security_net_ops = {
+ .pre_exit = iptable_security_net_pre_exit,
.exit = iptable_security_net_exit,
};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 3/4] netfilter: Split ip6t_unregister_table() into pre_exit and exit helpers.
2020-06-22 17:10 [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference David Wilder
2020-06-22 17:10 ` [PATCH v1 1/4] netfilter: Split ipt_unregister_table() into pre_exit and exit helpers David Wilder
2020-06-22 17:10 ` [PATCH v1 2/4] netfilter: Add a .pre_exit hook in all iptable_foo.c David Wilder
@ 2020-06-22 17:10 ` David Wilder
2020-06-22 17:10 ` [PATCH v1 4/4] netfilter: Add a .pre_exit hook in all ip6table_foo.c David Wilder
2020-06-24 12:05 ` [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference Pablo Neira Ayuso
4 siblings, 0 replies; 6+ messages in thread
From: David Wilder @ 2020-06-22 17:10 UTC (permalink / raw)
To: netdev; +Cc: netfilter-devel, fw, wilder, mkubecek
The pre_exit will un-register the underlying hook and .exit will do
the table freeing. The netns core does an unconditional synchronize_rcu
after the pre_exit hooks insuring no packets are in flight that have
picked up the pointer before completing the un-register.
Signed-off-by: David Wilder <dwilder@us.ibm.com>
---
include/linux/netfilter_ipv6/ip6_tables.h | 3 +++
net/ipv6/netfilter/ip6_tables.c | 15 ++++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index 8225f78..1547d5f 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -29,6 +29,9 @@ int ip6t_register_table(struct net *net, const struct xt_table *table,
const struct nf_hook_ops *ops, struct xt_table **res);
void ip6t_unregister_table(struct net *net, struct xt_table *table,
const struct nf_hook_ops *ops);
+void ip6t_unregister_table_pre_exit(struct net *net, struct xt_table *table,
+ const struct nf_hook_ops *ops);
+void ip6t_unregister_table_exit(struct net *net, struct xt_table *table);
extern unsigned int ip6t_do_table(struct sk_buff *skb,
const struct nf_hook_state *state,
struct xt_table *table);
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index e273934..e96a431 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -1807,11 +1807,22 @@ int ip6t_register_table(struct net *net, const struct xt_table *table,
return ret;
}
+void ip6t_unregister_table_pre_exit(struct net *net, struct xt_table *table,
+ const struct nf_hook_ops *ops)
+{
+ nf_unregister_net_hooks(net, ops, hweight32(table->valid_hooks));
+}
+
+void ip6t_unregister_table_exit(struct net *net, struct xt_table *table)
+{
+ __ip6t_unregister_table(net, table);
+}
+
void ip6t_unregister_table(struct net *net, struct xt_table *table,
const struct nf_hook_ops *ops)
{
if (ops)
- nf_unregister_net_hooks(net, ops, hweight32(table->valid_hooks));
+ ip6t_unregister_table_pre_exit(net, table, ops);
__ip6t_unregister_table(net, table);
}
@@ -1969,6 +1980,8 @@ static void __exit ip6_tables_fini(void)
EXPORT_SYMBOL(ip6t_register_table);
EXPORT_SYMBOL(ip6t_unregister_table);
+EXPORT_SYMBOL(ip6t_unregister_table_pre_exit);
+EXPORT_SYMBOL(ip6t_unregister_table_exit);
EXPORT_SYMBOL(ip6t_do_table);
module_init(ip6_tables_init);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 4/4] netfilter: Add a .pre_exit hook in all ip6table_foo.c.
2020-06-22 17:10 [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference David Wilder
` (2 preceding siblings ...)
2020-06-22 17:10 ` [PATCH v1 3/4] netfilter: Split ip6t_unregister_table() into pre_exit and exit helpers David Wilder
@ 2020-06-22 17:10 ` David Wilder
2020-06-24 12:05 ` [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference Pablo Neira Ayuso
4 siblings, 0 replies; 6+ messages in thread
From: David Wilder @ 2020-06-22 17:10 UTC (permalink / raw)
To: netdev; +Cc: netfilter-devel, fw, wilder, mkubecek
Using new helpers ip6t_unregister_table_pre_exit() and
ip6t_unregister_table_exit().
Signed-off-by: David Wilder <dwilder@us.ibm.com>
---
net/ipv6/netfilter/ip6table_filter.c | 10 +++++++++-
net/ipv6/netfilter/ip6table_mangle.c | 10 +++++++++-
net/ipv6/netfilter/ip6table_nat.c | 10 ++++++++--
net/ipv6/netfilter/ip6table_raw.c | 10 +++++++++-
net/ipv6/netfilter/ip6table_security.c | 10 +++++++++-
5 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
index 32667f5..88337b5 100644
--- a/net/ipv6/netfilter/ip6table_filter.c
+++ b/net/ipv6/netfilter/ip6table_filter.c
@@ -73,16 +73,24 @@ static int __net_init ip6table_filter_net_init(struct net *net)
return 0;
}
+static void __net_exit ip6table_filter_net_pre_exit(struct net *net)
+{
+ if (net->ipv6.ip6table_filter)
+ ip6t_unregister_table_pre_exit(net, net->ipv6.ip6table_filter,
+ filter_ops);
+}
+
static void __net_exit ip6table_filter_net_exit(struct net *net)
{
if (!net->ipv6.ip6table_filter)
return;
- ip6t_unregister_table(net, net->ipv6.ip6table_filter, filter_ops);
+ ip6t_unregister_table_exit(net, net->ipv6.ip6table_filter);
net->ipv6.ip6table_filter = NULL;
}
static struct pernet_operations ip6table_filter_net_ops = {
.init = ip6table_filter_net_init,
+ .pre_exit = ip6table_filter_net_pre_exit,
.exit = ip6table_filter_net_exit,
};
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
index 070afb9..1a27486 100644
--- a/net/ipv6/netfilter/ip6table_mangle.c
+++ b/net/ipv6/netfilter/ip6table_mangle.c
@@ -93,16 +93,24 @@ static int __net_init ip6table_mangle_table_init(struct net *net)
return ret;
}
+static void __net_exit ip6table_mangle_net_pre_exit(struct net *net)
+{
+ if (net->ipv6.ip6table_mangle)
+ ip6t_unregister_table_pre_exit(net, net->ipv6.ip6table_mangle,
+ mangle_ops);
+}
+
static void __net_exit ip6table_mangle_net_exit(struct net *net)
{
if (!net->ipv6.ip6table_mangle)
return;
- ip6t_unregister_table(net, net->ipv6.ip6table_mangle, mangle_ops);
+ ip6t_unregister_table_exit(net, net->ipv6.ip6table_mangle);
net->ipv6.ip6table_mangle = NULL;
}
static struct pernet_operations ip6table_mangle_net_ops = {
+ .pre_exit = ip6table_mangle_net_pre_exit,
.exit = ip6table_mangle_net_exit,
};
diff --git a/net/ipv6/netfilter/ip6table_nat.c b/net/ipv6/netfilter/ip6table_nat.c
index 0f48759..0a23265 100644
--- a/net/ipv6/netfilter/ip6table_nat.c
+++ b/net/ipv6/netfilter/ip6table_nat.c
@@ -114,16 +114,22 @@ static int __net_init ip6table_nat_table_init(struct net *net)
return ret;
}
+static void __net_exit ip6table_nat_net_pre_exit(struct net *net)
+{
+ if (net->ipv6.ip6table_nat)
+ ip6t_nat_unregister_lookups(net);
+}
+
static void __net_exit ip6table_nat_net_exit(struct net *net)
{
if (!net->ipv6.ip6table_nat)
return;
- ip6t_nat_unregister_lookups(net);
- ip6t_unregister_table(net, net->ipv6.ip6table_nat, NULL);
+ ip6t_unregister_table_exit(net, net->ipv6.ip6table_nat);
net->ipv6.ip6table_nat = NULL;
}
static struct pernet_operations ip6table_nat_net_ops = {
+ .pre_exit = ip6table_nat_net_pre_exit,
.exit = ip6table_nat_net_exit,
};
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index a22100b..8f9e742 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -66,15 +66,23 @@ static int __net_init ip6table_raw_table_init(struct net *net)
return ret;
}
+static void __net_exit ip6table_raw_net_pre_exit(struct net *net)
+{
+ if (net->ipv6.ip6table_raw)
+ ip6t_unregister_table_pre_exit(net, net->ipv6.ip6table_raw,
+ rawtable_ops);
+}
+
static void __net_exit ip6table_raw_net_exit(struct net *net)
{
if (!net->ipv6.ip6table_raw)
return;
- ip6t_unregister_table(net, net->ipv6.ip6table_raw, rawtable_ops);
+ ip6t_unregister_table_exit(net, net->ipv6.ip6table_raw);
net->ipv6.ip6table_raw = NULL;
}
static struct pernet_operations ip6table_raw_net_ops = {
+ .pre_exit = ip6table_raw_net_pre_exit,
.exit = ip6table_raw_net_exit,
};
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c
index a74335f..5e8c48f 100644
--- a/net/ipv6/netfilter/ip6table_security.c
+++ b/net/ipv6/netfilter/ip6table_security.c
@@ -61,15 +61,23 @@ static int __net_init ip6table_security_table_init(struct net *net)
return ret;
}
+static void __net_exit ip6table_security_net_pre_exit(struct net *net)
+{
+ if (net->ipv6.ip6table_security)
+ ip6t_unregister_table_pre_exit(net, net->ipv6.ip6table_security,
+ sectbl_ops);
+}
+
static void __net_exit ip6table_security_net_exit(struct net *net)
{
if (!net->ipv6.ip6table_security)
return;
- ip6t_unregister_table(net, net->ipv6.ip6table_security, sectbl_ops);
+ ip6t_unregister_table_exit(net, net->ipv6.ip6table_security);
net->ipv6.ip6table_security = NULL;
}
static struct pernet_operations ip6table_security_net_ops = {
+ .pre_exit = ip6table_security_net_pre_exit,
.exit = ip6table_security_net_exit,
};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference.
2020-06-22 17:10 [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference David Wilder
` (3 preceding siblings ...)
2020-06-22 17:10 ` [PATCH v1 4/4] netfilter: Add a .pre_exit hook in all ip6table_foo.c David Wilder
@ 2020-06-24 12:05 ` Pablo Neira Ayuso
4 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2020-06-24 12:05 UTC (permalink / raw)
To: David Wilder; +Cc: netdev, netfilter-devel, fw, wilder, mkubecek
On Mon, Jun 22, 2020 at 10:10:10AM -0700, David Wilder wrote:
> A crash happened on ppc64le when running ltp network tests triggered by "rmmod iptable_mangle".
>
> See previous discussion in this thread: https://lists.openwall.net/netdev/2020/06/03/161 .
>
> In the crash I found in iptable_mangle_hook() that state->net->ipv4.iptable_mangle=NULL causing a NULL pointer dereference. net->ipv4.iptable_mangle is set to NULL in iptable_mangle_net_exit() and called when ip_mangle modules is unloaded. A rmmod task was found running in the crash dump. A 2nd crash showed the same problem when running "rmmod iptable_filter" (net->ipv4.iptable_filter=NULL).
>
> To fix this I added .pre_exit hook in all iptable_foo.c. The pre_exit will un-register the underlying hook and exit would do the table freeing. The netns core does an unconditional synchronize_rcu after the pre_exit hooks insuring no packets are in flight that have picked up the pointer before completing the un-register.
>
> These patches include changes for both iptables and ip6tables.
>
> We tested this fix with ltp running iptables01.sh and iptables01.sh -6 a loop for 72 hours.
Series applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-06-24 12:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 17:10 [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference David Wilder
2020-06-22 17:10 ` [PATCH v1 1/4] netfilter: Split ipt_unregister_table() into pre_exit and exit helpers David Wilder
2020-06-22 17:10 ` [PATCH v1 2/4] netfilter: Add a .pre_exit hook in all iptable_foo.c David Wilder
2020-06-22 17:10 ` [PATCH v1 3/4] netfilter: Split ip6t_unregister_table() into pre_exit and exit helpers David Wilder
2020-06-22 17:10 ` [PATCH v1 4/4] netfilter: Add a .pre_exit hook in all ip6table_foo.c David Wilder
2020-06-24 12:05 ` [PATCH v1 0/4] iptables: Module unload causing NULL pointer reference Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).