Received: by 10.223.185.116 with SMTP id b49csp1059532wrg; Fri, 23 Feb 2018 11:10:12 -0800 (PST) X-Google-Smtp-Source: AH8x225IwA7Q/vkJGJyOJ6810du067HoIsDo6KjLd14GM8POSjMk5edNfAI4t/IYQE39SuWkRGFM X-Received: by 2002:a17:902:22f:: with SMTP id 44-v6mr2584610plc.418.1519413012231; Fri, 23 Feb 2018 11:10:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519413012; cv=none; d=google.com; s=arc-20160816; b=BqruDcTvOrxe9lsXcVeIUdXc7jCRUiDPPwnL7qhaliKF/tnHaRhGCc/5DXt+4XOAoB rLavy+Rki0I4xqbE5Shy2D4JaYYMgczVypjjqLHf7UhVjiw1IwKTdGDl3RM/It11amuR qXePNq6vV1hp51tMgURLPTilHy/hLAllRJ3ZVmHG2uOlk3U/vGPW82P9vT3BHn2BappP v56TsbUE0NT25kOYPw52Q3gV11n0bqYp4+DNC2SWQZ4WU6vF5femV3Fgx1kmdjfbikG5 HQ1bmAEQ6zaxr1kybjjOUs6jkC7jlK8Nd/jjiLc2xGcQ2PQXpe/c5kJKQ48WCKAqpTxH cvdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2BXqbO32PxuwbvW3hoHZbfPIKU/BKZBrF+FtANLbc6g=; b=LvOy6wFFq1wUaRltnuWJ4FoTaC1ajm0t/tfSQal/TAMAVrhsw7/4/CiJL4AnvLNtsa Jmj/ddBoHVvPSQGHTqSlVw4nRiBcdvps2ohkoPMFuXqGsiZSqKdBrqzP6VY8hLBlfqtD 4JkLyEfbB68ULPdJ+N9nRr2WduQhd38NR19v2kDu105PYA7XGPsgQEy5KtYiFH2iqurf H40E5LDHevxENcU3Edf67O5GjPBoKL6moc43Q3ylbTaDjBoYOUebELjTDMIwmwplgqbO 0o9xFMrfosONCzvYClb87LQeAurc4V8x9ert3pD4He6V9sgtv7eKgCsZW+US3ZCT9aJy WMjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si2242938pfg.246.2018.02.23.11.09.57; Fri, 23 Feb 2018 11:10:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935514AbeBWTIL (ORCPT + 99 others); Fri, 23 Feb 2018 14:08:11 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50084 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965342AbeBWS5S (ORCPT ); Fri, 23 Feb 2018 13:57:18 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7F21D107C; Fri, 23 Feb 2018 18:57:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+4396883fa8c4f64e0175@syzkaller.appspotmail.com, Dmitry Vyukov , Pablo Neira Ayuso Subject: [PATCH 4.15 13/45] netfilter: x_tables: fix int overflow in xt_alloc_table_info() Date: Fri, 23 Feb 2018 19:28:52 +0100 Message-Id: <20180223170717.445038853@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170715.197760019@linuxfoundation.org> References: <20180223170715.197760019@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Vyukov commit 889c604fd0b5f6d3b8694ade229ee44124de1127 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: Dmitry Vyukov Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/x_tables.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- 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_inf 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);