Skip to content

Commit bb26cfd

Browse files
liu-song-6pmladek
authored andcommitted
livepatch: add sysfs entry "patched" for each klp_object
Add per klp_object sysfs entry "patched". It makes it easier to debug typos in the module name. Signed-off-by: Song Liu <[email protected]> Reviewed-by: Joe Lawrence <[email protected]> [[email protected]: Updated kernel version when the sysfs file will be introduced] Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 033a944 commit bb26cfd

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Documentation/ABI/testing/sysfs-kernel-livepatch

+8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ Description:
5555
The object directory contains subdirectories for each function
5656
that is patched within the object.
5757

58+
What: /sys/kernel/livepatch/<patch>/<object>/patched
59+
Date: August 2022
60+
KernelVersion: 6.1.0
61+
62+
Description:
63+
An attribute which indicates whether the object is currently
64+
patched.
65+
5866
What: /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
5967
Date: Nov 2014
6068
KernelVersion: 3.19.0

kernel/livepatch/core.c

+18
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,
325325
* /sys/kernel/livepatch/<patch>/transition
326326
* /sys/kernel/livepatch/<patch>/force
327327
* /sys/kernel/livepatch/<patch>/<object>
328+
* /sys/kernel/livepatch/<patch>/<object>/patched
328329
* /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
329330
*/
330331
static int __klp_disable_patch(struct klp_patch *patch);
@@ -431,6 +432,22 @@ static struct attribute *klp_patch_attrs[] = {
431432
};
432433
ATTRIBUTE_GROUPS(klp_patch);
433434

435+
static ssize_t patched_show(struct kobject *kobj,
436+
struct kobj_attribute *attr, char *buf)
437+
{
438+
struct klp_object *obj;
439+
440+
obj = container_of(kobj, struct klp_object, kobj);
441+
return sysfs_emit(buf, "%d\n", obj->patched);
442+
}
443+
444+
static struct kobj_attribute patched_kobj_attr = __ATTR_RO(patched);
445+
static struct attribute *klp_object_attrs[] = {
446+
&patched_kobj_attr.attr,
447+
NULL,
448+
};
449+
ATTRIBUTE_GROUPS(klp_object);
450+
434451
static void klp_free_object_dynamic(struct klp_object *obj)
435452
{
436453
kfree(obj->name);
@@ -576,6 +593,7 @@ static void klp_kobj_release_object(struct kobject *kobj)
576593
static struct kobj_type klp_ktype_object = {
577594
.release = klp_kobj_release_object,
578595
.sysfs_ops = &kobj_sysfs_ops,
596+
.default_groups = klp_object_groups,
579597
};
580598

581599
static void klp_kobj_release_func(struct kobject *kobj)

0 commit comments

Comments
 (0)