* [PATCH] netfilter: fix int overflow in xt_alloc_table_info()
@ 2017-12-28 8:48 Dmitry Vyukov
2018-01-06 14:07 ` Dmitry Vyukov
2018-01-06 22:52 ` Pablo Neira Ayuso
0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Vyukov @ 2017-12-28 8:48 UTC (permalink / raw)
To: pablo, kadlec, fw, davem
Cc: Dmitry Vyukov, netfilter-devel, coreteam, netdev, linux-kernel
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>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Florian Westphal <fw@strlen.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
net/netfilter/x_tables.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 55802e97f906..e02a21549c99 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -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 {
@@ -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);
--
2.15.1.620.gb9897f4670-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] netfilter: fix int overflow in xt_alloc_table_info()
2017-12-28 8:48 [PATCH] netfilter: fix int overflow in xt_alloc_table_info() Dmitry Vyukov
@ 2018-01-06 14:07 ` Dmitry Vyukov
2018-01-06 22:52 ` Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Vyukov @ 2018-01-06 14:07 UTC (permalink / raw)
To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
David Miller
Cc: Dmitry Vyukov, netfilter-devel, coreteam, netdev, LKML
On Thu, Dec 28, 2017 at 9:48 AM, Dmitry Vyukov <dvyukov@google.com> wrote:
> 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>
> Cc: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
> Cc: Florian Westphal <fw@strlen.de>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: netfilter-devel@vger.kernel.org
> Cc: coreteam@netfilter.org
> Cc: netdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
> net/netfilter/x_tables.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
> index 55802e97f906..e02a21549c99 100644
> --- a/net/netfilter/x_tables.c
> +++ b/net/netfilter/x_tables.c
> @@ -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 {
> @@ -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?
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] netfilter: fix int overflow in xt_alloc_table_info()
2017-12-28 8:48 [PATCH] netfilter: fix int overflow in xt_alloc_table_info() Dmitry Vyukov
2018-01-06 14:07 ` Dmitry Vyukov
@ 2018-01-06 22:52 ` Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2018-01-06 22:52 UTC (permalink / raw)
To: Dmitry Vyukov
Cc: kadlec, fw, davem, netfilter-devel, coreteam, netdev,
linux-kernel
On Thu, Dec 28, 2017 at 09:48:54AM +0100, Dmitry Vyukov wrote:
> 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().
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-06 22:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-28 8:48 [PATCH] netfilter: fix int overflow in xt_alloc_table_info() Dmitry Vyukov
2018-01-06 14:07 ` Dmitry Vyukov
2018-01-06 22:52 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox