Received: by 10.223.185.116 with SMTP id b49csp1144506wrg; Fri, 23 Feb 2018 12:44:19 -0800 (PST) X-Google-Smtp-Source: AH8x2242Vivz5PzBehYTQxXBddRtq9GElNaUaXSQF6SZfC4aAwRKzZ/IPZ4PSzaO9dOPD4gVopV2 X-Received: by 2002:a17:902:b591:: with SMTP id a17-v6mr2925721pls.118.1519418659567; Fri, 23 Feb 2018 12:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418659; cv=none; d=google.com; s=arc-20160816; b=qMq8aoyDjGxGJH7BsRNwB1cTEqKmp6PPCUOZ90lUG9tLUEUuJsMfC6GxdBbaFTu1Sw 75tEKkX8kXvjB+CcP8w9GjrxOLTeeZzehd6sZy6ZSzc9EdVgfCMLliudErGki3V0IhAp ENYOU5/3+Nfyc/3umm/EOCQAZ/QxTibg8sz4nR4roJZkHcWQ4N/9xYPwJqrpWsvMkl2s OsbCEvmw5C0o0mfOjDAdPy/wXg3HY8+2PcDWO6ZVxXHhkGe1cH1ZzIOOTLcqQdDuXEU8 eVx/4ecpt+9V8RTn145VjOLaWIbF4wuVehByTUuydoByBNx+ItxoLq5IzGRdgBLbn/Ii M29w== 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=6TxRH9qQw5BWV7qSHI/m/nXZGZ5Mk98vwWJ3o+TURro=; b=OcZio6eBHflhg8tnIo9IZk2NU268rJeK3KKwt9JaBcn6Uv7UJzitSwHBlnV47tdgCP feux/VcbBUm27Ws7ZCSRBsOJycoPYveNpnyBVyoMqLl1sQ1qumBQ8R6ocGm9/ExZWllQ sDn5LXNfbts9TPM5GUxgaugRnzyCa5zLXFUgapqgfksDVzTCJNdHbS33i/x76w/12LUj fgkXM7La+IuRBW2HdBR3OClY9Ru/Lvv3/qsntyqNizq52At/4I7alOTMrZoUir1zP5xq u2VrxxwhKKXhTUpig5LkLjE3rFfREAkLy0Ap7YMMUAisNATJ+0EnbTJ9/YjZB1ozeGF+ dRpg== 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 w62si1904110pgd.573.2018.02.23.12.44.05; Fri, 23 Feb 2018 12:44:19 -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 S1753164AbeBWSdQ (ORCPT + 99 others); Fri, 23 Feb 2018 13:33:16 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36464 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753102AbeBWSdN (ORCPT ); Fri, 23 Feb 2018 13:33:13 -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 CFBC410EA; Fri, 23 Feb 2018 18:33:12 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Vyukov , syzbot , Pablo Neira Ayuso Subject: [PATCH 4.4 017/193] netfilter: ipt_CLUSTERIP: fix out-of-bounds accesses in clusterip_tg_check() Date: Fri, 23 Feb 2018 19:24:10 +0100 Message-Id: <20180223170328.783017063@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 1a38956cce5eabd7b74f94bab70265e4df83165e upstream. Commit 136e92bbec0a switched local_nodes from an array to a bitmask but did not add proper bounds checks. As the result clusterip_config_init_nodelist() can both over-read ipt_clusterip_tgt_info.local_nodes and over-write clusterip_config.local_nodes. Add bounds checks for both. Fixes: 136e92bbec0a ("[NETFILTER] CLUSTERIP: use a bitmap to store node responsibility data") Signed-off-by: Dmitry Vyukov Reported-by: syzbot Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/ipv4/netfilter/ipt_CLUSTERIP.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c @@ -365,7 +365,7 @@ static int clusterip_tg_check(const stru struct ipt_clusterip_tgt_info *cipinfo = par->targinfo; const struct ipt_entry *e = par->entryinfo; struct clusterip_config *config; - int ret; + int ret, i; if (par->nft_compat) { pr_err("cannot use CLUSTERIP target from nftables compat\n"); @@ -384,8 +384,18 @@ static int clusterip_tg_check(const stru pr_info("Please specify destination IP\n"); return -EINVAL; } - - /* FIXME: further sanity checks */ + if (cipinfo->num_local_nodes > ARRAY_SIZE(cipinfo->local_nodes)) { + pr_info("bad num_local_nodes %u\n", cipinfo->num_local_nodes); + return -EINVAL; + } + for (i = 0; i < cipinfo->num_local_nodes; i++) { + if (cipinfo->local_nodes[i] - 1 >= + sizeof(config->local_nodes) * 8) { + pr_info("bad local_nodes[%d] %u\n", + i, cipinfo->local_nodes[i]); + return -EINVAL; + } + } config = clusterip_config_find_get(par->net, e->ip.dst.s_addr, 1); if (!config) {