diff options
author | Yafang Shao <laoar.shao@gmail.com> | 2024-06-25 23:11:21 +0800 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2024-07-02 16:56:18 +0200 |
commit | adb68ed26a3e92224e04502c768f1bb03b7c7aeb (patch) | |
tree | 599f6186e93c0c3af455a458470109d8e902daeb /kernel | |
parent | 8c06da67d0bd3139a97f301b4aa9c482b9d4f29e (diff) | |
download | linux-stable-adb68ed26a3e92224e04502c768f1bb03b7c7aeb.tar.gz linux-stable-adb68ed26a3e92224e04502c768f1bb03b7c7aeb.tar.bz2 linux-stable-adb68ed26a3e92224e04502c768f1bb03b7c7aeb.zip |
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 <laoar.shao@gmail.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lore.kernel.org/r/20240625151123.2750-2-laoar.shao@gmail.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/livepatch/core.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 52426665eecc..ad28617bfd75 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -346,6 +346,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>/<object> * /sys/kernel/livepatch/<patch>/<object>/patched * /sys/kernel/livepatch/<patch>/<object>/<function,sympos> @@ -443,13 +444,24 @@ static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr, return count; } +static ssize_t replace_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); +} + 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 attribute *klp_patch_attrs[] = { &enabled_kobj_attr.attr, &transition_kobj_attr.attr, &force_kobj_attr.attr, + &replace_kobj_attr.attr, NULL }; ATTRIBUTE_GROUPS(klp_patch); |