Re: [PATCH] samples/livepatch: Add BPF struct_ops integration sample

From: Miroslav Benes

Date: Fri Apr 17 2026 - 04:19:35 EST


Hi,

On Wed, 15 Apr 2026, Song Liu wrote:

> Add a sample module that demonstrates how BPF struct_ops can work
> together with kernel livepatch. The module livepatches
> cmdline_proc_show() and delegates the output to a BPF struct_ops
> callback. When no BPF program is attached, a fallback message is
> shown; when a BPF struct_ops program is attached, it controls the
> /proc/cmdline output via the bpf_klp_seq_write kfunc.
>
> This builds on the existing livepatch-sample.c pattern but shows how
> livepatch and BPF struct_ops can be combined to make livepatched
> behavior programmable from userspace.
>
> The module is built when both CONFIG_SAMPLE_LIVEPATCH and
> CONFIG_BPF_JIT are enabled.
>
> Signed-off-by: Song Liu <song@xxxxxxxxxx>

Interesting. It does not make me comfortable to be honest. Is this
something we want to advertise through samples?

Sashiko has comments...
https://sashiko.dev/#/patchset/20260416001628.2062468-1-song%40kernel.org

Miroslav