From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C335925A2BF; Mon, 12 May 2025 17:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747071846; cv=none; b=IK+OVMVQNvahY/N22uT17TkT72CyJU/Q2F0NWigFkCZ4Mn5LGU6MlQNpYFpW2kF69+SbPGpvFyCV9Hdcbcy62dquO0JYxKruKxPNgZPVapwIaWcCuBXYnhRywHTDu/ZRZFDflKxDVoNq9qSkQ6oEKomDIsRcj4lwFRLbAhLcmEA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747071846; c=relaxed/simple; bh=Fd7otjbKaKlXuUxYUlp4NrUZkGaPw3MtTlw9u6ZTb7k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dd5KUxKaeuLAvJteuSGoCkaLULqdCPz7S+gDHfAOKJR/LnNWgH/Q2jkyRxE2Or+zVEg2HnQc28xiJDCbSsvik99YoPCuSJjZLn8b82pYQ+vQHKhwfhHGOvww4IEuCT9NCmIp/QdD4+5vFZGUWh7APuiwX1x/eEKx5BtP94edCOQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VgdkfaX3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VgdkfaX3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54462C4CEE7; Mon, 12 May 2025 17:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747071846; bh=Fd7otjbKaKlXuUxYUlp4NrUZkGaPw3MtTlw9u6ZTb7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VgdkfaX3xCw0XVTnJ7xMPI3WLkfYqDCtv3DN/y3rVgJ1INjkp/F1KEmNn+/SGwGnt hIM+HyPuwYMHtbNEMdwdw4anF/0Pzgeo3z6PtTF0O2yy539ZvLu6SG6jFE0uZlq40+ M2j3RnZNNhkIfk3WJwKWshJCbATFZHOFNToAAU6c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kota Toda , Jozsef Kadlecsik , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.14 032/197] netfilter: ipset: fix region locking in hash types Date: Mon, 12 May 2025 19:38:02 +0200 Message-ID: <20250512172045.670792027@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512172044.326436266@linuxfoundation.org> References: <20250512172044.326436266@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jozsef Kadlecsik [ Upstream commit 8478a729c0462273188263136880480729e9efca ] Region locking introduced in v5.6-rc4 contained three macros to handle the region locks: ahash_bucket_start(), ahash_bucket_end() which gave back the start and end hash bucket values belonging to a given region lock and ahash_region() which should give back the region lock belonging to a given hash bucket. The latter was incorrect which can lead to a race condition between the garbage collector and adding new elements when a hash type of set is defined with timeouts. Fixes: f66ee0410b1c ("netfilter: ipset: Fix "INFO: rcu detected stall in hash_xxx" reports") Reported-by: Kota Toda Signed-off-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/ipset/ip_set_hash_gen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h index cf3ce72c3de64..5251524b96afa 100644 --- a/net/netfilter/ipset/ip_set_hash_gen.h +++ b/net/netfilter/ipset/ip_set_hash_gen.h @@ -64,7 +64,7 @@ struct hbucket { #define ahash_sizeof_regions(htable_bits) \ (ahash_numof_locks(htable_bits) * sizeof(struct ip_set_region)) #define ahash_region(n, htable_bits) \ - ((n) % ahash_numof_locks(htable_bits)) + ((n) / jhash_size(HTABLE_REGION_BITS)) #define ahash_bucket_start(h, htable_bits) \ ((htable_bits) < HTABLE_REGION_BITS ? 0 \ : (h) * jhash_size(HTABLE_REGION_BITS)) -- 2.39.5