Article View: linux.kernel.netdev
Article #12978Re: [PATCH bpf v4] bpf: check cpu_possible() in per-cpu helpers and map callbacks
From: bot+bpf-ci
Date: Mon, 09 Nov 2026 03:21
Date: Mon, 09 Nov 2026 03:21
52 lines
9569 bytes
9569 bytes
--===============5952342031053075532==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
> bpf: check cpu_possible() in per-cpu helpers and map callbacks
TL;DR: Not a bug, a design question: the new cpu_possible() check in the
bpf_map_lookup_percpu_elem() helper looks redundant, since every per-cpu map
callback now does the same check. Could it be dropped?
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
[ ... ]
> @@ -133,6 +133,10 @@ const struct bpf_func_proto bpf_map_peek_elem_proto = {
> BPF_CALL_3(bpf_map_lookup_percpu_elem, struct bpf_map *, map, void *, key, u32, cpu)
> {
> WARN_ON_ONCE(!bpf_rcu_lock_held());
> +
> + if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
> + return 0;
> +
> return (unsigned long) map->ops->map_lookup_percpu_elem(map, key, cpu);
> }
This isn't a bug, but is the extra check in the
bpf_map_lookup_percpu_elem() helper needed?
Every map_lookup_percpu_elem callback (percpu_array_map_lookup_percpu_elem(),
htab_percpu_map_lookup_percpu_elem() and
htab_lru_percpu_map_lookup_percpu_elem()) now rejects impossible CPUs
itself, and check_map_func_compatibility() only admits those three map
types for this helper.
When bpf_do_misc_fixups() patches the call into a direct call to the
callback, the helper body never runs. So the helper-level check never
decides anything on either path.
Could it be dropped, to match bpf_map_lookup_elem() and friends, which
leave argument checks to the map ops?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/42553704194
--===============5952342031053075532==--
Technical Details
Message-ID:
<63803328eeb37398cdfa03e5991651c0fb151109c74648b599b29b9dd9508a1d@mail.kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359013-linux-kernel-netdev=dewy.ruReferences:
<tencent_6A1D611E2DA9545DA6E76ABCCA806BC39707@qq.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359013-linux-kernel-netdev=dewy.ru From: bot+bpf-ci@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH bpf v4] bpf: check cpu_possible() in per-cpu helpers and map callbacks Date: Mon, 9 Nov 2026 03:21:45 +0000 (UTC) Organization: Usenet Network Message-ID: <63803328eeb37398cdfa03e5991651c0fb151109c74648b599b29b9dd9508a1d@mail.kernel.org> References: <tencent_6A1D611E2DA9545DA6E76ABCCA806BC39707@qq.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5952342031053075532==" Injection-Info: usenet.network; logging-data="261690"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:4GjKAw3xqD48ac/97wFT038kmuQ= sha256:P68m/5OwilQ+dVAK6p+/a/wyClbQ1bDx0NebcEPtWZ8= sha1:6J4gGNhKtR5s7D4l9HJTjofTr64= sha256:Zr1k679Yodzt6pS2U4ASmYpOXEiSXuoepPBKk1+lROc= 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 437E01136C6; Mon, 9 Nov 2026 06:22:33 +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 uT8ZYFmNQfp4; Mon, 9 Nov 2026 06:22:29 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-359013-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 998D41136C2; Mon, 9 Nov 2026 06:22:21 +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 3AA20606E12; Mon, 9 Nov 2026 03:21:59 +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=1794194517; b=PxIBbhOq1WtX91exdr9peZonUgnmhr+oqr37UkpoCcKIhErN8irWi+UPOBI8c0/SwI5R /Bz3HXZqRvWRJNh60eL0+DWB/e2h5jFdROKQdmr9Y4iXpYEc4fHYRv3RXL7RGNoXsbYXY FC3hg3gNzYe/HZGqs2dk7HUrkC7VTKck5EIBsVHuGg0XmeljUOzHaAgrxjWIJAGaJ26mU 29S76uRE7P+LOeuA0Nod1rmHz4DMql2FDSDcTqzokRG2aIojsEuEZ0TF4nJKn5zO/VyF1 mnGaU7k4En5z01G2uKLpHN6/1sF7RieFBO1qTUD6311qwiRVJA0r7JJw2bkXgIZII4A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794194517; h=X-Original-To:Received:Received:DKIM-Signature:Content-Type: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=57oS6m1b9doBy7H5rmfFkLclTYei+DSwfk/1lcfyc1c=; b=m3qbIwaYPU/uDl007iBIGOSsvFVPDx9wBImjXRjjog9q+NfYk3oxUbGSGpAGyVNgW23E smovDPl4pWfAi7bMaDkIM5p+7PInE4XrvfClaP+wNNlKAC+SAsLI6n6t14ZxAGaK5x8HF sriBqtx8gqDd89Mhm79iKR7N8wesmwGNSkHvaWuSj7rEPZItL9W4RBm7scY7bRtnNvW5h YxWmHFOFmwRyNCuhR9AEDolkyi6kCDd2X/IA1zodqDSmFEhi2OwOjRcNOTb4YM29ts34W Z6puYkfP5EqM+nMbXZnrjCTA0Gxn0Y2Nk6hZHfS2zz+puePiO77vh+ra8NUL/uf7y+g== 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=GPFtGz7H; 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 3E372606A331; Mon, 9 Nov 2026 03:21:57 +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=GPFtGz7H 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=1794194506; b=w38j0+UkcqGfXZWMV2hV1yd0GuvaWTvR4kgccRLTANXTWYTewq+u7oxEE+DWyx/kC6jj J1nWWr8QDEup5GeiEwJFb566md8hm+aLTe/ugn6CJ0e44iqeMsFq8t0Re9GFtSferrYR3 jg+NtA0KLlrYvhHa91ggIFoVWJy6T/2DayOZoH2mBr+w7WOQY5dCp7qZ09qd5+Fo6TrlN zqx+9yMVCOL5DMCtuJqIbBZQHLEYBxkTv2Y3XE3dL681mSOZFnrzIEqN/6uryNL72JSbZ MS/0pIyRz1K6SUhMpsZzywaS/j900db2N4TnEt5TGgHPuyKs0jLwPSk4t89USMRggMA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794194506; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=57oS6m1b9doBy7H5rmfFkLclTYei+DSwfk/1lcfyc1c=; b=bRRK33EF5tiYndZJiXQl16bUfc/YPZK2eR5fwCF2ijBTyDDJNfTGBMNW0CEANlVb/U0f j4XqBER12yPKvz4CcmtI9PkEutqsSUzo29sdCTo0B3Fo2LlgRo1/OpqpqGrmJ+c3PAy3o U6AetUdbVWlhMwfvTglN+7u8LX/niE6CABF6gcONcoqCDrOMRSHk3SnYDtzHUsVzFSY0S guS00WmatZmQQK/Fid8Op0JDHc76X4eBSXFdDq0LLBP3kNS2LjVw6UQuqWb6+Lg5pQekO F+4FyRK9lJ8oOIjwAGtHETrCM5JgV0fgHA7UQx06bZgjAHQyWOhdpH/G+EiZ9UhQwGg== 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=GPFtGz7H; 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 16B13606A320; Mon, 9 Nov 2026 03:21:45 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FA1B1F0089F; Mon, 9 Nov 2026 03:21:45 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794194505; bh=57oS6m1b9doBy7H5rmfFkLclTYei+DSwfk/1lcfyc1c=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=GPFtGz7HiHr6oYZ0QNpfF+ZgxAbQ2GM/oFwn9mqtHe6QgSs7tF8wNOxDOSmqjPtu+ 2W0Z0tBG75Cf3P0DW3WsUXKX0nSaoFE+jJLq0lWVz3uhDvhCHNz8ZHh9760xGakgAr qg+EmSGZQ2q/RxqH/LwIAF580uYFck9KG73EXZcRzv+7hB0goVB7VqXlZDBx9JLrkw TP/yYbQCUTMHDDXamTX1eUgz5gNFV9CskH3QRkUOQWsJNNOKqBDDSA/5E4gP/1h7Me AUVHe/azjKhr0eYle8aRjjL9qZjZ6WLSOX1/42TAc3EIREOL/K7IRZIouV+iAJIKss WD7zw+9OOQ6iw== 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 X-In-Reply-To: <tencent_6A1D611E2DA9545DA6E76ABCCA806BC39707@qq.com> X-Cc: andrii.nakryiko@gmail.com,andrii@kernel.org,ast@kernel.org,daniel@iogearbox.net,netdev@vger.kernel.org,treebacker@foxmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev