On Tue, Feb 03, 2026 at 09:51:38PM -0500, Joe Lawrence wrote:
> The klp-build script is currently very strict with input patches,
> requiring them to apply cleanly via `git apply --recount`. This
> prevents the use of patches with minor contextual fuzz relative to the
> target kernel sources.
>
> To allow users to reuse a patch across similar kernel streams, switch to
> using GNU patch and patchutils for intermediate patch manipulation.
> Update the logic for applying, reverting, and regenerating patches:
>
> - Use 'patch -p1' for better handling of context fuzz.
> - Use 'recountdiff' to update line counts after FIX_PATCH_LINES.
> - Drop git_refresh() and related git-specific logic.
>
> Signed-off-by: Joe Lawrence <[email protected]>
> ---
> scripts/livepatch/klp-build | 50 +++++++++++--------------------------
> 1 file changed, 14 insertions(+), 36 deletions(-)
>
Forgot to mention this was tested as per Josh's suggestion (slightly
modified*):
$ find . -type f -name '*.c' ! -path "./lib/*" -print0 | xargs -0 sed -i
'1iasm("nop");'
$ git checkout tools arch/x86/lib/inat.c arch/x86/lib/insn.c kernel/configs.c
$ git diff > /tmp/oneline.patch
$ ./scripts/livepatch/klp-build /tmp/oneline.patch
...
error: klp-build: no changes detected
* modified to exclude lib/ to dodge unsupported patch complaints, avoid
symlinks (GNU patch does not like), and kernel/configs.o which objtool
couldn't find its .discard.sym_checksum section
--
Joe