Re: [PATCH v6 0/8] livepatch: Introduce replace set support
From: Yafang Shao <hidden>
Date: 2026-08-24 03:41:49
On Mon, Aug 24, 2026 at 11:27 AM Yafang Shao [off-list ref] wrote:
We previously proposed a BPF+livepatch method to enable rapid experimentation with new kernel features without interrupting production workloads: https://lore.kernel.org/live-patching/20260402092607.96430-1-laoar.shao@gmail.com/ (local) In the resulting discussion, Song and Petr suggested adding a "replace set" to support scenarios where specific livepatches can be selectively replaced or skipped. This patchset introduces a more flexible model using two new fields in struct klp_patch: - provides: an unsigned int id identifying the patch replace set. By default (provides=0), any livepatch replaces any other livepatch. - obsoletes: an optional array of unsigned int ids specifying additional provides ids to be replaced. This allows a new patch to explicitly obsolete patches from different replace sets. A new livepatch atomically replaces any existing livepatch whose provides id matches either: 1. The new patch provides id (same replace set), or 2. Any id in the new patch obsoletes list Additionally, this design deprecates the traditional non-atomic-replace model. Previously, setting 'replace' to 0 was the only way to keep certain livepatches persistent on the system, forcing developers to disable atomic replacement entirely. With the introduction of replace set, developers now have a selective option to keep specific livepatches persistent while maintaining atomic replacement capabilities elsewhere. At present, KLP state, shadow variables, and callbacks are not integrated with the new replace_set mechanism in this patchset. Support for these features is deferred until Petr's klp-state-transfer infrastructure is completed and merged: https://github.com/pmladek/linux/tree/klp-state-transfer-v1-iter12 Future Work =========== - Allow `provides` and `obsoletes` to be configured dynamically at module load time, rather than being fixed at build time. Notes for sashiko-bot ===================== In your review of v5, you found the following issues: - A malformed livepatch module with a missing `old_name` triggers a NULL pointer dereference in `klp_find_func()`. This has already been addressed by commit 1a921fd13c31e ("livepatch: Fix NULL pointer dereference in klp_find_func()"). - When CONFIG_DEBUG_KOBJECT_RELEASE is enabled, an error during patch initialization causes a use-after-free during module unload due to the delayed kobject release. This is addressed by the patch posted at https://lore.kernel.org/live-patching/20260821031648.48195-1-laoar.shao@gmail.com/ (local) - Other review issues are addressed in this version; details in the changes section.
Oops. It seems the sashiko-bot failed to apply the patch because of this change: https://lore.kernel.org/live-patching/20260816090442.18128-2-laoar.shao@gmail.com/ (local) I based this series on that change. I'll wait for others' reviews and then rebase it onto the livepatch tree's for-next branch.
Changes ======= v5->v6: - Check `--provides` argument in `klp-build (sashiko) - Fix the 'replace' feature detection for OOT kernel builds (sashiko) - Fix race condition in sysfs polling (sashiko) v5: https://lore.kernel.org/live-patching/20260809091954.22930-1-laoar.shao@gmail.com (local)
[...] -- Regards Yafang