aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2014-07-25 07:15:36 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2014-07-31 15:11:43 -0400
commit7d5570ca8972aad58de0b4ad03a5e991c41d4ce2 (patch)
tree011475fa651a86a0579c2b77e8714b91dbb4d213 /net
parentb6d04688040218d66edd8b221e43c67240b83119 (diff)
netfilter: nf_tables: check for unset NFTA_SET_ELEM_LIST_ELEMENTS attribute
Otherwise, the kernel oopses in nla_for_each_nested when iterating over the unset attribute NFTA_SET_ELEM_LIST_ELEMENTS in the nf_tables_{new,del}setelem() path. netlink: 65524 bytes leftover after parsing attributes in process `nft'. [...] Oops: 0000 [#1] SMP [...] CPU: 2 PID: 6287 Comm: nft Not tainted 3.16.0-rc2+ #169 RIP: 0010:[<ffffffffa0526e61>] [<ffffffffa0526e61>] nf_tables_newsetelem+0x82/0xec [nf_tables] [...] Call Trace: [<ffffffffa05178c4>] nfnetlink_rcv+0x2e7/0x3d7 [nfnetlink] [<ffffffffa0517939>] ? nfnetlink_rcv+0x35c/0x3d7 [nfnetlink] [<ffffffff8137d300>] netlink_unicast+0xf8/0x17a [<ffffffff8137d6a5>] netlink_sendmsg+0x323/0x351 [...] Fix this by returning -EINVAL if this attribute is not set, which doesn't make sense at all since those commands are there to add and to delete elements from the set. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nf_tables_api.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index ecffb26e2f20..93692d692ebc 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3073,6 +3073,9 @@ static int nf_tables_newsetelem(struct sock *nlsk, struct sk_buff *skb,
3073 struct nft_ctx ctx; 3073 struct nft_ctx ctx;
3074 int rem, err = 0; 3074 int rem, err = 0;
3075 3075
3076 if (nla[NFTA_SET_ELEM_LIST_ELEMENTS] == NULL)
3077 return -EINVAL;
3078
3076 err = nft_ctx_init_from_elemattr(&ctx, skb, nlh, nla, true); 3079 err = nft_ctx_init_from_elemattr(&ctx, skb, nlh, nla, true);
3077 if (err < 0) 3080 if (err < 0)
3078 return err; 3081 return err;
@@ -3156,6 +3159,9 @@ static int nf_tables_delsetelem(struct sock *nlsk, struct sk_buff *skb,
3156 struct nft_ctx ctx; 3159 struct nft_ctx ctx;
3157 int rem, err = 0; 3160 int rem, err = 0;
3158 3161
3162 if (nla[NFTA_SET_ELEM_LIST_ELEMENTS] == NULL)
3163 return -EINVAL;
3164
3159 err = nft_ctx_init_from_elemattr(&ctx, skb, nlh, nla, false); 3165 err = nft_ctx_init_from_elemattr(&ctx, skb, nlh, nla, false);
3160 if (err < 0) 3166 if (err < 0)
3161 return err; 3167 return err;