netfilter: nf_tables: fix overrun in nf_tables_set_alloc_name()
authorPatrick McHardy <kaber@trash.net>
Wed, 5 Feb 2014 11:26:22 +0000 (12:26 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 5 Feb 2014 16:46:07 +0000 (17:46 +0100)
The map that is used to allocate anonymous sets is indeed
BITS_PER_BYTE * PAGE_SIZE long.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index 9ce30534f8533cd63a023e16bd66565bc43b46cc..2a22a186eb3d2f20188f98e0695dfc6b4cce31aa 100644 (file)
@@ -1989,13 +1989,13 @@ static int nf_tables_set_alloc_name(struct nft_ctx *ctx, struct nft_set *set,
 
                        if (!sscanf(i->name, name, &tmp))
                                continue;
-                       if (tmp < 0 || tmp > BITS_PER_LONG * PAGE_SIZE)
+                       if (tmp < 0 || tmp >= BITS_PER_BYTE * PAGE_SIZE)
                                continue;
 
                        set_bit(tmp, inuse);
                }
 
-               n = find_first_zero_bit(inuse, BITS_PER_LONG * PAGE_SIZE);
+               n = find_first_zero_bit(inuse, BITS_PER_BYTE * PAGE_SIZE);
                free_page((unsigned long)inuse);
        }