livepatch: Introduce replace set support
Subsystems (3)
v2 cover livepatch: Introduce replace set support
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/[email protected]/
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 patch introduces 'replace_set' to provide finer-grained control over livepatch management. The core rules and behaviors of a replace_set are defined as follows:
- Livepatches sharing the same replace_set can mutually replace each other.
- Only one livepatch within a given replace_set can be active at a time.
- Livepatches belonging to different replace_sets can coexist on the system.
- Livepatches in different replace_sets are prohibited from modifying the same function.
- Livepatches in different replace_sets cannot use the same state ID.
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
v1->v2:
- Incorporate feedback from Petr:
- Initialize replace_set to 0 by default
- Improve documentation
- Enforce that livepatches in different replace_sets cannot use the same
state->id.
- Enforce that livepatches in different replace_sets cannot modify the same function.
- Ensure consistent capitalization and naming usage of KLP_REPLACE_SET.
- Incorporate feedback from Sachiko AI:
- Skip the klp_transition patch during klp_force_transition().
v1 (RFC): https://lore.kernel.org/live-patching/[email protected]/
Yafang Shao (4):
livepatch: Make klp_find_func() non-static
livepatch: Support scoped atomic replace using replace_set
livepatch: Deprecate stack_order selftests/livepatch: Update tests for replace_set
.../ABI/testing/sysfs-kernel-livepatch | 6 +- .../livepatch/cumulative-patches.rst | 23 +++-- Documentation/livepatch/livepatch.rst | 21 ++-- include/linux/livepatch.h | 8 +- kernel/livepatch/core.c | 52 +++------- kernel/livepatch/state.c | 51 ++++++++-- kernel/livepatch/transition.c | 11 ++- scripts/livepatch/init.c | 6 +- scripts/livepatch/klp-build | 16 +-- .../selftests/livepatch/test-callbacks.sh | 33 +++---- .../selftests/livepatch/test-livepatch.sh | 98 +------------------ .../testing/selftests/livepatch/test-sysfs.sh | 91 +++-------------- .../test_modules/test_klp_atomic_replace.c | 10 +- .../test_modules/test_klp_callbacks_demo.c | 6 ++ .../test_modules/test_klp_callbacks_demo2.c | 10 +- .../test_modules/test_klp_livepatch.c | 6 ++ .../livepatch/test_modules/test_klp_state.c | 2 +- .../livepatch/test_modules/test_klp_state2.c | 2 +- 18 files changed, 165 insertions(+), 287 deletions(-)
Signature · 1 line
2.47.3
PATCH v2 1/4 livepatch: Make klp_find_func() non-static
Move klp_find_func() out of the static scope to make it available outside of core.c. It will be reused by the upcoming patch.
--- include/linux/livepatch.h | 4 ++++ kernel/livepatch/core.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
include/linux/livepatch.h +4 -0
@@ -215,6 +215,10 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs, unsigned int symindex, unsigned int secindex, const char *objname); +struct klp_func *klp_find_func (struct klp_object *obj, +struct klp_func *old_func); + +#else /* !CONFIG_LIVEPATCH */ static inline int klp_module_coming (struct module *mod) {return 0 ; }
kernel/livepatch/core.c +2 -2
@@ -82,8 +82,8 @@ static bool klp_initialized(void)return !!klp_root_kobj; } -static struct klp_func *klp_find_func (struct klp_object *obj, -struct klp_func *old_func) +struct klp_func *klp_find_func (struct klp_object *obj, +struct klp_func *old_func) {struct klp_func *func;
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v2 1/4] livepatch: Make klp_find_func() non-static
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Low] klp_find_func() is improperly exposed in the global public header, breaking encapsulation and introducing potential build/linkage errors.
Pre-existing issues:
- [High] klp_find_func() lacks input validation, exacerbating a pre-existing NULL pointer dereference vulnerability during livepatch loading. --
commit 0b93025e6e1dd48057bb98e4d5e13741daab118e
Author: Yafang Shao <[email protected]>
livepatch: Make klp_find_func() non-static
This commit exposes klp_find_func() by moving it out of the static scope to make it available outside of core.c for reuse in upcoming patches.
include/linux/livepatch.h int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs, · line 220
Quoted 11 lines
include/linux/livepatch.h +3
-0@@ -215,6 +215,10 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs, unsigned int symindex, unsigned int secindex, const char *objname); +struct klp_func *klp_find_func (struct klp_object *obj, +struct klp_func *old_func); +
[Severity: Low]
Does this declaration belong in kernel/livepatch/core.h instead? It lacks an EXPORT_SYMBOL_GPL() and a stub for when !CONFIG_LIVEPATCH is set.
[ ... ]
Quoted 5 lines
kernel/livepatch/core.c +0
-0
kernel/livepatch/core.c static bool klp_initialized(void) · line 88
Quoted 9 lines
kernel/livepatch/core.c +2
-2@@ -82,8 +82,8 @@ static bool klp_initialized(void)return !!klp_root_kobj; } -static struct klp_func *klp_find_func (struct klp_object *obj, -struct klp_func *old_func) +struct klp_func *klp_find_func (struct klp_object *obj, +struct klp_func *old_func) {struct klp_func *func;
[Severity: High]
This is a pre-existing issue, but does this function dereference a NULL pointer if old_name is NULL?
If a newly loaded livepatch provides a function entry with a NULL old_name, func->old_name will be NULL when evaluated in strcmp():
klp_init_patch()
klp_add_nops()
klp_find_func()
strcmp(old_func->old_name, func->old_name)Could a check be added for NULL before calling strcmp()?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 1/4] livepatch: Make klp_find_func() non-static
Quoted 5 lines · On Fri, May 29, 2026 at 12:01 PM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Low]klp_find_func()is improperly exposed in the global public header, breaking encapsulation and introducing potential build/linkage errors.
I will update it.
Quoted 3 lines
Pre-existing issues:
- [High]klp_find_func()lacks input validation, exacerbating a pre-existing NULL pointer dereference vulnerability during livepatch loading.
Valid. will fix this issue.
Signature · 2 lines
Regards Yafang
PATCH v2 2/4 livepatch: Support scoped atomic replace using replace_set
In reply to Yafang ShaoConvert the replace attribute from a boolean to a u32 to function as a "replace set." A newly loaded livepatch will now atomically replace any existing patch belonging to the same set. There can only ever be one active livepatch for a given replace_set number.
This change currently supports function replacement only. Livepatches that belong to different replace sets cannot modify the same function. If a new livepatch attempts to modify a function already modified by an older livepatch from a different replace_set, the loading of the new livepatch will be refused.
Similarly, for the KLP state, livepatches belonging to different replace sets cannot use the same state ID. The system will refuse to load a new livepatch if it uses a state ID already in use by an older livepatch from a different replace_set.
For the KLP shadow variable mechanism, developers must assign unique shadow IDs to livepatches that belong to different replace sets.
Support for replace_set compatibility with KLP state and shadow variables will be implemented after Petr's KLP state transfer work is completed [0].
Other user-visible changes include:
- The non-replace model is now deprecated
- /sys/kernel/livepatch/livepatch_XXX/replace attribute is replaced by /sys/kernel/livepatch/livepatch_XXX/replace_set
--- .../ABI/testing/sysfs-kernel-livepatch | 5 +- .../livepatch/cumulative-patches.rst | 23 ++++++--- Documentation/livepatch/livepatch.rst | 21 ++++---- include/linux/livepatch.h | 6 +-- kernel/livepatch/core.c | 24 +++++---- kernel/livepatch/state.c | 51 +++++++++++++++---- kernel/livepatch/transition.c | 11 ++-- scripts/livepatch/init.c | 6 +-- scripts/livepatch/klp-build | 16 +++--- 9 files changed, 104 insertions(+), 59 deletions(-)
Documentation/ABI/testing/sysfs-kernel-livepatch +2 -3
@@ -47,13 +47,12 @@ Description: disabled when the feature is used. See Documentation/livepatch/livepatch.rst for more information. -What: /sys/kernel/livepatch/<patch>/replace +What: /sys/kernel/livepatch/<patch>/replace_set Date: Jun 2024 KernelVersion: 6.11.0 Contact: [email protected] Description: - An attribute which indicates whether the patch supports - atomic-replace. + An attribute to show the replace_set of this livepatch. What: /sys/kernel/livepatch/<patch>/stack_order Date: Jan 2025
Documentation/livepatch/cumulative-patches.rst +15 -8
@@ -17,18 +17,20 @@ from all older livepatches and completely replace them in one transition. Usage ----- -The atomic replace can be enabled by setting "replace" flag in struct klp_patch, -for example:: +The "replace_set" attribute in ``struct klp_patch`` acts as a **replace_set**, +defining the scope of the replacement. By default, the replace_set is 0. + +For example:: static struct klp_patch patch = { .mod = THIS_MODULE, .objs = objs, - .replace = true, + .replace_set = 0, }; All processes are then migrated to use the code only from the new patch. -Once the transition is finished, all older patches are automatically -disabled. +Once the transition is finished, all older patches with the same replace +set are automatically disabled. Patches with different tags remain active. Ftrace handlers are transparently removed from functions that are no longer modified by the new cumulative patch.
@@ -62,9 +64,14 @@ Limitations: ------------ - Once the operation finishes, there is no straightforward way - to reverse it and restore the replaced patches atomically. - - A good practice is to set .replace flag in any released livepatch. + to reverse it and restore the replaced patches (with the same set) + atomically. + + A good practice is to use only one (default) "replace_set". It + makes sure that there always will be only one enabled livepatch + on the system. The consistency model will ensure a safe update + between two versions. It prevents potential problems with installing + two livepatches doing incompatible functional changes. Then re-adding an older livepatch is equivalent to downgrading to that patch. This is safe as long as the livepatches do _not_ do extra modifications in (un)patching callbacks or in the module_init()
Documentation/livepatch/livepatch.rst +12 -9
@@ -347,15 +347,18 @@ to '0'. 5.3. Replacing -------------- -All enabled patches might get replaced by a cumulative patch that -has the .replace flag set. - -Once the new patch is enabled and the 'transition' finishes then -all the functions (struct klp_func) associated with the replaced -patches are removed from the corresponding struct klp_ops. Also -the ftrace handler is unregistered and the struct klp_ops is -freed when the related function is not modified by the new patch -and func_stack list becomes empty. +There always can be only one livepatch with a given "replace_set" number. +They always replace each other. + +Once the transition is complete, all functions (``struct klp_func``) +associated with the matching replaced patches are removed from the +corresponding ``struct klp_ops``. If a function is no longer modified by +the new patch and its ``func_stack`` list becomes empty, the ftrace +handler is unregistered and the ``struct klp_ops`` is freed. + +Patches with a different replace set are not affected by this process +and remain active. This allows for the independent management and +stacking of multiple, non-conflicting livepatch sets. See Documentation/livepatch/cumulative-patches.rst for more details.
include/linux/livepatch.h +3 -3
@@ -123,7 +123,8 @@ struct klp_state {* @mod: reference to the live patch module * @objs: object entries for kernel objects to be patched * @states: system states that can get modified -* @replace: replace all actively used patches +* @replace_set:Livepatch using the same @replace_set will get atomically +* replaced. * @list: list node for global list of actively used patches * @kobj: kobject for sysfs resources * @obj_list: dynamic list of the object entries
@@ -137,7 +138,7 @@ struct klp_patch {struct module *mod;struct klp_object *objs;struct klp_state *states; -bool replace; +unsigned int replace_set;/* internal */ struct list_head list;
@@ -218,7 +219,6 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,struct klp_func *klp_find_func (struct klp_object *obj,struct klp_func *old_func); -#else /* !CONFIG_LIVEPATCH */ static inline int klp_module_coming (struct module *mod) {return 0 ; }
kernel/livepatch/core.c +14 -10
@@ -350,7 +350,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,* /sys/kernel/livepatch/<patch>/enabled * /sys/kernel/livepatch/<patch>/transition * /sys/kernel/livepatch/<patch>/force -* /sys/kernel/livepatch/<patch>/replace +* /sys/kernel/livepatch/<patch>/replace_set * /sys/kernel/livepatch/<patch>/stack_order * /sys/kernel/livepatch/<patch>/<object> * /sys/kernel/livepatch/<patch>/<object>/patched
@@ -448,13 +448,13 @@ static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr,return count; } -static ssize_t replace_show (struct kobject *kobj, +static ssize_t replace_set_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf) {struct klp_patch *patch; patch = container_of(kobj, struct klp_patch, kobj); -return sysfs_emit (buf,"%d\n" , patch->replace); +return sysfs_emit (buf,"%u\n" , patch->replace_set); } static ssize_t stack_order_show(struct kobject *kobj,
@@ -481,13 +481,13 @@ static ssize_t stack_order_show(struct kobject *kobj,static struct kobj_attribute enabled_kobj_attr =__ATTR_RW (enabled);static struct kobj_attribute transition_kobj_attr =__ATTR_RO (transition);static struct kobj_attribute force_kobj_attr =__ATTR_WO (force); -static struct kobj_attribute replace_kobj_attr =__ATTR_RO (replace); +static struct kobj_attribute replace_set_kobj_attr =__ATTR_RO (replace_set);static struct kobj_attribute stack_order_kobj_attr =__ATTR_RO (stack_order);static struct attribute *klp_patch_attrs[] = { &enabled_kobj_attr.attr, &transition_kobj_attr.attr, &force_kobj_attr.attr, - &replace_kobj_attr.attr, + &replace_set_kobj_attr.attr, &stack_order_kobj_attr.attr,NULL };
@@ -621,6 +621,8 @@ static int klp_add_nops(struct klp_patch *patch)klp_for_each_object (old_patch, old_obj) {int err; +if (patch->replace_set != old_patch->replace_set) +continue ; err =klp_add_object_nops (patch, old_obj);if (err)return err;
@@ -793,6 +795,8 @@ void klp_free_replaced_patches_async(struct klp_patch *new_patch)klp_for_each_patch_safe (old_patch, tmp_patch) {if (old_patch == new_patch)return ; +if (old_patch->replace_set != new_patch->replace_set) +continue ;klp_free_patch_async (old_patch); } }
@@ -988,11 +992,9 @@ static int klp_init_patch(struct klp_patch *patch)if (ret)return ret; -if (patch->replace) { - ret =klp_add_nops (patch); -if (ret) -return ret; - } + ret =klp_add_nops (patch); +if (ret) +return ret;klp_for_each_object (patch, obj) { ret =klp_init_object (patch, obj);
@@ -1195,6 +1197,8 @@ void klp_unpatch_replaced_patches(struct klp_patch *new_patch)if (old_patch == new_patch)return ; +if (old_patch->replace_set != new_patch->replace_set) +continue ; old_patch->enabled = false;klp_unpatch_objects (old_patch); }
kernel/livepatch/state.c +41 -10
75 lines not on this page · raw message
kernel/livepatch/transition.c +6 -5
@@ -89,7 +89,7 @@ static void klp_complete_transition(void) klp_transition_patch->mod->name, klp_target_state == KLP_TRANSITION_PATCHED ? "patching" : "unpatching"); -if (klp_transition_patch->replace && klp_target_state ==KLP_TRANSITION_PATCHED ) { +if (klp_target_state ==KLP_TRANSITION_PATCHED ) {klp_unpatch_replaced_patches (klp_transition_patch);klp_discard_nops (klp_transition_patch); }
@@ -498,7 +498,7 @@ void klp_try_complete_transition(void)*/ if (!patch->enabled)klp_free_patch_async (patch); -else if (patch->replace) +else klp_free_replaced_patches_async (patch); }
@@ -720,11 +720,12 @@ void klp_force_transition(void)klp_update_patch_state (idle_task (cpu));/* Set forced flag for patches being removed. */ -if (klp_target_state ==KLP_TRANSITION_UNPATCHED ) +if (klp_target_state ==KLP_TRANSITION_UNPATCHED ) { klp_transition_patch->forced = true; -else if (klp_transition_patch->replace) { + }else {klp_for_each_patch (patch) { -if (patch != klp_transition_patch) +if (patch != klp_transition_patch && + patch->replace_set == klp_transition_patch->replace_set) patch->forced = true; } }
scripts/livepatch/init.c +3 -3
@@ -72,10 +72,10 @@ static int __init livepatch_mod_init(void)/* TODO patch->states */ -#ifdef KLP_NO_REPLACE - patch->replace = false; +#ifdef KLP_REPLACE_SET + patch->replace_set =KLP_REPLACE_SET ;#else - patch->replace = true; + patch->replace_set =0 ;#endif return klp_enable_patch (patch);
scripts/livepatch/klp-build +8 -8
@@ -22,7 +22,7 @@ shopt -s lastpipe unset DEBUG_CLONE DIFF_CHECKSUM SKIP_CLEANUP XTRACE -REPLACE=1 +REPLACE_SET=0 SHORT_CIRCUIT=0 JOBS="$(getconf _NPROCESSORS_ONLN)" VERBOSE="-s"
@@ -134,7 +134,7 @@ Options: -f, --show-first-changed Show address of first changed instruction -j, --jobs=<jobs> Build jobs to run simultaneously [default: $JOBS] -o, --output=<file.ko> Output file [default: livepatch-<patch-name>.ko] - --no-replace Disable livepatch atomic replace + -s, --replace-set=<set> Set the atomic replace set for this livepatch -v, --verbose Pass V=1 to kernel/module builds Advanced Options:
@@ -159,8 +159,8 @@ process_args() { local long local args - short="hfj:o:vdS:T" - long="help,show-first-changed,jobs:,output:,no-replace,verbose,debug,short-circuit:,keep-tmp" + short="hfj:o:s:vdS:T" + long="help,show-first-changed,jobs:,output:,replace-set:,verbose,debug,short-circuit:,keep-tmp" args=$(getopt --options "$short" --longoptions "$long" -- "$@") || { echo; usage; exit
@@ -189,9 +189,9 @@ process_args() { NAME="$(module_name_string "$NAME")" shift 2 ;; - --no-replace) - REPLACE=0 - shift + -s | --replace-set) + REPLACE_SET="$2" + shift 2 ;; -v | --verbose) VERBOSE="V=1"
@@ -777,7 +777,7 @@ build_patch_module() { cflags=("-ffunction-sections") cflags+=("-fdata-sections") - [[ $REPLACE -eq 0 ]] && cflags+=("-DKLP_NO_REPLACE") + cflags+=("-DKLP_REPLACE_SET=$REPLACE_SET") cmd=("make") cmd+=("$VERBOSE")
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v2 2/4] livepatch: Support scoped atomic replace using replace_set
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] A malformed livepatch module with a missing function `old_name` will cause a kernel panic during…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] A malformed livepatch module with a missing function old_name will cause a kernel panic during patch compatibility checking. --
commit 48dd0b716d1f70f13c1e96b75bf54e1aba77be18
Author: Yafang Shao <[email protected]>
livepatch: Support scoped atomic replace using replace_set
Convert the replace attribute from a boolean to a u32 to function as a "replace set." A newly loaded livepatch will now atomically replace any existing patch belonging to the same set. There can only ever be one active livepatch for a given replace_set number.
Quoted 4 lines
kernel/livepatch/state.c +0
-0
[ ... ]
Quoted 1 line
kernel/livepatch/state.c +0
-0@@ -85,34 +85,65 @@ EXPORT_SYMBOL_GPL(klp_get_prev_state);
[ ... ]
kernel/livepatch/state.c EXPORT_SYMBOL_GPL(klp_get_prev_state); · line 146
Quoted 12 lines
kernel/livepatch/state.c +12
-0+klp_for_each_object_static (patch, obj) { +klp_for_each_object (old_patch, old_obj) { +if (!!obj->name != !!old_obj->name) +continue ; +if (obj->name &&strcmp (obj->name, old_obj->name)) +continue ; +klp_for_each_func_static (obj, func) { +if (klp_find_func (old_obj, func)) +return false; + } + } + }
[Severity: High]
Could a malformed livepatch module cause a kernel panic here during patch compatibility checking?
Since klp_is_patch_compatible() is called in klp_enable_patch() before klp_init_patch() validates the incoming patch structures, a malformed patch might have func->old_name set to NULL but func->new_func populated.
In that scenario, klp_for_each_func_static() would still process the function and pass it to klp_find_func(), where it is used as old_func:
kernel/livepatch/core.c:klp_find_func() {
...
klp_for_each_func(obj, func) {
if ((strcmp(old_func->old_name, func->old_name) == 0) &&
...
}Would this result in a NULL pointer dereference when klp_find_func() attempts to call strcmp() on the unvalidated function's old_name? While livepatch modules are loaded by root, should they fail validation gracefully instead of crashing the kernel?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v2 2/4] livepatch: Support scoped atomic replace using replace_set
Quoted 3 lines · On Fri, May 29, 2026 at 12:32 PM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] A malformed livepatch module with a missing functionold_namewill cause a kernel panic during patch compatibility checking.
The same issue with Patch #1.
Signature · 2 lines
Regards Yafang
PATCH v2 3/4 livepatch: deprecate stack_order
In reply to Yafang Shaostack_order is no longer needed for atomic-replace livepatches, as a single function can only be modified by a unique replace_set.
--- .../ABI/testing/sysfs-kernel-livepatch | 1 + kernel/livepatch/core.c | 24 ------- .../testing/selftests/livepatch/test-sysfs.sh | 69 ------------------- 3 files changed, 1 insertion(+), 93 deletions(-)
Documentation/ABI/testing/sysfs-kernel-livepatch +1 -0
@@ -62,6 +62,7 @@ Description: are applied to the system. If multiple live patches modify the same function, the implementation with the biggest 'stack_order' number is used, unless a transition is currently in progress. + <deprecated> What: /sys/kernel/livepatch/<patch>/<object> Date: Nov 2014
kernel/livepatch/core.c +0 -24
@@ -351,7 +351,6 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,* /sys/kernel/livepatch/<patch>/transition * /sys/kernel/livepatch/<patch>/force * /sys/kernel/livepatch/<patch>/replace_set -* /sys/kernel/livepatch/<patch>/stack_order * /sys/kernel/livepatch/<patch>/<object> * /sys/kernel/livepatch/<patch>/<object>/patched * /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
@@ -457,38 +456,15 @@ static ssize_t replace_set_show(struct kobject *kobj,return sysfs_emit (buf,"%u\n" , patch->replace_set); } -static ssize_t stack_order_show (struct kobject *kobj, -struct kobj_attribute *attr,char *buf) -{ -struct klp_patch *patch, *this_patch; -int stack_order =0 ; - - this_patch = container_of(kobj, struct klp_patch, kobj); - -mutex_lock (&klp_mutex); - -klp_for_each_patch (patch) { - stack_order++; -if (patch == this_patch) -break ; - } - -mutex_unlock (&klp_mutex); - -return sysfs_emit (buf,"%d\n" , stack_order); -} -static struct kobj_attribute enabled_kobj_attr =__ATTR_RW (enabled);static struct kobj_attribute transition_kobj_attr =__ATTR_RO (transition);static struct kobj_attribute force_kobj_attr =__ATTR_WO (force);static struct kobj_attribute replace_set_kobj_attr =__ATTR_RO (replace_set); -static struct kobj_attribute stack_order_kobj_attr =__ATTR_RO (stack_order);static struct attribute *klp_patch_attrs[] = { &enabled_kobj_attr.attr, &transition_kobj_attr.attr, &force_kobj_attr.attr, &replace_set_kobj_attr.attr, - &stack_order_kobj_attr.attr,NULL };ATTRIBUTE_GROUPS (klp_patch);
tools/testing/selftests/livepatch/test-sysfs.sh +0 -69
79 lines not on this page · raw message
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v2 3/4] livepatch: deprecate stack_order
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Critical] The commit entirely removes the `stack_order` sysfs attribute while only marking it as…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] The commit entirely removes the stack_order sysfs attribute while only marking it as <deprecated> in the ABI documentation, causing immediate backwards compatibility breakage and contradicting documentation guidelines. --
commit 041b2dbba1a7397626104dd773fc1f37228d382c
Author: Yafang Shao <[email protected]>
livepatch: deprecate stack_order
This commit deprecates the stack_order sysfs attribute for atomic-replace livepatches, since a single function can only be modified by a unique replace_set.
Quoted 9 lines
Documentation/ABI/testing/sysfs-kernel-livepatch +1
-0@@ -62,6 +62,7 @@ Description: are applied to the system. If multiple live patches modify the same function, the implementation with the biggest 'stack_order' number is used, unless a transition is currently in progress. + <deprecated>
[ ... ]
Quoted 4 lines
kernel/livepatch/core.c +0
-0
[ ... ]
Quoted 28 lines
kernel/livepatch/core.c +0
-21@@ -457,38 +456,15 @@ static ssize_t replace_set_show(struct kobject *kobj,return sysfs_emit (buf,"%u\n" , patch->replace_set); } -static ssize_t stack_order_show (struct kobject *kobj, -struct kobj_attribute *attr,char *buf) -{ -struct klp_patch *patch, *this_patch; -int stack_order =0 ; - - this_patch = container_of(kobj, struct klp_patch, kobj); - -mutex_lock (&klp_mutex); - -klp_for_each_patch (patch) { - stack_order++; -if (patch == this_patch) -break ; - } - -mutex_unlock (&klp_mutex); - -return sysfs_emit (buf,"%d\n" , stack_order); -} -static struct kobj_attribute enabled_kobj_attr =__ATTR_RW (enabled);static struct kobj_attribute transition_kobj_attr =__ATTR_RO (transition);static struct kobj_attribute force_kobj_attr =__ATTR_WO (force);
kernel/livepatch/core.c static ssize_t replace_set_show(struct kobject *kobj, · line 469
Quoted 10 lines
kernel/livepatch/core.c +0
-2static struct kobj_attribute replace_set_kobj_attr =__ATTR_RO (replace_set); -static struct kobj_attribute stack_order_kobj_attr =__ATTR_RO (stack_order);static struct attribute *klp_patch_attrs[] = { &enabled_kobj_attr.attr, &transition_kobj_attr.attr, &force_kobj_attr.attr, &replace_set_kobj_attr.attr, - &stack_order_kobj_attr.attr,NULL };
[Severity: Critical]
The commit message and documentation state that the stack_order attribute is being deprecated, but this code completely removes the attribute. Does this abruptly break ABI compatibility for userspace tools that expect this sysfs file to exist?
Normally, deprecating an interface requires keeping it around for a transition period (perhaps returning a dummy value) rather than deleting it immediately. Also, if it were actually removed, shouldn't the ABI documentation be moved to the removed/ directory instead of just appending <deprecated> to the existing entry?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v2 3/4] livepatch: deprecate stack_order
Quoted 76 lines · On Fri, May 29, 2026 at 12:54 PM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] The commit entirely removes thestack_ordersysfs attribute while only marking it as<deprecated>in the ABI documentation, causing immediate backwards compatibility breakage and contradicting documentation guidelines. --commit
041b2dbba1a7397626104dd773fc1f37228d382c
Author: Yafang Shao <[email protected]>livepatch: deprecate
stack_orderThis commit deprecates the
stack_ordersysfs attribute for atomic-replace livepatches, since a single function can only be modified by a uniquereplace_set.Quoted 9 lines
Documentation/ABI/testing/sysfs-kernel-livepatch +1
-0@@ -62,6 +62,7 @@ Description: are applied to the system. If multiple live patches modify the same function, the implementation with the biggest 'stack_order' number is used, unless a transition is currently in progress. + <deprecated>[ ... ]
Quoted 4 lines
kernel/livepatch/core.c +0
-0[ ... ]
Quoted 28 lines
kernel/livepatch/core.c +0
-21@@ -457,38 +456,15 @@ static ssize_t replace_set_show(struct kobject *kobj,return sysfs_emit (buf,"%u\n" , patch->replace_set); } -static ssize_t stack_order_show (struct kobject *kobj, -struct kobj_attribute *attr,char *buf) -{ -struct klp_patch *patch, *this_patch; -int stack_order =0 ; - - this_patch = container_of(kobj, struct klp_patch, kobj); - -mutex_lock (&klp_mutex); - -klp_for_each_patch (patch) { - stack_order++; -if (patch == this_patch) -break ; - } - -mutex_unlock (&klp_mutex); - -return sysfs_emit (buf,"%d\n" , stack_order); -} -static struct kobj_attribute enabled_kobj_attr =__ATTR_RW (enabled);static struct kobj_attribute transition_kobj_attr =__ATTR_RO (transition);static struct kobj_attribute force_kobj_attr =__ATTR_WO (force);kernel/livepatch/core.c static ssize_t replace_set_show(struct kobject *kobj, · line 469
Quoted 10 lines
kernel/livepatch/core.c +0
-2static struct kobj_attribute replace_set_kobj_attr =__ATTR_RO (replace_set); -static struct kobj_attribute stack_order_kobj_attr =__ATTR_RO (stack_order);static struct attribute *klp_patch_attrs[] = { &enabled_kobj_attr.attr, &transition_kobj_attr.attr, &force_kobj_attr.attr, &replace_set_kobj_attr.attr, - &stack_order_kobj_attr.attr,NULL };[Severity: Critical]
The commit message and documentation state that thestack_orderattribute is being deprecated, but this code completely removes the attribute. Does this abruptly break ABI compatibility for userspace tools that expect this sysfs file to exist?
Quoted 5 lines
Normally, deprecating an interface requires keeping it around for a transition period (perhaps returning a dummy value) rather than deleting it immediately. Also, if it were actually removed, shouldn't the ABI documentation be moved to the removed/ directory instead of just appending <deprecated> to the existing entry?
I will wait for the feedback from the maintainers.
Signature · 2 lines
Regards Yafang
PATCH v2 4/4 selftests/livepatch: Update tests for replace_set
In reply to Yafang ShaoThe changes are as follows:
- Replace "replace" with "replace_set"
- For atomic-replace test cases, we configure two different livepatches that share the same replace_set.
- For non-atomic-replace test cases, we configure multiple livepatches, each with a different replace_set.
The result are as follows,
$ ./test-callbacks.sh TEST: target module before livepatch ... ok TEST: module_coming notifier ... ok TEST: module_going notifier ... ok TEST: module_coming and module_going notifiers ... ok TEST: target module not present ... ok TEST: pre-patch callback -ENODEV ... ok TEST: module_coming + pre-patch callback -ENODEV ... ok TEST: multiple target modules ... ok TEST: busy target module ... ok TEST: multiple livepatches ... ok TEST: atomic replace ... ok
$ ./test-ftrace.sh TEST: livepatch interaction with ftrace_enabled sysctl ... ok TEST: trace livepatched function and check that the live patch remains in effect ... ok TEST: livepatch a traced function and check that the live patch remains in effect ... ok
$ ./test-kprobe.sh TEST: livepatch interaction with kprobed function with post_handler ... ok TEST: livepatch interaction with kprobed function without post_handler ... ok
$ ./test-livepatch.sh TEST: basic function patching ... ok TEST: multiple livepatches ... ok TEST: module function patching ... ok TEST: module function patching (livepatch first) ... ok
$ ./test-shadow-vars.sh TEST: basic shadow variable API ... ok
$ ./test-state.sh TEST: system state modification ... ok TEST: taking over system state modification ... ok TEST: compatible cumulative livepatches ... ok TEST: incompatible cumulative livepatches ... ok
$ ./test-syscall.sh TEST: patch getpid syscall while being heavily hammered ... ok
--- .../selftests/livepatch/test-callbacks.sh | 33 +++---- .../selftests/livepatch/test-livepatch.sh | 98 +------------------ .../testing/selftests/livepatch/test-sysfs.sh | 22 ++--- .../test_modules/test_klp_atomic_replace.c | 10 +- .../test_modules/test_klp_callbacks_demo.c | 6 ++ .../test_modules/test_klp_callbacks_demo2.c | 10 +- .../test_modules/test_klp_livepatch.c | 6 ++ .../livepatch/test_modules/test_klp_state.c | 2 +- .../livepatch/test_modules/test_klp_state2.c | 2 +- 9 files changed, 55 insertions(+), 134 deletions(-)
tools/testing/selftests/livepatch/test-callbacks.sh +16 -17
@@ -451,8 +451,8 @@ $MOD_TARGET_BUSY: busymod_work_func exit $MOD_TARGET_BUSY: ${MOD_TARGET_BUSY}_exit" -# Test loading multiple livepatches. This test-case is mainly for comparing -# with the next test-case. +# Test loading multiple livepatches sharing different replace_set. +# This test-case is mainly for comparing with the next test-case. # # - Load and unload two livepatches, pre and post (un)patch callbacks # execute as each patch progresses through its (un)patching
@@ -460,14 +460,14 @@ $MOD_TARGET_BUSY: ${MOD_TARGET_BUSY}_exit" start_test "multiple livepatches" -load_lp $MOD_LIVEPATCH -load_lp $MOD_LIVEPATCH2 +load_lp $MOD_LIVEPATCH replace_set=0 +load_lp $MOD_LIVEPATCH2 replace_set=1 disable_lp $MOD_LIVEPATCH2 disable_lp $MOD_LIVEPATCH unload_lp $MOD_LIVEPATCH2 unload_lp $MOD_LIVEPATCH -check_result "% insmod test_modules/$MOD_LIVEPATCH.ko +check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace_set=0 livepatch: enabling patch '$MOD_LIVEPATCH' livepatch: '$MOD_LIVEPATCH': initializing patching transition $MOD_LIVEPATCH: pre_patch_callback: vmlinux
@@ -475,7 +475,7 @@ livepatch: '$MOD_LIVEPATCH': starting patching transition livepatch: '$MOD_LIVEPATCH': completing patching transition $MOD_LIVEPATCH: post_patch_callback: vmlinux livepatch: '$MOD_LIVEPATCH': patching complete -% insmod test_modules/$MOD_LIVEPATCH2.ko +% insmod test_modules/$MOD_LIVEPATCH2.ko replace_set=1 livepatch: enabling patch '$MOD_LIVEPATCH2' livepatch: '$MOD_LIVEPATCH2': initializing patching transition $MOD_LIVEPATCH2: pre_patch_callback: vmlinux
@@ -501,14 +501,13 @@ livepatch: '$MOD_LIVEPATCH': unpatching complete % rmmod $MOD_LIVEPATCH" -# Load multiple livepatches, but the second as an 'atomic-replace' -# patch. When the latter loads, the original livepatch should be -# disabled and *none* of its pre/post-unpatch callbacks executed. On -# the other hand, when the atomic-replace livepatch is disabled, its -# pre/post-unpatch callbacks *should* be executed. +# Load multiple livepatches sharing the same replace_set. +# When the latter loads, the original livepatch should be disabled and +# *none* of its pre/post-unpatch callbacks executed. On the other hand, +# when the atomic-replace livepatch is disabled, its pre/post-unpatch +# callbacks *should* be executed. # -# - Load and unload two livepatches, the second of which has its -# .replace flag set true. +# - Load and unload two livepatches sharing the same replace_set # # - Pre and post patch callbacks are executed for both livepatches. #
@@ -517,13 +516,13 @@ livepatch: '$MOD_LIVEPATCH': unpatching complete start_test "atomic replace" -load_lp $MOD_LIVEPATCH -load_lp $MOD_LIVEPATCH2 replace=1 +load_lp $MOD_LIVEPATCH replace_set=0 +load_lp $MOD_LIVEPATCH2 replace_set=0 disable_lp $MOD_LIVEPATCH2 unload_lp $MOD_LIVEPATCH2 unload_lp $MOD_LIVEPATCH -check_result "% insmod test_modules/$MOD_LIVEPATCH.ko +check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace_set=0 livepatch: enabling patch '$MOD_LIVEPATCH' livepatch: '$MOD_LIVEPATCH': initializing patching transition $MOD_LIVEPATCH: pre_patch_callback: vmlinux
@@ -531,7 +530,7 @@ livepatch: '$MOD_LIVEPATCH': starting patching transition livepatch: '$MOD_LIVEPATCH': completing patching transition $MOD_LIVEPATCH: post_patch_callback: vmlinux livepatch: '$MOD_LIVEPATCH': patching complete -% insmod test_modules/$MOD_LIVEPATCH2.ko replace=1 +% insmod test_modules/$MOD_LIVEPATCH2.ko replace_set=0 livepatch: enabling patch '$MOD_LIVEPATCH2' livepatch: '$MOD_LIVEPATCH2': initializing patching transition $MOD_LIVEPATCH2: pre_patch_callback: vmlinux
tools/testing/selftests/livepatch/test-livepatch.sh +4 -94
126 lines not on this page · raw message
tools/testing/selftests/livepatch/test-sysfs.sh +11 -11
@@ -20,7 +20,7 @@ check_sysfs_rights "$MOD_LIVEPATCH" "" "drwxr-xr-x" check_sysfs_rights "$MOD_LIVEPATCH" "enabled" "-rw-r--r--" check_sysfs_value "$MOD_LIVEPATCH" "enabled" "1" check_sysfs_rights "$MOD_LIVEPATCH" "force" "--w-------" -check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--" +check_sysfs_rights "$MOD_LIVEPATCH" "replace_set" "-r--r--r--" check_sysfs_rights "$MOD_LIVEPATCH" "transition" "-r--r--r--" check_sysfs_value "$MOD_LIVEPATCH" "transition" "0" check_sysfs_rights "$MOD_LIVEPATCH" "vmlinux/patched" "-r--r--r--"
@@ -86,18 +86,18 @@ test_klp_callbacks_demo: post_unpatch_callback: vmlinux livepatch: 'test_klp_callbacks_demo': unpatching complete % rmmod test_klp_callbacks_demo" -start_test "sysfs test replace enabled" +start_test "sysfs test replace_set 0" MOD_LIVEPATCH=test_klp_atomic_replace -load_lp $MOD_LIVEPATCH replace=1 +load_lp $MOD_LIVEPATCH replace_set=0 -check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--" -check_sysfs_value "$MOD_LIVEPATCH" "replace" "1" +check_sysfs_rights "$MOD_LIVEPATCH" "replace_set" "-r--r--r--" +check_sysfs_value "$MOD_LIVEPATCH" "replace_set" "0" disable_lp $MOD_LIVEPATCH unload_lp $MOD_LIVEPATCH -check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=1 +check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace_set=0 livepatch: enabling patch '$MOD_LIVEPATCH' livepatch: '$MOD_LIVEPATCH': initializing patching transition livepatch: '$MOD_LIVEPATCH': starting patching transition
@@ -110,17 +110,17 @@ livepatch: '$MOD_LIVEPATCH': completing unpatching transition livepatch: '$MOD_LIVEPATCH': unpatching complete % rmmod $MOD_LIVEPATCH" -start_test "sysfs test replace disabled" +start_test "sysfs test replace_set 1234" -load_lp $MOD_LIVEPATCH replace=0 +load_lp $MOD_LIVEPATCH replace_set=1234 -check_sysfs_rights "$MOD_LIVEPATCH" "replace" "-r--r--r--" -check_sysfs_value "$MOD_LIVEPATCH" "replace" "0" +check_sysfs_rights "$MOD_LIVEPATCH" "replace_set" "-r--r--r--" +check_sysfs_value "$MOD_LIVEPATCH" "replace_set" "1234" disable_lp $MOD_LIVEPATCH unload_lp $MOD_LIVEPATCH -check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace=0 +check_result "% insmod test_modules/$MOD_LIVEPATCH.ko replace_set=1234 livepatch: enabling patch '$MOD_LIVEPATCH' livepatch: '$MOD_LIVEPATCH': initializing patching transition livepatch: '$MOD_LIVEPATCH': starting patching transition
tools/testing/selftests/livepatch/test_modules/test_klp_atomic_replace.c +5 -5
@@ -7,9 +7,9 @@#include <linux/kernel.h> #include <linux/livepatch.h> -static int replace; -module_param (replace, int,0644 ); -MODULE_PARM_DESC (replace,"replace (default=0)" ); +static int replace_set; +module_param (replace_set, int,0644 ); +MODULE_PARM_DESC (replace_set,"replace_set (default=0)" );#include <linux/seq_file.h> static int livepatch_meminfo_proc_show (struct seq_file *m,void *v)
@@ -36,12 +36,12 @@ static struct klp_object objs[] = {static struct klp_patch patch = { .mod =THIS_MODULE , .objs = objs, -/* set .replace in the init function below for demo purposes */ +/* set .replace_set in the init function below for demo purposes */ };static int test_klp_atomic_replace_init (void ) { - patch.replace = replace; + patch.replace_set = replace_set;return klp_enable_patch (&patch); }
tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_demo.c +6 -0
@@ -7,6 +7,10 @@#include <linux/kernel.h> #include <linux/livepatch.h> +static int replace_set; +module_param (replace_set, int,0644 ); +MODULE_PARM_DESC (replace_set,"replace_set (default=0)" ); +static int pre_patch_ret;module_param (pre_patch_ret, int,0644 );MODULE_PARM_DESC (pre_patch_ret,"pre_patch_ret (default=0)" );
@@ -102,10 +106,12 @@ static struct klp_object objs[] = {static struct klp_patch patch = { .mod =THIS_MODULE , .objs = objs, +/* set .replace_set in the init function below for demo purposes */ };static int test_klp_callbacks_demo_init (void ) { + patch.replace_set = replace_set;return klp_enable_patch (&patch); }
tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_demo2.c +5 -5
@@ -7,9 +7,9 @@#include <linux/kernel.h> #include <linux/livepatch.h> -static int replace; -module_param (replace, int,0644 ); -MODULE_PARM_DESC (replace,"replace (default=0)" ); +static int replace_set; +module_param (replace_set, int,0644 ); +MODULE_PARM_DESC (replace_set,"replace_set (default=0)" );static const char *const module_state[] = { [MODULE_STATE_LIVE ] ="[MODULE_STATE_LIVE] Normal state" ,
@@ -72,12 +72,12 @@ static struct klp_object objs[] = {static struct klp_patch patch = { .mod =THIS_MODULE , .objs = objs, -/* set .replace in the init function below for demo purposes */ +/* set .replace_set in the init function below for demo purposes */ };static int test_klp_callbacks_demo2_init (void ) { - patch.replace = replace; + patch.replace_set = replace_set;return klp_enable_patch (&patch); }
tools/testing/selftests/livepatch/test_modules/test_klp_livepatch.c +6 -0
@@ -15,6 +15,10 @@ static int livepatch_cmdline_proc_show(struct seq_file *m, void *v)return 0 ; } +static int replace_set; +module_param (replace_set, int,0644 ); +MODULE_PARM_DESC (replace_set,"replace_set (default=0)" ); +static struct klp_func funcs[] = { { .old_name ="cmdline_proc_show" ,
@@ -32,10 +36,12 @@ static struct klp_object objs[] = {static struct klp_patch patch = { .mod =THIS_MODULE , .objs = objs, +/* set .replace_set in the init function below for demo purposes */ };static int test_klp_livepatch_init (void ) { + patch.replace_set = replace_set;return klp_enable_patch (&patch); }
tools/testing/selftests/livepatch/test_modules/test_klp_state.c +1 -1
@@ -142,7 +142,7 @@ static struct klp_patch patch = { .mod = THIS_MODULE, .objs = objs, .states = states, - .replace = true, + .replace_set = 0, };static int test_klp_callbacks_demo_init (void )
tools/testing/selftests/livepatch/test_modules/test_klp_state2.c +1 -1
@@ -171,7 +171,7 @@ static struct klp_patch patch = { .mod = THIS_MODULE, .objs = objs, .states = states, - .replace = true, + .replace_set = 0, };static int test_klp_callbacks_demo_init (void )
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v2 4/4] selftests/livepatch: Update tests for replace_set
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The 'atomic replace livepatch' test case in test-livepatch.sh was completely removed instead of…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The 'atomic replace livepatch' test case in test-livepatch.sh was completely removed instead of being updated, resulting in lost test coverage and leaving behind dead variables. --
commit 99bb60c2ba8319ec21289c482f1ea304e282396c
Author: Yafang Shao <[email protected]>
selftests/livepatch: Update tests for replace_set
This commit updates the livepatch selftests to use "replace_set" instead of "replace". It configures different livepatches to share or have different replace_sets to test atomic and non-atomic replace behaviors.
Quoted 4 lines
tools/testing/selftests/livepatch/test-livepatch.sh +0
-0
[ ... ]
Quoted 8 lines
tools/testing/selftests/livepatch/test-livepatch.sh +0
-4@@ -108,96 +108,6 @@ livepatch: '$MOD_LIVEPATCH1': completing unpatching transition livepatch: '$MOD_LIVEPATCH1': unpatching complete % rmmod $MOD_LIVEPATCH1" - -# - load a livepatch that modifies the output from /proc/cmdline and -# verify correct behavior -# - load two additional livepatches and check the number of livepatch modules
tools/testing/selftests/livepatch/test-livepatch.sh livepatch: '$MOD_LIVEPATCH1': completing unpatching transition · line 124
Quoted 10 lines
tools/testing/selftests/livepatch/test-livepatch.sh +0
-10-# applied -# - load an atomic replace livepatch and check that the other three modules were -# disabled -# - remove all livepatches besides the atomic replace one and verify that the -# atomic replace livepatch is still active -# - remove the atomic replace livepatch and verify that none are active - -start_test "atomic replace livepatch" - -load_lp $MOD_LIVEPATCH1
[Severity: Medium]
Was this test case intentionally removed completely instead of being updated for the new replace_set semantics?
The commit message does not mention removing this test. This removal causes a loss of test coverage that previously verified an atomic replace successfully disables multiple existing livepatches.
Additionally, removing this test leaves the script variables MOD_LIVEPATCH2 and MOD_LIVEPATCH3 unused in test-livepatch.sh. Could this test be adapted to use replace_set instead?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v2 4/4] selftests/livepatch: Update tests for replace_set
Quoted 42 lines · On Fri, May 29, 2026 at 1:17 PM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The 'atomic replace livepatch' test case intest-livepatch.shwas completely removed instead of being updated, resulting in lost test coverage and leaving behind dead variables. --commit
99bb60c2ba8319ec21289c482f1ea304e282396c
Author: Yafang Shao <[email protected]>selftests/livepatch: Update tests for
replace_setThis commit updates the livepatch selftests to use "
replace_set" instead of "replace". It configures different livepatches to share or have differentreplace_setsto test atomic and non-atomic replace behaviors.Quoted 4 lines
tools/testing/selftests/livepatch/test-livepatch.sh +0
-0[ ... ]
Quoted 8 lines
tools/testing/selftests/livepatch/test-livepatch.sh +0
-4@@ -108,96 +108,6 @@ livepatch: '$MOD_LIVEPATCH1': completing unpatching transition livepatch: '$MOD_LIVEPATCH1': unpatching complete % rmmod $MOD_LIVEPATCH1" - -# - load a livepatch that modifies the output from /proc/cmdline and -# verify correct behavior -# - load two additional livepatches and check the number of livepatch modulestools/testing/selftests/livepatch/test-livepatch.sh livepatch: '$MOD_LIVEPATCH1': completing unpatching transition · line 124
Quoted 10 lines
tools/testing/selftests/livepatch/test-livepatch.sh +0
-10-# applied -# - load an atomic replace livepatch and check that the other three modules were -# disabled -# - remove all livepatches besides the atomic replace one and verify that the -# atomic replace livepatch is still active -# - remove the atomic replace livepatch and verify that none are active - -start_test "atomic replace livepatch" - -load_lp $MOD_LIVEPATCH1[Severity: Medium]
Was this test case intentionally removed completely instead of being updated for the newreplace_setsemantics?
Quoted 3 lines
The commit message does not mention removing this test. This removal causes a loss of test coverage that previously verified an atomic replace successfully disables multiple existing livepatches.
This test case is invalid for the replace_set, since only one livepatch will be replaced.
Quoted 4 lines
Additionally, removing this test leaves the script variables
MOD_LIVEPATCH2andMOD_LIVEPATCH3unused intest-livepatch.sh. Could this test be adapted to usereplace_setinstead?
I will update it.
Signature · 2 lines
Regards Yafang