Received: by 10.223.185.116 with SMTP id b49csp1076654wrg; Fri, 23 Feb 2018 11:29:56 -0800 (PST) X-Google-Smtp-Source: AH8x226nlTchHeyvZT9f3ae2XV8f7j8RYMkqkF7dBChzMrwWe/Lzk6JFHA7gNMFRFzIn6CcHKB6f X-Received: by 2002:a17:902:6b02:: with SMTP id o2-v6mr2719304plk.334.1519414196493; Fri, 23 Feb 2018 11:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519414196; cv=none; d=google.com; s=arc-20160816; b=mk2Otgs67y6LbUy5OW39FW4tIXyOZLi5hPtT9MOlW38+8ypsVXdPFsS0LEjMIn8luT LnDx5ZU4eYlGM2pfa5RkQJ0WC55epcEh4dTsw/BWbk1WOdQJ6lguX2z0cZdY4LLmePbB /mYZivAiGa9vPdSP0MlYPZ2WaDD5XPBhd0d4uOVl8zYkXCLYOcyYhAhlgs1EORp5g/aV VXQm4gEGoELB/cej0yxEX5vNeNeFu+d0aYinEPe0QjIRNkKY51c2cVZ6Zv0Cmpum8B7e za1Nqt4M53B5UCcBO9qEOgYGrvwA9M0hjfmJQxFo4raEd+m+paG+5v+/Pl2YuaD6OV6N Hvvw== 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=7f/qkVfyKszcpu/4EEnvjeXI5dzsMUF3NcBG1lFPjFA=; b=gWo4j7dAX8ztXylHgOKU+Tq9K7++fb51w6HfTVGVhAXRIfuV+uYJntk8bVeAQqEyeZ vbUTSecozXbHospduIvZa4VPlS8+wklVI7PYQA/UX902g/nbgNmOL1mJKmdnwQAfu7Bz woCoBvcZeHoPWpXORlQ3EYKEsHc8IZKHFpOM0XDG9X836bVmiVpyLJ3kIo+Hxr13aC57 eCuZZVu/unMBeymJPD4mQmQePaI44VADIA1gspV3EU05JtNnP1+u7NPA4yLoViO8sku7 OPPsQ4K7K6cBLBg8+eVDk52K6x3uMVKQrOMtuEQZxU3QRvLXtQN7T9MfTq3GuEq+obAH +1oQ== 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 n3-v6si2186389plb.817.2018.02.23.11.29.42; Fri, 23 Feb 2018 11:29:56 -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 S1754678AbeBWT27 (ORCPT + 99 others); Fri, 23 Feb 2018 14:28:59 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46438 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934465AbeBWSwB (ORCPT ); Fri, 23 Feb 2018 13:52:01 -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 7A105728; Fri, 23 Feb 2018 18:52:00 +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.14 035/159] netfilter: x_tables: fix int overflow in xt_alloc_table_info() Date: Fri, 23 Feb 2018 19:25:43 +0100 Message-Id: <20180223170747.676382424@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@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.14-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);