netfilter: fix int overflow in xt_alloc_table_info()
Subsystems (3)
PATCH 1/1 netfilter: fix int overflow in xt_alloc_table_info()
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().
--- net/netfilter/x_tables.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/netfilter/x_tables.c +1 -2
@@ -39,7 +39,6 @@ MODULE_LICENSE("GPL");MODULE_AUTHOR ("Harald Welte <[email protected]>" );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 4096struct compat_delta {
@@ -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 );
Signature · 1 line
2.15.1.620.gb9897f4670-goog
Quoted 34 lines · Dmitry Vyukov
syzkaller triggered OOM kills by passing ipt_replace.size = -1 to
IPT_SO_SET_REPLACE. The root cause is thatSMP_ALIGN()inxt_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 inxt_alloc_table_info().Reported-by [email protected]Signed-off-by Dmitry Vyukov <[email protected]>Cc Pablo Neira Ayuso <[email protected]>Cc Jozsef Kadlecsik <[email protected]>Cc Florian Westphal <[email protected]>Cc "David S. Miller" <[email protected]>--- net/netfilter/x_tables.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/netfilter/x_tables.c +0
-1@@ -39,7 +39,6 @@ MODULE_LICENSE("GPL");MODULE_AUTHOR ("Harald Welte <[email protected]>" );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 4096struct compat_delta {
net/netfilter/x_tables.c struct xt_table_info *xt_alloc_table_info(unsigned int size) · line 1005
Quoted 8 lines
net/netfilter/x_tables.c +1
-1@@ -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 );
Ping.
Dave, will this go into net/net-next?
Quoted 6 lines · Dmitry Vyukov
syzkaller triggered OOM kills by passing ipt_replace.size = -1 to
IPT_SO_SET_REPLACE. The root cause is thatSMP_ALIGN()inxt_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 inxt_alloc_table_info().
Applied, thanks.