Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3630872pxb; Mon, 24 Jan 2022 13:58:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwziHMZ5U7agrxzH9796VzHT85s5MP0HHoXDFyplUNplEh8urlODUDCTc5EvktLpTJosWbH X-Received: by 2002:a17:90b:388d:: with SMTP id mu13mr342629pjb.228.1643061501153; Mon, 24 Jan 2022 13:58:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061501; cv=none; d=google.com; s=arc-20160816; b=UNpqmEaMygLVfPZkgQoomcEOU25VxQiz2FZoBqqHmZk6Bl/G1YK17zde3pcZ31UyYe xFJXj+5ZVJvgt8D6wI8DXEgNF6ZOUwpidKlFpeSANTuwhIEcUdFznFJXcv9n7UDGuPqY OIHR1BXoLY48+7PvIiu1swKQ6JnhEtUQpKchZhJ9LOSk6fCTn6vb6s2NOdrFSHutSSxB mQ76FqFUqJCCfJ9ayC/G9MFTN5Ub7tisxoxao2mjjOJOHYi6KDJZ7HaH04ou4b73fSZU NZCPHPqZMm4oCy91V06xGnubP17NVo/YHFSa+I5bA6K/tUs3D38kdl5Efnx0OjNKNZYy cpiA== 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=kDaofT/O/n6ryr5Ig3vRizBSjA/vcCoRJpN/GKRCn4Q=; b=AfSiPlgljF+Q+AiWgQUNI009k/NgE0embR4FXE9B76U+nszfPrtumvxAEb1OgOZMOa ftr+Wzl1+YfURtkqskwrD6SIgZxP4v+gmBytdTTennmlvDCkNJvUt9aP8wREtDvycWB8 4htnGAn8hsVQ1/C1SyaeYfKy2C9kQWfKBCFQSzrD+9xQltuKrryXrrYcAMl3YbJ9QNZf 0hPG+Ct8rQFYE63bCT7wn8ClLQ9p7TdKiuzjRhXngNuPUwDPDD6aTF6BQs0WfMMlJey9 8AuluFEljnMeLKV1bXdwh2FwmoZTAM4j4xMeK0zF1oRDsYkdDB4LMJdXucfCp8dmyq0X LgDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ddhQHlqB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f8si4582321plg.281.2022.01.24.13.57.59; Mon, 24 Jan 2022 13:58:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ddhQHlqB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573816AbiAXVp6 (ORCPT + 99 others); Mon, 24 Jan 2022 16:45:58 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:35314 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1448078AbiAXVL6 (ORCPT ); Mon, 24 Jan 2022 16:11:58 -0500 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 4C34E61425; Mon, 24 Jan 2022 21:11:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21D23C340E5; Mon, 24 Jan 2022 21:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058717; bh=GLTJnZCfJHVaIC+X5HqOOgqv8U5UHQODi6Ql/8KIEXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ddhQHlqBz55A3ML4VUAeeJ021W9lf4R1LqhoDrIfKYxO3n+h3qwVraNO5Uv22cLfx KxOpkQd7eaDeCCxmcHROXMpram2N/iW2CF8LWZ4CG1ESEoH5bpJu4A50n965SQNW88 52VyjV1k93XuBtSditIwDKdKOuYge/dn3IoNSw5g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, etkaar , Florian Westphal , Stefano Brivio , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.16 0380/1039] netfilter: nft_set_pipapo: allocate pcpu scratch maps on clone Date: Mon, 24 Jan 2022 19:36:09 +0100 Message-Id: <20220124184138.086534019@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Westphal [ Upstream commit 23c54263efd7cb605e2f7af72717a2a951999217 ] This is needed in case a new transaction is made that doesn't insert any new elements into an already existing set. Else, after second 'nft -f ruleset.txt', lookups in such a set will fail because ->lookup() encounters raw_cpu_ptr(m->scratch) == NULL. For the initial rule load, insertion of elements takes care of the allocation, but for rule reloads this isn't guaranteed: we might not have additions to the set. Fixes: 3c4287f62044a90e ("nf_tables: Add set type for arbitrary concatenation of ranges") Reported-by: etkaar Signed-off-by: Florian Westphal Reviewed-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_set_pipapo.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c index dce866d93feed..2c8051d8cca69 100644 --- a/net/netfilter/nft_set_pipapo.c +++ b/net/netfilter/nft_set_pipapo.c @@ -1290,6 +1290,11 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old) if (!new->scratch_aligned) goto out_scratch; #endif + for_each_possible_cpu(i) + *per_cpu_ptr(new->scratch, i) = NULL; + + if (pipapo_realloc_scratch(new, old->bsize_max)) + goto out_scratch_realloc; rcu_head_init(&new->rcu); @@ -1334,6 +1339,9 @@ out_lt: kvfree(dst->lt); dst--; } +out_scratch_realloc: + for_each_possible_cpu(i) + kfree(*per_cpu_ptr(new->scratch, i)); #ifdef NFT_PIPAPO_ALIGN free_percpu(new->scratch_aligned); #endif -- 2.34.1