Navigation Menu

Skip to content

Commit

Permalink
netfilter: x_tables: check for size overflow
Browse files Browse the repository at this point in the history
Ben Hawkes says:
 integer overflow in xt_alloc_table_info, which on 32-bit systems can
 lead to small structure allocation and a copy_from_user based heap
 corruption.

Change-Id: I13c554c630651a37e3f6a195e9a5f40cddcb29a1
Reported-by: Ben Hawkes <hawkes@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Florian Westphal authored and mdmower committed May 24, 2016
1 parent 54b2ee6 commit cc7c645
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/netfilter/x_tables.c
Expand Up @@ -664,6 +664,10 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
{
struct xt_table_info *newinfo;
int cpu;
size_t sz = sizeof(*newinfo) + size;

if (sz < sizeof(*newinfo))
return NULL;

/* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */
if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > totalram_pages)
Expand Down

0 comments on commit cc7c645

Please sign in to comment.