Skip to content

Commit adb68ed

Browse files
laoarpmladek
authored andcommitted
livepatch: Add "replace" sysfs attribute
There are situations when it might make sense to combine livepatches with and without the atomic replace on the same system. For example, the livepatch without the atomic replace might provide a hotfix or extra tuning. Managing livepatches on such systems might be challenging. And the information which of the installed livepatches do not use the atomic replace would be useful. Add new sysfs interface 'replace'. It works as follows: $ cat /sys/kernel/livepatch/livepatch-non_replace/replace 0 $ cat /sys/kernel/livepatch/livepatch-replace/replace 1 [ commit log improved by Petr ] Signed-off-by: Yafang Shao <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Acked-by: Miroslav Benes <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Petr Mladek <[email protected]>
1 parent 8c06da6 commit adb68ed

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Documentation/ABI/testing/sysfs-kernel-livepatch

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ Description:
4747
disabled when the feature is used. See
4848
Documentation/livepatch/livepatch.rst for more information.
4949

50+
What: /sys/kernel/livepatch/<patch>/replace
51+
Date: Jun 2024
52+
KernelVersion: 6.11.0
53+
54+
Description:
55+
An attribute which indicates whether the patch supports
56+
atomic-replace.
57+
5058
What: /sys/kernel/livepatch/<patch>/<object>
5159
Date: Nov 2014
5260
KernelVersion: 3.19.0

kernel/livepatch/core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,
346346
* /sys/kernel/livepatch/<patch>/enabled
347347
* /sys/kernel/livepatch/<patch>/transition
348348
* /sys/kernel/livepatch/<patch>/force
349+
* /sys/kernel/livepatch/<patch>/replace
349350
* /sys/kernel/livepatch/<patch>/<object>
350351
* /sys/kernel/livepatch/<patch>/<object>/patched
351352
* /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
@@ -443,13 +444,24 @@ static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr,
443444
return count;
444445
}
445446

447+
static ssize_t replace_show(struct kobject *kobj,
448+
struct kobj_attribute *attr, char *buf)
449+
{
450+
struct klp_patch *patch;
451+
452+
patch = container_of(kobj, struct klp_patch, kobj);
453+
return sysfs_emit(buf, "%d\n", patch->replace);
454+
}
455+
446456
static struct kobj_attribute enabled_kobj_attr = __ATTR_RW(enabled);
447457
static struct kobj_attribute transition_kobj_attr = __ATTR_RO(transition);
448458
static struct kobj_attribute force_kobj_attr = __ATTR_WO(force);
459+
static struct kobj_attribute replace_kobj_attr = __ATTR_RO(replace);
449460
static struct attribute *klp_patch_attrs[] = {
450461
&enabled_kobj_attr.attr,
451462
&transition_kobj_attr.attr,
452463
&force_kobj_attr.attr,
464+
&replace_kobj_attr.attr,
453465
NULL
454466
};
455467
ATTRIBUTE_GROUPS(klp_patch);

0 commit comments

Comments
 (0)