netfilter: ipset: fix a missing check of nla_parse
authorAditya Pakki <pakki001@umn.edu>
Mon, 10 Jun 2019 10:47:37 +0000 (12:47 +0200)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 10 Jun 2019 10:47:37 +0000 (12:47 +0200)
When nla_parse fails, we should not use the results (the first
argument). The fix checks if it fails, and if so, returns its error code
upstream.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
net/netfilter/ipset/ip_set_core.c

index 2ad609900b22eee6ffe52fa2b083ff47e17a205f..d0f4c627ff91247ca43fca60ced44a70515e6fc3 100644 (file)
@@ -1544,10 +1544,14 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
                memcpy(&errmsg->msg, nlh, nlh->nlmsg_len);
                cmdattr = (void *)&errmsg->msg + min_len;
 
-               nla_parse_deprecated(cda, IPSET_ATTR_CMD_MAX, cmdattr,
-                                    nlh->nlmsg_len - min_len,
-                                    ip_set_adt_policy, NULL);
+               ret = nla_parse_deprecated(cda, IPSET_ATTR_CMD_MAX, cmdattr,
+                                          nlh->nlmsg_len - min_len,
+                                          ip_set_adt_policy, NULL);
 
+               if (ret) {
+                       nlmsg_free(skb2);
+                       return ret;
+               }
                errline = nla_data(cda[IPSET_ATTR_LINENO]);
 
                *errline = lineno;