🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20672

Re: [RFC PATCH 0/3] Introduce a classic BPF filter cache for seccomp

#20672
From: Kees Cook
Date: Mon, 23 Nov 2026 02:47
55 lines
10189 bytes

On November 20, 2026 4:48:49 PM GMT+10:00, Xu Kuohai <xukuohai@huaweicloud.com> wrote:
>Sandboxes like Firecracker use seccomp filters to restrict allowed
>syscalls. Hundreds to thousands of Firecracker VM instances can run
>from a single template. Each instance loads identical seccomp filters.
>The kernel repeatedly translates and JIT-compiles these same cBPF
>programs, wasting CPU cycles and slowing down bulk startup of
>identically sandboxed workloads. cBPF lacks dynamic instruction patching
>features like tail calls or tracing. Its JITed instructions remain
>immutable at runtime. This makes it possible to share the same cBPF
>filter between different processes.
>
>This series introduces a classic BPF filter cache. It is implemented as
>a hash table that maps user-space filter instructions to the prepared
>bpf prog.
>
>The cache lookup occurs before filter preparation:
>- cache hit: Returns the shared bpf prog directly.
>- cache miss: Reserves an entry. Concurrent tasks loading the same filter
>  wait on a wait queue until preparation completes.
>
>The cache is instantiated per subsystem. Currently, seccomp is the only
>user.
>
>This series ends with a benchmark test. Every producer spawns one worker
>thread at a time, the worker installs a batch of filters and exits, the
>benchmark reports the number of filters installed per second. The table
>below benchmarks the batch size and the instruction length in one round,
>running the command below with different option values. The base column
>runs the same command on a kernel without this series. All data was
>measured on a local test setup with 32 producers.

I would expect either memory usage or launch benchmarks, not just filter install timings.

Is there a workload where there is a problem? It is hinted at in the opening paragraph, but I'd want to better understand the actual constraints before jumping to a solution. E.g. it's already possible to share filters by way of process hierarchy, so perhaps the issue is lack of hierarchy?

I've seen proposals in the past about having handles to pre-constructed filters, which could be applied (i.e. much of the existing caching and lifetime management remained unchanged).

-Kees

