From: Joe Lawrence <joe.lawrence@redhat.com>
To: Seke Kazuru <kazuruuni@gmail.com>
Cc: live-patching@vger.kernel.org, jpoimboe@kernel.org,
mbenes@suse.cz, "pmladek@suse.com" <pmladek@suse.com>,
"song@kernel.org" <song@kernel.org>,
peterz@infradead.org, bpf@vger.kernel.org
Subject: Re: objtool/klp: ___bpf_prog_run jumptable is correlated to the original, fix never runs
Date: Mon, 30 Nov 2026 15:51:14 -0500 [thread overview]
Message-ID: <aw3hwnJKWXXF8KUE@redhat.com> (raw)
In-Reply-To: <CAJATrkz6CgsaAFjeGT_1TuUTxrpVYEo=9rGuobnhpU-LPxv_dA@mail.gmail.com>
On Sat, Nov 28, 2026 at 08:51:14AM +0200, Seke Kazuru wrote:
> Hello,
>
> A livepatch module built by klp-build for a fix to ___bpf_prog_run()
> loads, reports "patching complete", and lists ___bpf_prog_run as
> patched, but the fixed instruction handlers never run. The replaced
> function dispatches through vmlinux's copy of its static jumptable,
> whose entries point into the original function body.
>
> Setup: Linux 6.19, x86_64, gcc 13, a config without BPF JIT (so every
> program runs in the interpreter), klp-build from the same tree:
>
> ./scripts/livepatch/klp-build -T --no-replace -o lp.ko fix.patch
>
> The fix is c77b30bd1dcb ("bpf: Fix undefined behavior in interpreter
> sdiv/smod for INT_MIN"), which changes the signed DIV and MOD handlers
> inside ___bpf_prog_run(). Those handlers are reached only through the
> computed-goto table:
>
> static const void * const jumptable[256] = { ... &&label ... };
>
> klp diff refers every static local of a changed function to the
> original kernel's copy unless is_uncorrelated_static_local() exempts its
> name. "jumptable" is not on that list (6.19, and still not in
> 7.4-rc4). The module's ___bpf_prog_run therefore carries a relocation
> to .klp.sym.vmlinux.jumptable.12 (R_X86_64_32S at +0x40), and every
> dispatch lands in the original handlers.
>
> Test, under KVM: a small helper module runs a three-instruction
> program through the interpreter (r0 = S32_MIN; r0 s/= 2 as ALU32 DIV K
> with off 1; exit) and prints r0. Unfixed code returns 0x40000000,
> fixed code 0xc0000000.
>
> boot 1, klp-build module as built:
> before load: 0x40000000 (6 of 6 runs)
> after load, enabled=1, transition=0, "patching complete",
> /sys/kernel/livepatch/<mod>/vmlinux/___bpf_prog_run,1 present:
> 0x40000000 (6 of 6 runs)
>
> boot 2, same command and same fix, with "jumptable." added to the
> list in is_uncorrelated_static_local():
> before load: 0x40000000 (6 of 6)
> after load: 0xc0000000 (6 of 6)
>
> The build prints no warning, and every kernel signal reports success.
> Any klp-build fix to ___bpf_prog_run has this effect on kernels that run
> the interpreter, that is without CONFIG_BPF_JIT_ALWAYS_ON when the JIT
> is off or unavailable.
>
> Two possible fixes:
>
> 1. Add "jumptable" to is_uncorrelated_static_local(). This is the change
> tested in boot 2. It covers this function only.
>
> 2. More generally, do not correlate a static local whose relocations
> point into the changed function's own text (label addresses). Such a
> table describes the code, not shared state, so it has to follow the
> new function. This would also cover any other computed-goto table.
>
> I can send the helper module, the program, the kernel config and the
> two klp-build logs. I am glad to test a patch on the same setup.
>
> This came up in a study of live-patch module fidelity. Of 70 klp-build
> modules built from real stable fixes on 6.19, this is the only one in
> which a changed function's new code does not run.
>
> Thank you for your time.
Hi Seke,
Thanks for the detailed report.
On the fixes: option 2 seems preferable. Option 1 (adding "jumptable"
to the list) may work but sounds fragile, it only catches tables spelled
"jumptable", right?
On the other hand, keying on "a static local whose relocations point
into the changed function's own text" would be compiler/name-agnostic I
believe.
Before settling on a fix, could you turn this repro into a regression
test for the objtool klp suite? It'd be fix-independent (any correct
fix makes it pass) and would guard this going forward. See
tools/objtool/Documentation/{klp-write-tests.txt,klp-test-design.txt}
and tools/objtool/tests/generic/test-switch-rodata.sh, which covers a
similar Clang switch-table test.
A computed-goto test, run under both gcc and clang, should reproduce it.
In my experience, AI agents can usually create a reasonable test from
the docs and a report like your own.
Thanks,
--
Joe
prev parent reply other threads:[~2026-11-30 20:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 6:51 objtool/klp: ___bpf_prog_run jumptable is correlated to the original, fix never runs Seke Kazuru
2026-11-30 20:51 ` Joe Lawrence [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=aw3hwnJKWXXF8KUE@redhat.com \
--to=joe.lawrence@redhat.com \
--cc=bpf@vger.kernel.org \
--cc=jpoimboe@kernel.org \
--cc=kazuruuni@gmail.com \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=song@kernel.org \
/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