From: Joe Lawrence <joe.lawrence@redhat.com>
To: Song Liu <song@kernel.org>
Cc: live-patching@vger.kernel.org,
Josh Poimboeuf <jpoimboe@kernel.org>,
Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
Petr Mladek <pmladek@suse.com>
Subject: Re: [PATCH v3 12/13] livepatch/klp-build: report patch validation drift
Date: Wed, 18 Feb 2026 10:09:10 -0500 [thread overview]
Message-ID: <aZXWFrrTDC0HpEBT@redhat.com> (raw)
In-Reply-To: <CAPhsuW4YN5PYp3iF8P3pBGF8vP62m0L-yEfD1pBut6fL+78N2Q@mail.gmail.com>
On Tue, Feb 17, 2026 at 11:42:21AM -0800, Song Liu wrote:
> On Tue, Feb 17, 2026 at 8:07 AM Joe Lawrence <joe.lawrence@redhat.com> wrote:
> >
> > Capture the output of the patch command to detect when a patch applies
> > with fuzz or line offsets.
> >
> > If such "drift" is detected during the validation phase, warn the user
> > and display the details. This helps identify input patches that may need
> > refreshing against the target source tree.
> >
> > Ensure that internal patch operations (such as those in refresh_patch or
> > during the final build phase) can still run quietly.
> >
> > Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
> > ---
> > scripts/livepatch/klp-build | 24 +++++++++++++++++++-----
> > 1 file changed, 19 insertions(+), 5 deletions(-)
> >
> > diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build
> > index fd104ace29e6..5367d573b94b 100755
> > --- a/scripts/livepatch/klp-build
> > +++ b/scripts/livepatch/klp-build
> > @@ -369,11 +369,24 @@ check_unsupported_patches() {
> >
> > apply_patch() {
> > local patch="$1"
> > + shift
> > + local extra_args=("$@")
> > + local drift_regex="with fuzz|offset [0-9]+ line"
> > + local output
> > + local status
> >
> > [[ ! -f "$patch" ]] && die "$patch doesn't exist"
> > - patch -d "$SRC" -p1 --dry-run --silent --no-backup-if-mismatch -r /dev/null < "$patch"
> > - patch -d "$SRC" -p1 --silent --no-backup-if-mismatch -r /dev/null < "$patch"
> > + status=0
> > + output=$(patch -d "$SRC" -p1 --dry-run --no-backup-if-mismatch -r /dev/null "${extra_args[@]}" < "$patch" 2>&1) || status=$?
> > + if [[ "$status" -ne 0 ]]; then
> > + echo "$output"
> > + die "$patch did not apply"
> > + elif [[ "$output" =~ $drift_regex ]]; then
> > + warn "$patch applied with drift"
> > + echo "$output"
> > + fi
>
> It appears we only need the non-silent "patch" command and the reporting
> logic in validate_patches(). Maybe we can have a different version of
> apply_patches for validate_patches(), say apply_patches_verbose(), and
> keep existing apply_patch() and apply_patches as-is?
>
Yes, you're right about the reporting cases. Splitting might be
cleaner, I'll consider for v4. This logic does get a little hairy to
handle the two cases of when we want to see output vs. not. (set -o
errexit forces us to disarm anything that might throw an error and bring
down the whole show.)
--
Joe
next prev parent reply other threads:[~2026-02-18 15:09 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-17 16:06 [PATCH v3 00/13] livepatch-klp-build: small fixups and enhancements Joe Lawrence
2026-02-17 16:06 ` [PATCH v3 01/13] objtool/klp: honor SHF_MERGE entry alignment in elf_add_data() Joe Lawrence
2026-02-17 16:14 ` Joe Lawrence
2026-03-05 2:33 ` Josh Poimboeuf
2026-03-10 14:02 ` Joe Lawrence
2026-03-10 16:34 ` Josh Poimboeuf
2026-02-17 16:06 ` [PATCH v3 02/13] objtool/klp: fix mkstemp() failure with long paths Joe Lawrence
2026-02-17 17:45 ` Song Liu
2026-02-17 16:06 ` [PATCH v3 03/13] livepatch/klp-build: support patches that add/remove files Joe Lawrence
2026-02-17 17:52 ` Song Liu
2026-02-17 16:06 ` [PATCH v3 04/13] livepatch/klp-build: switch to GNU patch and recountdiff Joe Lawrence
2026-02-17 16:06 ` [PATCH v3 05/13] livepatch/klp-build: add grep-override function Joe Lawrence
2026-02-17 18:22 ` Song Liu
2026-02-17 16:06 ` [PATCH v3 06/13] livepatch/klp-build: add Makefile with check target Joe Lawrence
2026-02-17 18:26 ` Song Liu
2026-02-17 16:06 ` [PATCH v3 07/13] livepatch/klp-build: fix shellcheck complaints Joe Lawrence
2026-02-17 18:30 ` Song Liu
2026-02-17 16:06 ` [PATCH v3 08/13] livepatch/klp-build: improve short-circuit validation Joe Lawrence
2026-02-17 18:29 ` Song Liu
2026-02-17 16:06 ` [PATCH v3 09/13] livepatch/klp-build: fix version mismatch when short-circuiting Joe Lawrence
2026-02-17 16:17 ` Joe Lawrence
2026-02-17 19:25 ` Song Liu
2026-02-18 15:04 ` Joe Lawrence
2026-02-19 2:52 ` Song Liu
2026-02-23 21:13 ` Josh Poimboeuf
2026-03-03 2:20 ` Joe Lawrence
2026-03-05 22:35 ` Josh Poimboeuf
2026-03-05 22:52 ` [PATCH] klp-build: Fix inconsistent kernel version Josh Poimboeuf
2026-03-10 13:45 ` Joe Lawrence
2026-03-10 16:30 ` Josh Poimboeuf
2026-02-17 16:06 ` [PATCH v3 10/13] livepatch/klp-build: provide friendlier error messages Joe Lawrence
2026-02-17 18:32 ` Song Liu
2026-02-23 21:15 ` Josh Poimboeuf
2026-03-03 2:20 ` Joe Lawrence
2026-02-17 16:06 ` [PATCH v3 11/13] livepatch/klp-build: add terminal color output Joe Lawrence
2026-02-17 16:20 ` Joe Lawrence
2026-02-17 18:45 ` Song Liu
2026-02-23 21:28 ` Josh Poimboeuf
2026-02-23 21:32 ` Josh Poimboeuf
2026-03-03 2:24 ` Joe Lawrence
2026-03-05 20:08 ` Josh Poimboeuf
2026-02-17 16:06 ` [PATCH v3 12/13] livepatch/klp-build: report patch validation drift Joe Lawrence
2026-02-17 19:42 ` Song Liu
2026-02-18 15:09 ` Joe Lawrence [this message]
2026-02-23 21:40 ` Josh Poimboeuf
2026-03-03 2:27 ` Joe Lawrence
2026-02-17 16:06 ` [PATCH v3 13/13] livepatch/klp-build: don't look for changed objects in tools/ Joe Lawrence
2026-02-17 19:29 ` Song Liu
2026-02-18 15:18 ` Joe Lawrence
2026-02-19 2:55 ` Song Liu
2026-02-23 21:41 ` Josh Poimboeuf
2026-03-03 2:30 ` Joe Lawrence
2026-03-05 20:10 ` Josh Poimboeuf
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=aZXWFrrTDC0HpEBT@redhat.com \
--to=joe.lawrence@redhat.com \
--cc=jikos@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--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