Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7367288yba; Thu, 2 May 2019 08:41:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyg7DeCuFiW8MXuanLhEXeidAan6J5OFTwX9A9yFT9rNriw3ZQ160PVO+OZ+RXBF23aXnVA X-Received: by 2002:a62:448d:: with SMTP id m13mr5056386pfi.182.1556811703610; Thu, 02 May 2019 08:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556811703; cv=none; d=google.com; s=arc-20160816; b=GFhvUF+ZS5eBpAVMh+3/DKCiQqd9bE3DYRzss95GOxnizCJsW2yDXlLKGZaQZRXEd1 Nxk1/pySLytuaXD0iLKkVyM6OTvF0RyR9m22BY50KqLD8n98WZADicDqhBVH05oxuBfi EfGl5/yNoZ2zzc1EWo0PsujDxvzWbUAyY9z59pBV+38rMLfHhd6YmusIKwyOfuM32ioJ dRBjS4EptfusAzkxvPRfW37+KkSvu0pYrlcrofj38GFJVTXLEKfm3JlTqRp9rHuOT0nu XOi/XUqM0dE00O+/FgYoG7600I+sp+r2jnL4vhkrc+cf7Jz7jx1WLAOW+GDzlYMTuJiZ Ab4Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1Nky8x91a4ZuMkGrTUkRThXrgzcp0vUeiNSvjX+R1PI=; b=RSpXaOUSA2n/C5jG1o70d+onQKw/pHmMDQVX/wpX8n9DehQT7KcId4NtfL366BllnL H1OgPalbNK0L5vdTpCDyXSCQ6xJG2Zo6xWcUvVbN1WJpDAAueO4UAUcTRLNr9WjT0hqW cAkITYEPJ2hIiFHaH8nExm87zt0GPVYGjvJzBPcd7yvPO7qoRMzKgYy8ColbXdg9j5ab iKXnLg5IQc5mHagn2VxokdkIci1Vj2EslnvVo84nWyV3aAxPSsUlGyx4Jsy6Bn2+Ordx azMrQ0EoTnO365evBO2NA+bL2Osvqi8/jIc/5BO23JT+UdBP/t5ShhMfOcYa8nS9w7rC o1sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zPs87Vcm; 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 67si12763458pfe.269.2019.05.02.08.41.28; Thu, 02 May 2019 08:41:43 -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=zPs87Vcm; 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 S1728534AbfEBPkG (ORCPT + 99 others); Thu, 2 May 2019 11:40:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfEBP3Y (ORCPT ); Thu, 2 May 2019 11:29:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 71C5320B7C; Thu, 2 May 2019 15:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556810963; bh=NDvVz4P9ETnzeV1AMycWhc1GB4KZgJcAaZTW4I65oug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zPs87VcmCIzl+kLtW3XC8VsOOiokBxP+yejs7TOHWKGC2Yri9HJ69ZJ+++18vZMNu bbcKbylAaOjf+zxW8wnyFeOO4euNALhuEONtnfsqokTr2miWMjAdV4MMidE6jRjszB 3m75qDAAWt6IuT/HTbwG42wZRSW8Aef2GpZIoyW4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?V=C3=A1clav=20Zindulka?= , Pablo Neira Ayuso , "Sasha Levin (Microsoft)" Subject: [PATCH 5.0 023/101] netfilter: nft_set_rbtree: check for inactive element after flag mismatch Date: Thu, 2 May 2019 17:20:25 +0200 Message-Id: <20190502143341.384720385@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190502143339.434882399@linuxfoundation.org> References: <20190502143339.434882399@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 fa61208371f8..321a0036fdf5 100644 --- a/net/netfilter/nft_set_rbtree.c +++ b/net/netfilter/nft_set_rbtree.c @@ -308,10 +308,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; @@ -320,6 +316,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