netfilter: ipset: fixes possible oops in mtype_resize
authorVasily Averin <vvs@virtuozzo.com>
Thu, 17 Dec 2020 08:53:40 +0000 (11:53 +0300)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 17 Dec 2020 18:44:52 +0000 (19:44 +0100)
commit2b33d6ffa9e38f344418976b06057e2fc2aa9e2a
treee4cf6737ee7ab41d04f745fdf78f275321373274
parent443d6e86f821a165fae3fc3fc13086d27ac140b1
netfilter: ipset: fixes possible oops in mtype_resize

currently mtype_resize() can cause oops

        t = ip_set_alloc(htable_size(htable_bits));
        if (!t) {
                ret = -ENOMEM;
                goto out;
        }
        t->hregion = ip_set_alloc(ahash_sizeof_regions(htable_bits));

Increased htable_bits can force htable_size() to return 0.
In own turn ip_set_alloc(0) returns not 0 but ZERO_SIZE_PTR,
so follwoing access to t->hregion should trigger an OOPS.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/ipset/ip_set_hash_gen.h