summaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-01-09 18:42:40 +0000
committerPablo Neira Ayuso <pablo@netfilter.org>2014-01-09 20:17:16 +0100
commit7047f9d052c379e14b7693bb9f1b766827d0bc40 (patch)
treeba7922b54a4c5b8690bba765b7aa9805cf561437 /net/netfilter
parentc5c1f975ada48801f1e08e2215714315fa9cf306 (diff)
downloadtalos-op-linux-7047f9d052c379e14b7693bb9f1b766827d0bc40.tar.gz
talos-op-linux-7047f9d052c379e14b7693bb9f1b766827d0bc40.zip
netfilter: nf_tables: take AF module reference when creating a table
The table refers to data of the AF module, so we need to make sure the module isn't unloaded while the table exists. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/nf_tables_api.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 88f9c9448538..c35261496c30 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -430,9 +430,14 @@ static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb,
return -EINVAL;
}
+ if (!try_module_get(afi->owner))
+ return -EAFNOSUPPORT;
+
table = kzalloc(sizeof(*table) + nla_len(name), GFP_KERNEL);
- if (table == NULL)
+ if (table == NULL) {
+ module_put(afi->owner);
return -ENOMEM;
+ }
nla_strlcpy(table->name, name, nla_len(name));
INIT_LIST_HEAD(&table->chains);
@@ -468,6 +473,7 @@ static int nf_tables_deltable(struct sock *nlsk, struct sk_buff *skb,
list_del(&table->list);
nf_tables_table_notify(skb, nlh, table, NFT_MSG_DELTABLE, family);
kfree(table);
+ module_put(afi->owner);
return 0;
}
OpenPOWER on IntegriCloud