Skip to content

Commit

Permalink
netfilter: x_tables: fix int overflow in xt_alloc_table_info()
Browse files Browse the repository at this point in the history
syzkaller triggered OOM kills by passing ipt_replace.size = -1
to IPT_SO_SET_REPLACE. The root cause is that SMP_ALIGN() in
xt_alloc_table_info() causes int overflow and the size check passes
when it should not. SMP_ALIGN() is no longer needed leftover.

Remove SMP_ALIGN() call in xt_alloc_table_info().

Reported-by: syzbot+4396883fa8c4f64e0175@syzkaller.appspotmail.com
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Dmitry Vyukov authored and Pablo Neira Ayuso committed Jan 6, 2018
1 parent d1616f0 commit 889c604
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/netfilter/x_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ MODULE_LICENSE("GPL");
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
MODULE_DESCRIPTION("{ip,ip6,arp,eb}_tables backend module");

#define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
#define XT_PCPU_BLOCK_SIZE 4096

struct compat_delta {
Expand Down Expand Up @@ -1000,7 +999,7 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
return NULL;

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

info = kvmalloc(sz, GFP_KERNEL);
Expand Down

0 comments on commit 889c604

Please sign in to comment.