Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2909779yba; Mon, 22 Apr 2019 15:30:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzr2cwc4HRPWy94D2C1uUnI7dOtufkQFvAfUS/6WXDdX1iSp/9APfarLYnirTB0qlmgwRl X-Received: by 2002:a65:64cf:: with SMTP id t15mr21445196pgv.322.1555972249922; Mon, 22 Apr 2019 15:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555972249; cv=none; d=google.com; s=arc-20160816; b=UPADGllqX17fxunVnJPBMvYGaOlrRNxeMgNgTj3fCuuVz4hWYXJpvCYFIIHotwUKaS e1OAy7ISebe61xbpVySetk3eXJssFDhIC8xlJ6L1d8z2F/Q7C99rkekgupbnT9l1ZHlo /TPRYKIPQyfYLyXAbydF1yfcqFsZc1yshjb/ezJg1FSCjXD7xsgCsxosZcAxNWlzhylY N1LbYjOBYg1x8FAEEVyg6KN8Db539xgcars7eq56Q4WyM3VjXHJAiNIC6RljThwi8OgB GtxETYjtYXzrLTa4Xw4hEaTwBxYbkN9sJcAzq8OoBK8ZZCxoqLLyeqbvwQKuszWLAzh0 2azA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dp4X+RCqz5kIUY7DN0soGelXOz814Ns7v7sSmNHSGMo=; b=jAVm/0yKxKYxB/e0cDl4MfKDxmPZeczDj//A6FyLtHUmQSnXHD/eKuq6+KG1jOhtx/ FQTAKUcwOWa+Wq+axEVT+obsc40cmyQ7kijSEpdO7ZFUR7fB2nwcesT+z5DX/K6HsvhY jojfkUhguCAdy9bSwViDlbtRsP9JghJDJjTooFbier+7Vb1VMQc3NUyOo1++RtVkHD34 tzzJpWU1mINsLH7mxEUb1TNV9lp6dP6xCh5EZAGVEN6Z/+jf3WDO8WidqthYKRpafLy8 aychSYOktyJV81GMF0AfAcYYt82xRjHp/+G+OzKMm/tR1fDnZI12aPeMNooH68LqPi3q wz8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PRQVgy7t; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w11si13897846plz.403.2019.04.22.15.30.34; Mon, 22 Apr 2019 15:30:49 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=PRQVgy7t; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729825AbfDVTpl (ORCPT + 99 others); Mon, 22 Apr 2019 15:45:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:47440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729791AbfDVTpi (ORCPT ); Mon, 22 Apr 2019 15:45:38 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B9D9218DA; Mon, 22 Apr 2019 19:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962337; bh=u/A/qeduHJvty0UNNiiEwnlbE7+QlX6u4fj0ynhjukI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PRQVgy7t4OhUg5WS1G6ydi4TJSsIxVLJP3q8z6s6RB7Zv0dtGvP6RYo+ZoTYxV+Cr g2cb9fQQJ7UCJsJ9UomTZv5sS3KS9Jvh4VSrS/vpb3b8wSRSkNRAXJv+QToMA8T8ZL fgiJ0Mu2DnEEJTzNE0qUN1cWJjs6oMU1sjKV/dG4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pablo Neira Ayuso , Sasha Levin , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 10/68] netfilter: nft_set_rbtree: check for inactive element after flag mismatch Date: Mon, 22 Apr 2019 15:44:18 -0400 Message-Id: <20190422194516.11634-10-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit 05b7639da55f5555b9866a1f4b7e8995232a6323 ] Otherwise, we hit bogus ENOENT when removing elements. Fixes: e701001e7cbe ("netfilter: nft_rbtree: allow adjacent intervals with dynamic updates") Reported-by: Václav Zindulka Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin (Microsoft) --- net/netfilter/nft_set_rbtree.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c index 0e5ec126f6ad..b3e75f9cb686 100644 --- a/net/netfilter/nft_set_rbtree.c +++ b/net/netfilter/nft_set_rbtree.c @@ -302,10 +302,6 @@ static void *nft_rbtree_deactivate(const struct net *net, else if (d > 0) parent = parent->rb_right; else { - if (!nft_set_elem_active(&rbe->ext, genmask)) { - parent = parent->rb_left; - continue; - } if (nft_rbtree_interval_end(rbe) && !nft_rbtree_interval_end(this)) { parent = parent->rb_left; @@ -314,6 +310,9 @@ static void *nft_rbtree_deactivate(const struct net *net, nft_rbtree_interval_end(this)) { parent = parent->rb_right; continue; + } else if (!nft_set_elem_active(&rbe->ext, genmask)) { + parent = parent->rb_left; + continue; } nft_rbtree_flush(net, set, rbe); return rbe; -- 2.19.1