Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753384AbeAFOHa (ORCPT + 1 other); Sat, 6 Jan 2018 09:07:30 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:45454 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753230AbeAFOH2 (ORCPT ); Sat, 6 Jan 2018 09:07:28 -0500 X-Google-Smtp-Source: ACJfBot7gz6rPGXhwwPf5tsyoxPf2TkaXJeyul8q3hl2obmSlZ3hJzvKoP99y1pmzRuxlLIF6WLdavQbmImn0tVnSSI= MIME-Version: 1.0 In-Reply-To: <20171228084854.247843-1-dvyukov@google.com> References: <20171228084854.247843-1-dvyukov@google.com> From: Dmitry Vyukov Date: Sat, 6 Jan 2018 15:07:06 +0100 Message-ID: Subject: Re: [PATCH] netfilter: fix int overflow in xt_alloc_table_info() To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , David Miller Cc: Dmitry Vyukov , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Dec 28, 2017 at 9:48 AM, 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(). > > Reported-by: syzbot+4396883fa8c4f64e0175@syzkaller.appspotmail.com > Signed-off-by: Dmitry Vyukov > Cc: Pablo Neira Ayuso > Cc: Jozsef Kadlecsik > Cc: Florian Westphal > Cc: "David S. Miller" > 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 "); > 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?