netfilter: ipset: Check IPSET_ATTR_ETHER netlink attribute length
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Tue, 8 Mar 2016 19:29:10 +0000 (20:29 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Tue, 8 Mar 2016 19:36:17 +0000 (20:36 +0100)
Julia Lawall pointed out that IPSET_ATTR_ETHER netlink attribute length
was not checked explicitly, just for the maximum possible size. Malicious
netlink clients could send shorter attribute and thus resulting a kernel
read after the buffer.

The patch adds the explicit length checkings.

Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
net/netfilter/ipset/ip_set_bitmap_ipmac.c
net/netfilter/ipset/ip_set_hash_mac.c

index 29dde208381dac6cdfca67094dc4fc07bc85b40c..9a065f672d3a56f33a22e38937780ab59d318c13 100644 (file)
@@ -267,6 +267,8 @@ bitmap_ipmac_uadt(struct ip_set *set, struct nlattr *tb[],
 
        e.id = ip_to_id(map, ip);
        if (tb[IPSET_ATTR_ETHER]) {
+               if (nla_len(tb[IPSET_ATTR_ETHER]) != ETH_ALEN)
+                       return -IPSET_ERR_PROTOCOL;
                memcpy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]), ETH_ALEN);
                e.add_mac = 1;
        }
index f1e7d2c0f68531421189b38d251148bdc4d12c95..8f004edad396717e5855dafbb456412b54e9fc51 100644 (file)
@@ -110,7 +110,8 @@ hash_mac4_uadt(struct ip_set *set, struct nlattr *tb[],
        if (tb[IPSET_ATTR_LINENO])
                *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
 
-       if (unlikely(!tb[IPSET_ATTR_ETHER]))
+       if (unlikely(!tb[IPSET_ATTR_ETHER] ||
+                    nla_len(tb[IPSET_ATTR_ETHER]) != ETH_ALEN))
                return -IPSET_ERR_PROTOCOL;
 
        ret = ip_set_get_extensions(set, tb, &ext);