From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com,
joe.lawrence@redhat.com, song@kernel.org,
live-patching@vger.kernel.org
Subject: Re: [PATCH v7 for-next 3/8] livepatch: Implement replace set for scoped atomic replace
Date: Thu, 27 Aug 2026 20:39:49 -0700 [thread overview]
Message-ID: <apD937ehtQ3CUPBY@jpoimboe> (raw)
In-Reply-To: <CALOAHbAoJf-brcQW-QtXZzR+8xi2ZCAJNwyHBQguXJCr+5+5xg@mail.gmail.com>
On Fri, Aug 28, 2026 at 11:03:02AM +0800, Yafang Shao wrote:
> On Fri, Aug 28, 2026 at 8:26 AM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
> > > + # Remove duplicates from obsoletes (if specified)
> > > + # Note: provides ID is not added here; the kernel will replace
> > > + # livepatch with the same provides ID.
> > > + if [[ -n "$OBSOLETES" ]]; then
> > > + local obsoletes_clean="${OBSOLETES//[ ]/}"
> > > + local IFS=','
> > > + local -a obs_array=()
> > > + local obs_id
> > > + local already_exists
> > > +
> > > + for obs_id in $obsoletes_clean; do
> > > + if [[ -n "$obs_id" ]]; then
> > > + already_exists=0
> > > + for existing in "${obs_array[@]}"; do
> > > + if [[ "$existing" -eq "$obs_id" ]]; then
> > > + already_exists=1
> > > + break
> > > + fi
> > > + done
> > > +
> > > + if [[ "$already_exists" -eq 0 ]]; then
> > > + obs_array+=("$obs_id")
> > > + fi
> > > + fi
> > > + done
> > > +
> > > + local IFS=','
> > > + OBSOLETES="${obs_array[*]}"
> > > + unset IFS
> > > + fi
> > > +
> >
> > What's the point of this? Do we expect duplicates,
>
> Duplicated ids are indeed a user input error (e.g. -r "1,1,2,3") and
> should not be expected.
>
> > and if so, wouldn't
> > it be the kernel's job to handle that?
>
> On the kernel side the duplicates are safe:
> klp_patch_replaces() iterates over the obsoletes array and compares
> each entry against the other patches' provides, so a duplicated id is
> simply idempotent - the only side effect is duplicated ids shown in
> the /sys/kernel/livepatch/<patch>/obsoletes attribute.
>
> Silently deduplicating in klp-build was masking the input mistake.
> Agreed on the fail-fast approach: klp-build will now error out with a
> clear message when duplicate obsoletes ids are detected. The list
> passed to the kernel is then guaranteed clean, and the sysfs side
> effect cannot happen.
There are other ways of building livepatches beyond klp-build, and this
wouldn't prevent those other patch generation methods from making the
same mistake.
But since it doesn't actually break anything, and the user is not likely
to be setting multiple obsoletes, much less introducing duplicates, I
would say just remove the check altogether. It's not really a bug and I
doubt that somebody who is careless enough to have duplicate obsoletes
would notice or care that sysfs also has duplicates... and if they do
care, they should fix their patch :-)
For similar reasons I think some of the other error checking isn't
really needed (invalid comma usage, negative number check) as those will
either fail the build or will give the user what they asked for, not
dissimilar from providing a buggy patch.
Then I think the majority of those klp-build changes aren't needed, and
it can be a simple passthrough of the user cmdline:
cflags+=("-DKLP_OBSOLETES=$OBSOLETES")
--
Josh
next prev parent reply other threads:[~2026-08-28 3:39 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 11:46 [PATCH v7 for-next 0/8] livepatch: Introduce replace set support Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 1/8] livepatch: Make klp_find_func() non static Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 2/8] livepatch: Call klp_init_patch_early() earlier Yafang Shao
2026-08-25 12:06 ` sashiko-bot
2026-08-25 12:11 ` Yafang Shao
2026-08-27 23:57 ` Josh Poimboeuf
2026-08-28 2:24 ` Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 3/8] livepatch: Implement replace set for scoped atomic replace Yafang Shao
2026-08-25 11:59 ` sashiko-bot
2026-08-25 12:10 ` Yafang Shao
2026-08-28 0:26 ` Josh Poimboeuf
2026-08-28 3:03 ` Yafang Shao
2026-08-28 3:39 ` Josh Poimboeuf [this message]
2026-08-28 5:42 ` Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 4/8] livepatch: Deprecate stack_order Yafang Shao
2026-08-28 0:29 ` Josh Poimboeuf
2026-08-28 3:14 ` Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 5/8] selftests/livepatch: Adapt atomic replace tests to provides/obsoletes Yafang Shao
2026-08-28 0:31 ` Josh Poimboeuf
2026-08-28 3:56 ` Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 6/8] selftests/livepatch: Add provides/obsoletes test scenarios Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 7/8] selftests/livepatch: Add test for state ID conflict across provides Yafang Shao
2026-08-25 11:46 ` [PATCH v7 for-next 8/8] selftests/livepatch: Add test for function " Yafang Shao
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=apD937ehtQ3CUPBY@jpoimboe \
--to=jpoimboe@kernel.org \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=laoar.shao@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.