From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3C79C2D0DB for ; Fri, 24 Jan 2020 11:12:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81D802071A for ; Fri, 24 Jan 2020 11:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864368; bh=79BzIEImy9GA1cgjPsnC4XGO1UI7iCCrXjwEuGO0WPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=083k2jB68lKF3weoxSlaGnWFuRv7VGz1InEQO1mxFKxw1y+6CVglQGRzWwsjWxs2t /HbiLbuAguxYhvRMrV55bz4XCuHR56/elIf3a6K1OVASBLHyaS9HF7SAgSr/WRl39L dulD7e7eCD8+QOSI/0B9OG5+6lEFTVgp3Zbx3CSg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390004AbgAXLMe (ORCPT ); Fri, 24 Jan 2020 06:12:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:48838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387877AbgAXLMa (ORCPT ); Fri, 24 Jan 2020 06:12:30 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (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 37F4120708; Fri, 24 Jan 2020 11:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864350; bh=79BzIEImy9GA1cgjPsnC4XGO1UI7iCCrXjwEuGO0WPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZM3Q9UwdkmoqWk+l76ibyhuTLEyITnNrNDPtK8uttd+zmD7S/uMt+iR9ZyZ0VHX+H tjKFnBKCjSNCcwu5Aikc52C+mxjqy5pZRMRXCg8UstUNzrEywYCwgSj0ckcnA5+JF+ E2qnDndhgHsosJTZe/un441EfYMLfH6QfL2ZjhSs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.19 242/639] netfilter: nft_set_hash: bogus element self comparison from deactivation path Date: Fri, 24 Jan 2020 10:26:52 +0100 Message-Id: <20200124093117.120261624@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@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 From: Pablo Neira Ayuso [ Upstream commit a01cbae57ec29b161d42ee1caa4ffffda5d519c2 ] Use the element from the loop iteration, not the same element we want to deactivate otherwise this branch always evaluates true. Fixes: 6c03ae210ce3 ("netfilter: nft_set_hash: add non-resizable hashtable implementation") Reported-by: Florian Westphal Tested-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_set_hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nft_set_hash.c b/net/netfilter/nft_set_hash.c index 8dde4bfe8b8a4..05118e03c3e48 100644 --- a/net/netfilter/nft_set_hash.c +++ b/net/netfilter/nft_set_hash.c @@ -555,7 +555,7 @@ static void *nft_hash_deactivate(const struct net *net, hash = nft_jhash(set, priv, &this->ext); hlist_for_each_entry(he, &priv->table[hash], node) { - if (!memcmp(nft_set_ext_key(&this->ext), &elem->key.val, + if (!memcmp(nft_set_ext_key(&he->ext), &elem->key.val, set->klen) && nft_set_elem_active(&he->ext, genmask)) { nft_set_elem_change_active(net, set, &he->ext); -- 2.20.1