Commit 9626ac65 authored by Dmitry Vyukov's avatar Dmitry Vyukov Committed by Greg Kroah-Hartman

netfilter: x_tables: fix int overflow in xt_alloc_table_info()

commit 889c604f upstream.

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: default avatarDmitry Vyukov <dvyukov@google.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9435c32b
...@@ -38,8 +38,6 @@ MODULE_LICENSE("GPL"); ...@@ -38,8 +38,6 @@ MODULE_LICENSE("GPL");
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
MODULE_DESCRIPTION("{ip,ip6,arp,eb}_tables backend module"); MODULE_DESCRIPTION("{ip,ip6,arp,eb}_tables backend module");
#define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
struct compat_delta { struct compat_delta {
unsigned int offset; /* offset in kernel */ unsigned int offset; /* offset in kernel */
int delta; /* delta in 32bit user land */ int delta; /* delta in 32bit user land */
...@@ -954,7 +952,7 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size) ...@@ -954,7 +952,7 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
return NULL; return NULL;
/* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */ /* 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; return NULL;
if (sz <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) if (sz <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment