From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=45.145.95.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796039394; b=lMWSOFqGlB19dLoYVkTj+Y9rf/wEFAYtUEYnYXkvAQhUcQDJ2Lzjuu9vCSqjYSJ9gp3M 0Zx9akTk3IGl7lvL7wuzDyemXDAV0XGGoKAOjfiFgDACSZCV3Dz4Sv+AgkLnS9W81qr6J LwX0l8Wk6SZFXo7xZdyw9XnJbHV7W/zlyapvst5jseXH/NgiJxscd4eGRCxUvgTl4eARC ibYOL8d34X1fO4d49WQNW8E6navy/VyIZckrWhrNkLc1NR9hSrFVx8TMkKGqIYO1Y4vyF z4Np1kfiLuX7nEL2gId2WoJDhgauQ7OdGKYkCEGyPnWVGP2FOI/edWRX253LyWR2tYw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796039394; h=DMARC-Filter:DKIM-Signature:From:To:Cc:Subject:In-Reply-To: References:Date:X-Clacks-Overhead:Message-ID:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=2G5JXeWXoVGYjqoQZNfilSdeSci5A+Ksyr+Y7yuDT5I=; b=n2XjQDA6gqnn9at2YkGzGakxLqpQ0Keoj7p38Hesa1AcKZLGg4+M5pVEEfeRL9mN7dVG 55BzJKwGiH5DoufzIs2sM93RCo7PkcDTrbZV47EVaFPLEeUDd+OFNaty2houVbZfVCCFN 045dJC+RcgEmrsu4I+09pYo0rO4oW6YaA8wuQzIWjwwVOLGM4arD1yI1EtiKUENsLc3sC 4s/bhUoGxMIuoa5PWpn70N8aaDzJu6DoU7IZajx6vu/rYf7C3YqXGaeqTxzGtmM/9fEBW DxEJpduvUSaQPMVgAUgLPpca2T/D7q4MxkgY6+9r/9szIAyHkxCDP73dxjzqy5pJO3w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=toke.dk; spf=pass smtp.mailfrom=toke.dk; dkim=pass header.d=toke.dk header.i=@toke.dk header.a=rsa-sha256 header.s=20161023 header.b=TQbSamr+; arc=none smtp.remote-ip=45.145.95.4 Received: from mail.toke.dk (mail.toke.dk [45.145.95.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6C5C606A320 for ; Mon, 30 Nov 2026 11:49:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C6C5C606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=toke.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=toke.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toke.dk header.i=@toke.dk header.a=rsa-sha256 header.s=20161023 header.b=TQbSamr+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1796039391; bh=8UHB/fIl/1k/TPFe+UDz4iXhZ0dlEsoAF0TEz1xREGQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=TQbSamr+faJNAKk7yN3OB+yZS2NAbaer3R7PkJx7tLjizjSHt9qoPByddEBJeJlKX vOJOjIiyR9Io/KaBpMD+656EauiOqiXm8MxSqfPldO36/guqiGUXPuI5xAx3Vo2hzp y67ftVrPde9lUaCQ+fsezCu0ozb3x/UD6dD9Kj9nbNrpPyJUzrkYQ0eSl4rb1Jt7JJ utw+0Uh5EYb09ZkEZrNVNccnDnITzde6CQ1xQHtf7QCZeEhIaqiqcTC61HMsEKzqXT SqIv4/WjNNGAhM1u4fFembAOx/owPAl2ePb8//+TaOC4lzj2IbO0GcvzoD9ENZ6c9n pU2TNTxbcSVBQ== From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: sashiko-reviews@lists.linux.dev Cc: bpf@vger.kernel.org Subject: Re: [PATCH bpf-next v4 4/6] libbpf: Pass in token_fd when iterating kernel BTF objects In-Reply-To: References: <20261130-bpf-relax-get-next-id-v4-0-807e2b53cc22@toke.dk> <20261130-bpf-relax-get-next-id-v4-4-807e2b53cc22@toke.dk> Date: Mon, 30 Nov 2026 12:49:51 +0100 X-Clacks-Overhead: GNU Terry Pratchett Message-ID: <877bhuczds.fsf@toke.dk> X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable sashiko-bot@kernel.org writes: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Low] libbpf: commit message mismatch with EINVAL handling in > load_module_btfs() > -- > > commit 5b2c115a6b84d1a2dda07a4ba224595597f8f78d > Author: Toke H=C3=B8iland-J=C3=B8rgensen > > libbpf: Pass in token_fd when iterating kernel BTF objects > > This commit passes obj->token_fd to bpf_btf_get_next_id_opts() and > bpf_btf_get_fd_by_id_opts() when iterating and loading kernel module BTFs > in load_module_btfs(). > >> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c >> index 2aa3d3e33cc2d..ce748b8bde96e 100644 >> --- a/tools/lib/bpf/libbpf.c >> +++ b/tools/lib/bpf/libbpf.c >> @@ -6020,6 +6020,9 @@ static bool is_btf_mod_allowed(const struct bpf_ob= ject *obj, const char *name) >>=20=20 >> static int load_module_btfs(struct bpf_object *obj) >> { >> + DECLARE_LIBBPF_OPTS(bpf_get_fd_by_id_opts, opts, >> + .open_flags =3D obj->token_fd ? BPF_F_TOKEN_FD : 0, >> + .token_fd =3D obj->token_fd); >> struct bpf_btf_info info; >> struct module_btf *mod_btf; >> struct btf *btf; >> @@ -6044,10 +6047,10 @@ static int load_module_btfs(struct bpf_object *o= bj) >> return 0; >>=20=20 >> while (true) { >> - err =3D bpf_btf_get_next_id(id, &id); >> + err =3D bpf_btf_get_next_id_opts(id, &id, &opts); >> if (err && errno =3D=3D ENOENT) >> return 0; >> - if (err && errno =3D=3D EPERM) { >> + if (err && (errno =3D=3D EPERM || (errno =3D=3D EINVAL && opts.token_= fd))) { >> pr_debug("skipping module BTFs loading, missing privileges\n"); >> return 0; >> } >> @@ -6057,10 +6060,14 @@ static int load_module_btfs(struct bpf_object *o= bj) >> return err; >> } >>=20=20 >> - fd =3D bpf_btf_get_fd_by_id(id); >> + fd =3D bpf_btf_get_fd_by_id_opts(id, &opts); >> if (fd < 0) { >> if (errno =3D=3D ENOENT) >> continue; /* expected race: BTF was unloaded */ >> + if (errno =3D=3D EPERM) { >> + pr_debug("skipping module BTFs loading, missing privileges\n"); >> + return 0; >> + } > > [Severity: Low] > Does the commit message match how load_module_btfs() handles EINVAL? > > The changelog states that on EINVAL from older kernels, load_module_btfs() > resets any tokens and tries again, but the code instead treats > (errno =3D=3D EINVAL && opts.token_fd) the same as EPERM, logs a debug me= ssage > about missing privileges, and returns 0 without retrying. The changelog > also does not mention the new EPERM check after > bpf_btf_get_fd_by_id_opts(). Ah, oops, forgot to update the commit message when changing the code. Will do a quick respin fixing this and the dead code complaint in the other commit. pw-bot: cr