From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: bpf@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH 6/6] s390/bpf: Add kCFI support
Date: Fri, 24 Jul 2026 14:34:48 +0000 [thread overview]
Message-ID: <20260724143448.C08831F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724141318.1037434-7-hca@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] BPF line info offsets are shifted by 4 bytes due to double-counting the CFI hash size in `bpf_prog_fill_jited_linfo()`.
--
--- Patch [6]: [PATCH 6/6] s390/bpf: Add kCFI support ---
commit 07d29b72daf2643a639d32a0ab6a9b913adcfbc6
Author: Heiko Carstens <hca@linux.ibm.com>
s390/bpf: Add kCFI support
This patch adds kCFI (Kernel Control Flow Integrity) support for BPF programs
on the s390 architecture. It emits a CFI hash before the BPF program
instructions and adjusts the function pointer and lengths to account for
this prefix.
> diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
> index 31749c0362ca2..74642e0b4ee19 100644
> --- a/arch/s390/net/bpf_jit_comp.c
> +++ b/arch/s390/net/bpf_jit_comp.c
[ ... ]
> @@ -2401,9 +2417,9 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
> jit_data->ctx = jit;
> jit_data->pass = pass;
> }
> - fp->bpf_func = (void *) jit.prg_buf;
> + fp->bpf_func = (void *)jit.prg_buf + cfi_get_offset();
> fp->jited = 1;
> - fp->jited_len = jit.size;
> + fp->jited_len = jit.size - cfi_get_offset();
>
> if (!fp->is_func || extra_pass) {
> bpf_prog_fill_jited_linfo(fp, jit.addrs + 1);
[Severity: Medium]
Does this double-count the CFI offset when calculating the JIT line info?
Looking at bpf_int_jit_compile(), the emit_kcfi() call during the prologue
generation advances jit.prg by 4 bytes. This means the offsets stored in
jit.addrs already include the CFI hash size.
However, when we pass these offsets to bpf_prog_fill_jited_linfo(), it
uses fp->bpf_func as the base address to resolve the final instruction
pointers:
kernel/bpf/core.c:bpf_prog_fill_jited_linfo() {
...
for (i = 1; i < nr_linfo && linfo[i].insn_off < insn_end; i++)
jited_linfo[i] = prog->bpf_func +
insn_to_jit_off[linfo[i].insn_off - insn_start - 1];
}
Since fp->bpf_func has already been shifted forward by cfi_get_offset(),
adding the unadjusted jit.addrs offsets might shift the resulting line info
by 4 bytes, which could break source line mapping in userspace tools.
Should jit.addrs be adjusted to subtract cfi_get_offset() before filling
the line info, or should the original base pointer be passed instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724141318.1037434-1-hca@linux.ibm.com?part=6
prev parent reply other threads:[~2026-07-24 14:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 14:13 [PATCH 0/6] s390: Add kCFI support Heiko Carstens
2026-07-24 14:13 ` [PATCH 1/6] s390/tools: Pass symbol name to do_relocs() Heiko Carstens
2026-07-24 14:23 ` sashiko-bot
2026-07-24 15:14 ` bot+bpf-ci
2026-07-24 14:13 ` [PATCH 2/6] s390/tools/relocs: Ignore __kcfi_typeid_ relocations Heiko Carstens
2026-07-24 14:30 ` sashiko-bot
2026-07-24 14:13 ` [PATCH 3/6] s390: Add ftrace_stub_graph Heiko Carstens
2026-07-24 14:21 ` sashiko-bot
2026-07-24 15:14 ` bot+bpf-ci
2026-07-24 14:13 ` [PATCH 4/6] s390/diag: Generate CFI type information for assembly functions Heiko Carstens
2026-07-24 14:26 ` sashiko-bot
2026-07-24 14:13 ` [PATCH 5/6] s390/Kconfig: Select ARCH_SUPPORTS_CFI Heiko Carstens
2026-07-24 14:37 ` sashiko-bot
2026-07-24 14:13 ` [PATCH 6/6] s390/bpf: Add kCFI support Heiko Carstens
2026-07-24 14:34 ` sashiko-bot [this message]
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=20260724143448.C08831F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.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