-- 
Kees Cook
Technical Details
Message-ID: <EF2067C8-7F71-4D92-ABC9-25BC3234036E@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368975-linux-kernel-netdev=dewy.ru
References: <cover.1795139109.git.xukuohai@huaweicloud.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368975-linux-kernel-netdev=dewy.ru
From: kees@kernel.org (Kees Cook)
Newsgroups: linux.kernel.netdev
Subject: Re: [RFC PATCH 0/3] Introduce a classic BPF filter cache for seccomp
Date: Mon, 23 Nov 2026 12:47:53 +1000
Organization: Usenet Network
Message-ID: <EF2067C8-7F71-4D92-ABC9-25BC3234036E@kernel.org>
References: <cover.1795139109.git.xukuohai@huaweicloud.com>
MIME-Version: 1.0
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3774980"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Ly61sskU832hvTyWVHwtjwZaPhA= sha256:Jn7dIN0mF4H0QF/pIR7gJB+FJvwzQh3l3WjXEpvdH90=
	sha1:lYydsaRdsMGQsfzgIA2l93B87SI= sha256:4zNMViAXsj564u0Zll+Yky+PwiCOZA82iuJV/tcUW9M=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 507F9125D8A; Mon, 23 Nov 2026 05:48:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id BpMTU1BI53Wf;
	Mon, 23 Nov 2026 05:48:24 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-368975-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 38114125D83; Mon, 23 Nov 2026 05:48:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 6E597602000; Mon, 23 Nov 2026 02:48:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795402089;
	b=VI9HYI8rNcdcduUpjHQ9X6m7ceqkagKBawXqEYkWXrBcsMyyBmgSQXz2boBMpHov1hLK
	 g55/AKBcsHLyRFpxrFyPQU2NU2Sge5yETWoat1MHBHZPhrO96ZgiLJO4ijCLuanrQdphl
	 1tM159mhCt50rYLMiUglUTXgLdtx6opRErWPYfV6AsfM2LKkLqEkEWda1RrozwMzaYj1r
	 658rdIDCOk+ytmGRYkYeuAt0EFUVTwhTkG09zlgGchlyxM5hf9ypMyamV0/drzU3rXHfH
	 w13fLlB7dFMPGDdMQGtcHhwnRF4WS8UhGBY6YQBAyZbP60iXDo3nPaYK2mTgcuCrfrw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795402089;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:CC:
	 Subject:User-Agent:In-Reply-To:References:Message-ID:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=yrk9+Mje2C0J1qnXfhBPjrjMZR0Y6jR+rEChJda2HwE=;
	b=kcdqtvtpzmMe4TjrKhE5RNTs/iTxUBdtPezRxs0iw6cqdc3ZElZQGfO3tMFArgLKorcd
	 AKdFH/yT3iMMNCuZZ0v7mLyK9R3Sga8idY1l19obGFlx033BpRsog2eDQAMekVY1dHNtN
	 vC49tXFJTjEqIv8SNCTNOKnBKllkP9qXoWEjjtn8ExULV1Qh2Scn/GG7IOY/yHLkd7bZm
	 55aalXZ1nLO2U+UWoleSRbEECOKR/rxl1H4pFZREWyXdjyzPQSWOwhxoVn3ZQFGgtgg1W
	 pK15zI/AMrAJXCaOxdMiDHK8+9nDKmxkgrpaTvIZJKmVpM5uASmXw/elBTDsRe57DfA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CyI3qMqW;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id EBFE2606A320;
	Mon, 23 Nov 2026 02:48:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CyI3qMqW
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795402083;
	b=WleBY9LIpDjr9eXIlP/wfNPjhNdD7th8NJGClh7AvIKgcu4475BmTVPGqKy/bwuxKu6C
	 Fa2QgvBKXraijByJfKWxptZhQ57Od9hKX3nkT2kbGI67Kk5z6RUTSO/A7Xdg1pg9Uw6LW
	 VrwzjAwWkO64csyHVbzn7V8ZJbvreINXg854irfyy5qaMEd+KOnD7gH6gQTo7VF/NJWKU
	 4t4MEmdk9R/bmWz+4BG+MiuG6lNzT6lHpc/XUNW3W5kj0vWxESnRqCpxJLGm1d0pO9YEv
	 MZ0niamVgQbmrNu9kQR4NdkdLOrOKM7Z+4ezoJXkhp+ClQe2ed/u5SajjBAAwVtt5DQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795402083;
	h=Received:DKIM-Signature:Date:From:To:CC:Subject:User-Agent:
	 In-Reply-To:References:Message-ID:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=yrk9+Mje2C0J1qnXfhBPjrjMZR0Y6jR+rEChJda2HwE=;
	b=d2PZNk3Yik9CbqhBgFY0pP3qkw9am3yTXFRjY2EyORR4xuzzGkeH42ZeGPMOvmrc/gyq
	 AYbMLh7n4yBBN/HfGyciSVcia3l+xqijimkH1F2QOp5L/4l4KucvuX4AQxZIJ9dKjqHb1
	 21AjzJCB5MN8WHPtIfpqJirqbnBozfc6UFDCO06kK7UpESMs7CvyXp0DyToupmAvfmJ7q
	 2HSLg7JxptRJV7VoNwqWgi5W31mVhL4mBhCcv4gGCPHuBu5hiWGnbPbwuVpkDLvH2eq2L
	 Ac8CUDPRcfGSzxRzN0Fozy6KYk/30ffRATKQGC9v4hjepLRi3mBXMsWJ1xZN9rLdFOQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CyI3qMqW;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 153FA606A335;
	Mon, 23 Nov 2026 02:48:02 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 743561F000D0;
	Mon, 23 Nov 2026 02:47:59 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795402082;
	bh=yrk9+Mje2C0J1qnXfhBPjrjMZR0Y6jR+rEChJda2HwE=;
	h=Date:From:To:CC:Subject:In-Reply-To:References;
	b=CyI3qMqWU+bbm41Pvu5eArEyhtjiTt0S0MgixsjmMnIX8XzpTtcXkx19YoV/xmS9l
	 HMpqGRoxOGOA1NhKJ3H2UtIeX3UTIJW+8eDTdQfbSrm9RXF7gJTXIYZnWa0oEyuel/
	 k0fJ/dWSKO/w4sFbvhQTmoVdrA+siN9We+OGlyygTU0SADHC3DlcG4iMgdpZlF42tk
	 yzlUeRBp4mvjlzXvg65kGKGeekb4OApYFk0FISD0yeZ5xSXG8+HLG4N+iY7Jf138SK
	 S+JMqNDwUcRvas5sBIC9/IUOI0GGEVtjdkuHqW7Kdddmq/3ie0D2BWFMo6kTy5UnO3
	 0THvIYbT0tEbA==
X-CC: Andy Lutomirski <luto@amacapital.net>, Will Drewry <wad@chromium.org>,
 Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>,
 Stanislav Fomichev <sdf@fomichev.me>,
 "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>,
 Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
 Jens Axboe <axboe@kernel.dk>
X-User-Agent: K-9 Mail for Android
X-In-Reply-To: <cover.1795139109.git.xukuohai@huaweicloud.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list