From: bot+bpf-ci@kernel.org
To: a.s.protopopov@gmail.com,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,almagui@kernel.org,john.fastabend@gmail.com,qmo@kernel.org,brauner@kernel.org,kpsingh@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,sashal@kernel.org,bpf@vger.kernel.org,linux-kernel@vger.kernel.org
Cc: a.s.protopopov@gmail.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
Subject: Re: [PATCH v3 bpf-next 15/18] resolve_btfids: Tag fmod_ret candidates as targets
Date: Wed, 11 Nov 2026 08:21:45 +0000 (UTC) [thread overview]
Message-ID: <f0cac3d0039b840d9e1cab4dffbff15923f87115dda70351043219df57fbd4d8@mail.kernel.org> (raw)
In-Reply-To: <20261110164046.454431-16-a.s.protopopov@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2995 bytes --]
> resolve_btfids: Tag fmod_ret candidates as targets
TL;DR: Nits only in resolve_btfids fmodret.c: the second branch in
relocation_offset() looks unreachable or wrong, and record field offsets are
hardcoded in three functions. No functional bugs reported.
> diff --git a/tools/bpf/resolve_btfids/fmodret.c b/tools/bpf/resolve_btfids/fmodret.c
> new file mode 100644
> --- /dev/null
> +++ b/tools/bpf/resolve_btfids/fmodret.c
[ ... ]
> +static bool relocation_offset(const GElf_Shdr *target, GElf_Addr offset,
> + size_t width, size_t *result)
> +{
> + if (target->sh_size < width)
> + return false;
> + if (offset >= target->sh_addr &&
> + offset - target->sh_addr <= target->sh_size - width) {
> + *result = offset - target->sh_addr;
> + return true;
> + }
> + /* ET_REL relocation offsets are relative to their target section. */
> + if (offset <= target->sh_size - width) {
> + *result = offset;
> + return true;
> + }
> + return false;
> +}
this isn't a bug, but when is the second branch in relocation_offset() taken?
For the module sections that use this helper, sh_addr is 0, so the first
test already returns the section-relative offset, and with sh_addr == 0 the
second condition cannot be true once the first has failed.
The second branch is reached only when sh_addr != 0 and offset < sh_addr,
which would be a linked image whose r_offset lies below the target section.
Treating that address as a section offset would be wrong there.
Would it be clearer to pick the interpretation from e_type, or to drop the
fallback?
[ ... ]
> +static char *format_values(const unsigned char *buf, size_t offset, size_t ptr_size,
> + unsigned int encoding)
> +{
> + unsigned int nr = read_elf_value(buf + offset + 16 + ptr_size, 4, encoding);
> + const unsigned char *p = buf + offset + FMODRET_META_HEADER_SIZE(ptr_size);
[ ... ]
> +static int choose_functions(struct elf_function_list *functions, const struct btf *btf,
[ ... ]
> + if (!read_elf_value(buf + record + 16 + ptr_size, 4, encoding))
> + continue;
> + stats->with_values++;
> + flags = read_elf_value(buf + record + 12, 4, encoding);
this isn't a bug, but the record field offsets (flags at 12, nr_values at
16 + ptr_size) are written out by hand in parse_records(), format_values()
and choose_functions(). parse_records() has already decoded flags and
nr_values, and the other two decode them again from the raw buffer at the
same offsets.
fmodret_metadata.h has macros for the magic, the version and the header
size, but none for the field offsets.
Would it be simpler to put the offsets in fmodret_metadata.h, or to have a
small helper return flags and nr_values for a record, so that the three
functions do not each repeat 12 and 16 + ptr_size?
---
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/42981885558
next prev parent reply other threads:[~2026-11-11 8:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 16:40 [PATCH v3 bpf-next 00/18] Auto-detect BPF fmodret targets Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 01/18] bpf: Add BTF ID sets for fmod_ret targets Anton Protopopov
2026-11-11 8:01 ` bot+bpf-ci
2026-11-10 16:40 ` [PATCH v3 bpf-next 02/18] bpf: Add a btf_id_set8_entry helper Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 03/18] bpf: Build fmod_ret target sets from BTF decl tags Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 04/18] selftests/bpf: Declare bpf_fentry_test1 in tracing tests Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 05/18] bpf: Declare fmod_ret targets with BTF_FMODRET sets Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 06/18] selftests/bpf: Test fmod_ret BTF decl tags and attach permission Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 07/18] scripts: Add LLVM plugin infrastructure Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 08/18] bpf: Add the bpf_scan_ir LLVM plugin Anton Protopopov
2026-11-11 8:21 ` bot+bpf-ci
2026-11-10 16:40 ` [PATCH v3 bpf-next 09/18] bpf: Find fmod_ret candidates in bpf_scan_ir Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 10/18] bpf: Allow writes to private stack objects " Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 11/18] bpf: Follow PHIs " Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 12/18] bpf: Follow integer casts " Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 13/18] bpf: Check the return values of fmod_ret programs on found targets Anton Protopopov
2026-11-11 8:21 ` bot+bpf-ci
2026-11-10 16:40 ` [PATCH v3 bpf-next 14/18] bpf: Require the JIT for fmod_ret programs on found 64-bit targets Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 15/18] resolve_btfids: Tag fmod_ret candidates as targets Anton Protopopov
2026-11-11 8:21 ` bot+bpf-ci [this message]
2026-11-10 16:40 ` [PATCH v3 bpf-next 16/18] selftests/bpf: Test fmod_ret candidates found by bpf_scan_ir Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 17/18] selftests/bpf: Enable bpf_scan_ir in the config Anton Protopopov
2026-11-10 16:40 ` [PATCH v3 bpf-next 18/18] bpftool: List and show fmod_ret targets Anton Protopopov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0cac3d0039b840d9e1cab4dffbff15923f87115dda70351043219df57fbd4d8@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=a.s.protopopov@gmail.com \
--cc=almagui@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=mason@kernel.org \
--cc=memxor@gmail.com \
--cc=qmo@kernel.org \
--cc=sashal@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®