aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-02-05 10:03:35 -0500
committerPablo Neira Ayuso <pablo@netfilter.org>2014-02-05 18:04:15 -0500
commitec2c9935688fbd5eaa7c975e3e21562c3da77363 (patch)
tree929fe5c28ed844898fec9226773c20a55748dcb1 /net
parent53b70287ddf487a38b7cbf0a10db28f40714b799 (diff)
netfilter: nf_tables: fix potential oops when dumping sets
Commit c9c8e48597 (netfilter: nf_tables: dump sets in all existing families) changed nft_ctx_init_from_setattr() to only look up the address family if it is not NFPROTO_UNSPEC. However if it is NFPROTO_UNSPEC and a table attribute is given, nftables_afinfo_lookup() will dereference the NULL afi pointer. Fix by checking for non-NULL afi and also move a check added by that commit to the proper position. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nf_tables_api.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 2a22a186eb3d..3c5a219f4242 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1943,6 +1943,9 @@ static int nft_ctx_init_from_setattr(struct nft_ctx *ctx,
1943 } 1943 }
1944 1944
1945 if (nla[NFTA_SET_TABLE] != NULL) { 1945 if (nla[NFTA_SET_TABLE] != NULL) {
1946 if (afi == NULL)
1947 return -EAFNOSUPPORT;
1948
1946 table = nf_tables_table_lookup(afi, nla[NFTA_SET_TABLE]); 1949 table = nf_tables_table_lookup(afi, nla[NFTA_SET_TABLE]);
1947 if (IS_ERR(table)) 1950 if (IS_ERR(table))
1948 return PTR_ERR(table); 1951 return PTR_ERR(table);
@@ -2428,6 +2431,8 @@ static int nf_tables_delset(struct sock *nlsk, struct sk_buff *skb,
2428 struct nft_ctx ctx; 2431 struct nft_ctx ctx;
2429 int err; 2432 int err;
2430 2433
2434 if (nfmsg->nfgen_family == NFPROTO_UNSPEC)
2435 return -EAFNOSUPPORT;
2431 if (nla[NFTA_SET_TABLE] == NULL) 2436 if (nla[NFTA_SET_TABLE] == NULL)
2432 return -EINVAL; 2437 return -EINVAL;
2433 2438
@@ -2435,9 +2440,6 @@ static int nf_tables_delset(struct sock *nlsk, struct sk_buff *skb,
2435 if (err < 0) 2440 if (err < 0)
2436 return err; 2441 return err;
2437 2442
2438 if (nfmsg->nfgen_family == NFPROTO_UNSPEC)
2439 return -EAFNOSUPPORT;
2440
2441 set = nf_tables_set_lookup(ctx.table, nla[NFTA_SET_NAME]); 2443 set = nf_tables_set_lookup(ctx.table, nla[NFTA_SET_NAME]);
2442 if (IS_ERR(set)) 2444 if (IS_ERR(set))
2443 return PTR_ERR(set); 2445 return PTR_ERR(set);