Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4673739iob; Sun, 8 May 2022 21:30:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5xFyIZosZSUqsQIlpnAk6JsiPSQb+fkwKvRAwj59yMvye3DlEUSIpxFAapw/M+/7ZSbJ+ X-Received: by 2002:a05:6a00:1146:b0:4c9:ede0:725a with SMTP id b6-20020a056a00114600b004c9ede0725amr14400177pfm.35.1652070599846; Sun, 08 May 2022 21:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652070599; cv=none; d=google.com; s=arc-20160816; b=ebp+MYQK9cF35zCK2UbGN1DDu0E1BS0wcGfqNeTUUv2AWiXDYLRZqqpRX3QDpCup59 57eBqD3FFotWIxHDZ1nYIZ79Yn693JDI/Q7rFkCylAyirpMCB3PwaxRXR6rH0yi/2jZ4 FWM3vViktEXsO9fJrp1ONs5oWitFi7eYY4puSHg60CTxrhLa7oEjAzRm7xf9jY2AIs6f uzjfvef8m1GAntJlLP5IAHElU6VCcSpUEkwR0IiWfN2uVAPNxZauEXZykJzyolDQ3E5O 1mTCIejQtnGEUkpdSnQ9RBsumF1AkBZHIHpZZxXRWUw51/pLx0lNQVbwV08QfA526UqE 1T4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H2QkCXRUbBfnGxpFfnEq5YAOODOgopAoK1Amaz6er3Q=; b=enovRghXjDLJw/+Q+4kC3fObwRNWKsYJVpOFy66o52vascyIJ4XvbKpyXoVAa4GRhH WFKqZnL6O46dBr4fdofNCEm7yf3HGxARCO+V8zd2JeHFeGXWdJ3PEW0khm7oWGgK0BvN LBgGj9ADVMJFTNBNtpCZxzjVC72ZOp541CE/cAZs90qtRnTNSS5dGFy2SaXCsuUaeezY +Ch3sBQ2fAR6b/d9NS4dnBGBO4w3ZcRmba8NdRgoZn5NWrR5+0MCOxIDmcTPWPf3jjuG 6LGgcsJxIF9cC41TOcWZj03InJgimiS9R3GCanLh1z0UQGL4UEySJoe8rEL4jbMEzGoa T8qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dzXANxX2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p19-20020a170902e35300b00158bfb59d03si8727926plc.382.2022.05.08.21.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 21:29:59 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dzXANxX2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AEC29121219; Sun, 8 May 2022 21:29:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355998AbiEDRQa (ORCPT + 99 others); Wed, 4 May 2022 13:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355963AbiEDREs (ORCPT ); Wed, 4 May 2022 13:04:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DD8D4F9FC; Wed, 4 May 2022 09:53:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D700D61505; Wed, 4 May 2022 16:53:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28C23C385AA; Wed, 4 May 2022 16:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683216; bh=eidVBpEHpfCZhtqWZN0t3L727DuGTceR+6ii9207lXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dzXANxX2pAT6TwfowZT6cSxMMbjhSSKEe4/aPLlo0mAVovp9XMSj2TOotpfoMm8c2 8D1+qQuX4bqssfI9I4dIEYMDhxT7aD28Ra7RSvRiGIto81bOo4/7Xv49KQCrOP0z2j xxR5J7goZ4vqXK+4yO7SGg4RXDfQAd9mpnVs4eFA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso , Stefano Brivio , Sasha Levin Subject: [PATCH 5.15 081/177] netfilter: nft_set_rbtree: overlap detection with element re-addition after deletion Date: Wed, 4 May 2022 18:44:34 +0200 Message-Id: <20220504153100.311608257@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit babc3dc9524f0bcb5a0ec61f3c3639b11508fad6 ] This patch fixes spurious EEXIST errors. Extend d2df92e98a34 ("netfilter: nft_set_rbtree: handle element re-addition after deletion") to deal with elements with same end flags in the same transation. Reset the overlap flag as described by 7c84d41416d8 ("netfilter: nft_set_rbtree: Detect partial overlaps on insertion"). Fixes: 7c84d41416d8 ("netfilter: nft_set_rbtree: Detect partial overlaps on insertion") Fixes: d2df92e98a34 ("netfilter: nft_set_rbtree: handle element re-addition after deletion") Signed-off-by: Pablo Neira Ayuso Reviewed-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_set_rbtree.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c index d600a566da32..7325bee7d144 100644 --- a/net/netfilter/nft_set_rbtree.c +++ b/net/netfilter/nft_set_rbtree.c @@ -349,7 +349,11 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set, *ext = &rbe->ext; return -EEXIST; } else { - p = &parent->rb_left; + overlap = false; + if (nft_rbtree_interval_end(rbe)) + p = &parent->rb_left; + else + p = &parent->rb_right; } } -- 2.35.1