Received: by 10.223.185.116 with SMTP id b49csp1145514wrg; Fri, 23 Feb 2018 12:45:25 -0800 (PST) X-Google-Smtp-Source: AH8x227QyB27zbiz88AyUf31BYnZSHJYrmuek7X3YKTx6GKLYlimKUHFj7oBRGoDY8LVAbmARFCp X-Received: by 2002:a17:902:4d:: with SMTP id 71-v6mr2832843pla.341.1519418725777; Fri, 23 Feb 2018 12:45:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418725; cv=none; d=google.com; s=arc-20160816; b=WM0mDhv5swN23T+cLnIazqDN5WArq0KBjQXJrCVenfx+jJiAkBYKUgawjzy4kGX2Ie OuXzz7kvgrPvqMAjdld+fnqyt8FcxDvgfF5a+3sHHLJeEefbgPsRpSSHbkvEt3YYwBB2 SB9wTCpnoWTOjFrJI8igcQM1oGLYrNYt7P1bFBIx++krjDTojiE46EW53kdfgELhvIMu NJod1J2Peh50FlAaOod++jsLLRDYvklod1q8E38BvU7PyBq3nMOqtDGdLaAey2LdTzZA 4HWWFWdR4ElywYXGG6weuhu6jh2Vjb+Knn4xvnTT67sTBxcCz85OXdZtMJUIqaB4bZoj wmZg== 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=cvOC+6qnWEQHzpKgIl6r3fHUvFfYmO3tts/IVjVimE0=; b=i2kQZbiXBhgSOdGbNbxvb6hse6KK+Hcfh6xaOHYSjSdspNUajBom6XTtxsbgN4GEn9 aDifjSToCdX9ehWq0YLD7LHktHpDw7QSj20rMh/QUmzkPiMqWI84eK+KLhGeBxdYPNco q2PQ2Uv918S/EvuJNiZjD2BovdsUPvD2Wqppdp3vZRSDL026u1aD70ZRMMfOOu5UiLua v2DJEo9DJcZ4GNOBg12O84PIvHJJZh2h0S6iwKQ0F0Shr4tHsU8hbkIxi2iWTrndy2yD L46ioI33kjLHIX3jVLt1jPvTiHKPg9yi0/yVrPxytXQGxMruAvT4Z4v3Gs3h1eBdEQ8O F/+A== 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 g66si1937564pgc.374.2018.02.23.12.45.11; Fri, 23 Feb 2018 12:45:25 -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 S1753118AbeBWSdJ (ORCPT + 99 others); Fri, 23 Feb 2018 13:33:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36432 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753099AbeBWSdH (ORCPT ); Fri, 23 Feb 2018 13:33:07 -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 C323F1070; Fri, 23 Feb 2018 18:33:06 +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.4 015/193] netfilter: x_tables: fix int overflow in xt_alloc_table_info() Date: Fri, 23 Feb 2018 19:24:08 +0100 Message-Id: <20180223170328.496659583@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@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.4-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 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -38,8 +38,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)) - struct compat_delta { unsigned int offset; /* offset in kernel */ int delta; /* delta in 32bit user land */ @@ -954,7 +952,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; if (sz <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))