Two possible error conditions were caught during an extended testing
session, and by a build robot. These patches fix the two issues (a
missing handler when config is changed, and a potential NULL
dereference).
Aaron Conole (2):
netfilter: Fix potential null pointer dereference
nf_set_hooks_head: acommodate different kconfig
net/netfilter/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--
2.5.5
It's possible for nf_hook_entry_head to return NULL if two
nf_unregister_net_hook calls happen simultaneously with a single hook
entry in the list. This fix ensures that no null pointer dereference
could occur when such a race happens.
Signed-off-by: Aaron Conole <redacted>
---
net/netfilter/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
When CONFIG_NETFILTER_INGRESS is unset (or no), we need to handle
the request for registration properly by dropping the hook. This
releases the entry during the set.
Signed-off-by: Aaron Conole <redacted>
---
net/netfilter/core.c | 4 ++++
1 file changed, 4 insertions(+)
@@ -90,10 +90,14 @@ static void nf_set_hooks_head(struct net *net, const struct nf_hook_ops *reg,{switch(reg->pf){caseNFPROTO_NETDEV:+#ifdef CONFIG_NETFILTER_INGRESS/* We already checked in nf_register_net_hook() that this is*usedfromingress.*/rcu_assign_pointer(reg->dev->nf_hooks_ingress,entry);+#else+kfree(entry);+#endifbreak;default:rcu_assign_pointer(net->nf.hooks[reg->pf][reg->hooknum],
When CONFIG_NETFILTER_INGRESS is unset (or no), we need to handle
the request for registration properly by dropping the hook. This
releases the entry during the set.
Signed-off-by: Aaron Conole <redacted>
---
net/netfilter/core.c | 4 ++++
1 file changed, 4 insertions(+)
@@ -90,10 +90,14 @@ static void nf_set_hooks_head(struct net *net, const struct nf_hook_ops *reg,{switch(reg->pf){caseNFPROTO_NETDEV:+#ifdef CONFIG_NETFILTER_INGRESS/* We already checked in nf_register_net_hook() that this is*usedfromingress.*/rcu_assign_pointer(reg->dev->nf_hooks_ingress,entry);+#else+kfree(entry);+#endifbreak;
This looks dodgy (its correct though).
I'd propose to add a test to nf_register_net_hook()
to bail with -EOPNOSTUPP instead of this "#else kfree()" if we get
NFPROTO_NETDEV pf with CONFIG_NETFILTER_INGRESS=n build instead.
When CONFIG_NETFILTER_INGRESS is unset (or no), we need to handle
the request for registration properly by dropping the hook. This
releases the entry during the set.
Signed-off-by: Aaron Conole <redacted>
---
net/netfilter/core.c | 4 ++++
1 file changed, 4 insertions(+)
@@ -90,10 +90,14 @@ static void nf_set_hooks_head(struct net *net, const struct nf_hook_ops *reg,{switch(reg->pf){caseNFPROTO_NETDEV:+#ifdef CONFIG_NETFILTER_INGRESS/* We already checked in nf_register_net_hook() that this is*usedfromingress.*/rcu_assign_pointer(reg->dev->nf_hooks_ingress,entry);+#else+kfree(entry);+#endifbreak;
This looks dodgy (its correct though).
I'd propose to add a test to nf_register_net_hook()
to bail with -EOPNOSTUPP instead of this "#else kfree()" if we get
NFPROTO_NETDEV pf with CONFIG_NETFILTER_INGRESS=n build instead.
Okay, I'll spin a new version.
Thanks for the review, Florian!
-Aaron