Received: by 10.223.185.116 with SMTP id b49csp1108132wrg; Fri, 23 Feb 2018 12:04:43 -0800 (PST) X-Google-Smtp-Source: AH8x2242chvPbrrW9iGhLKDs7+fc/xU9k9/3WbwwVKdQdUi2AmTmqS9dfdjMDTOuxdldL/uDCp0k X-Received: by 2002:a17:902:a607:: with SMTP id u7-v6mr2673319plq.367.1519416283631; Fri, 23 Feb 2018 12:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519416283; cv=none; d=google.com; s=arc-20160816; b=BIvnqk0zeH+gjyWLgQbp6bfWOlofdDHKVBicu+yqDnjhEPliGTljcl7DHEVFoRHbj/ G+hvMR/4g+LhwO/rOBqVdz9WNKrzvhBD5lEtwLfB4PT6UcHIoe3Szci2sknQksOf6PXP alLxU6V+oCvKiUl1skTdSeNOf23sgHZvbh894h1MZ1I3lpJzzNe4h00Lrpx+1ydYEkLk hxDp8NYbT9uhSv7jxdup0HSo5j2nUDBXPfatH8gHwiZ2LiMsZSUotQuXHEeESIvaeo8K KwaIjTFzeH1l5KDM8yUe74t8y2l37aOq0G0TuqqRGQDVMOa648oor4OQEf4PG3JstW2B lwWA== 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=2TBIkk58oUh2E2CqxB7ckp2CaxyYv/FRxP+jGeBuUpM=; b=vW5K+zX8scfmywSMTn3jSdjADrt8LO2BfLorTMaIDsomPi1GN5Hfqxh4yHkGQoEJj3 eggjArzVeKpm2wnaHLRJo+ovxujbM510EwA5JNB919BcDzHV+81bjdxfQNcGTJtcymo4 Kb3mIP8hcE3Pffk7d9XE8JodI+e0ljxpbsEHCoCPSjsZlKdMfaWN6C9IZzcVP3prVANR QIL8673uye5HK1fm1q872CmBvl2tsHQlFKqAfAQ6c4I28vUj/so4BTPQFbjsZ2HXJ4SC QgfGMANBjK7/Nd8N4wnFfIElZBAET4V5Xajmt1EThKvyzJ4rJRfJhV5CLkNlZOrxcCVw OttQ== 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 n6si1895494pgr.31.2018.02.23.12.04.17; Fri, 23 Feb 2018 12:04:43 -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 S933183AbeBWSnA (ORCPT + 99 others); Fri, 23 Feb 2018 13:43:00 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41998 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932515AbeBWSm5 (ORCPT ); Fri, 23 Feb 2018 13:42:57 -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 D6415104C; Fri, 23 Feb 2018 18:42:56 +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.9 022/145] netfilter: x_tables: fix int overflow in xt_alloc_table_info() Date: Fri, 23 Feb 2018 19:25:28 +0100 Message-Id: <20180223170727.519726218@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@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.9-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 @@ -39,8 +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)) - struct compat_delta { unsigned int offset; /* offset in kernel */ int delta; /* delta in 32bit user land */ @@ -952,7 +950,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))