Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3590011pxb; Mon, 24 Jan 2022 12:59:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVsdJopXHKnSf74x+OeNcNA+Pos4iTPVgaQQJJG+2djBlRn7CJNeZXR4qOFyeDsnk0Wdak X-Received: by 2002:a17:90a:4407:: with SMTP id s7mr162206pjg.126.1643057965998; Mon, 24 Jan 2022 12:59:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057965; cv=none; d=google.com; s=arc-20160816; b=vCLrQVxznVWl+YAHgC7v2YWS02gSts03jaeky+NU/3Yqk3N4wFWBjNk1QCF0yZ4XzL Ef+yCuNOBcYECyWknEdRPjpNlL5CPwAaZEynJadAii7KmJLe/61jSchZbzWD73mxBLmf cbFmcHbBULc4jAM12gla/LO/13WuXo0harBDQVvaW+gYa0vNrFGI7dtdj71bZgMM7eRo Y2ukOI5kUbT66TDmHks+FipfhBWCl3ZNh2NJwFibZXCg1qdTim+WFmaEl3ZBbNtutBb4 j81IcddL8+/11+z4MtVSTCzJDTe3AeA9WrsEF4SJ68d6bW2k6yD77fMaBVHd6t0iBLZM YLkg== 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=GR++N8AKlZ2vnEijXTnhs2am+CHz3PXUJkkLTn7KB0s=; b=mrn9wAzHkDcPlrhTJKfFZ6LAMw5gp/ByiAOxU+/cte3rPuWHmi23wehTjV4VN2T3p2 B5pQnpUO7rU3MJ3aKtOl2lriVb5ozWRIt7ax7/WZilhHnzfeaKOSurRQAvPz+nsXl8DQ vgJEbbq/VbgYkEbwmfzwzvz4tutmLI3ErVWqtyV//7tGNv5vX/+AXJqIvDv5PffqBNIN cJYcE+OO0Cvx6D1KCSQ6KMSFmiucqCd1JWVtFxS9cVy+cOWuQGB1edpBqMt+T1YF9Rwl WSbvaF7XKUdAMl/BQoXplF+OnAUJWpS6ksZMcgGFumPzSqSw3oVS7B31gQu9MjcKHdWB f7RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F+TUmL3n; 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 o3si3229214pfu.335.2022.01.24.12.59.07; Mon, 24 Jan 2022 12:59:25 -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=F+TUmL3n; 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 S1356114AbiAXUYf (ORCPT + 99 others); Mon, 24 Jan 2022 15:24:35 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:39910 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354724AbiAXTv1 (ORCPT ); Mon, 24 Jan 2022 14:51:27 -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 ams.source.kernel.org (Postfix) with ESMTPS id 37A9CB811F3; Mon, 24 Jan 2022 19:51:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69D57C340E5; Mon, 24 Jan 2022 19:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053884; bh=RTtE72TEKRptEnT9avhBLidZKHxVwDtJvr7QQ0QGyVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F+TUmL3nh3/phT4BMuw7tcwY4ABe9QcDEegr32klRSRrRkC+JWzyKLVp3Cs2n30Bs 2VC/wRG5eWsU6DEZ/KTT5JtT9t2hYc0wI+AjUN6k3vxn8KwaQTKtEZswTqmXOmv/KO 2xd6N4HmAbXG1Je4994OevbprSPzpzyK++xi6B2E= 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.10 207/563] netfilter: nft_set_pipapo: allocate pcpu scratch maps on clone Date: Mon, 24 Jan 2022 19:39:32 +0100 Message-Id: <20220124184031.583468907@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@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 2d73f265b12c9..f67c4436c5d31 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