History

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.

Song Liu committed 4 years ago

Commit bb26cfd1 parent 033a9442 files · +26 −0Browse files

Unified · Split

2 files
  1. Documentation/ABI/testing/sysfs-kernel-livepatch +8 −0
  2. kernel/livepatch/core.c +18 −0
Documentation/ABI/testing/sysfs-kernel-livepatch+8−0
@@ -55,6 +55,14 @@ Description: · 54 unmodified lines
55 The object directory contains subdirectories for each function55 The object directory contains subdirectories for each function
56 that is patched within the object.56 that is patched within the object.
57 57
58What: /sys/kernel/livepatch/<patch>/<object>/patched
59Date: August 2022
60KernelVersion: 6.1.0
61Contact: live-patching@vger.kernel.org
62Description:
63 An attribute which indicates whether the object is currently
64 patched.
65
58What: /sys/kernel/livepatch/<patch>/<object>/<function,sympos>66What: /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
59Date: Nov 201467Date: Nov 2014
60KernelVersion: 3.19.068KernelVersion: 3.19.0
kernel/livepatch/core.c+18−0
@@ -325,6 +325,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs, · 324 unmodified lines
325 * /sys/kernel/livepatch/<patch>/transition325 * /sys/kernel/livepatch/<patch>/transition
326 * /sys/kernel/livepatch/<patch>/force326 * /sys/kernel/livepatch/<patch>/force
327 * /sys/kernel/livepatch/<patch>/<object>327 * /sys/kernel/livepatch/<patch>/<object>
328 * /sys/kernel/livepatch/<patch>/<object>/patched
328 * /sys/kernel/livepatch/<patch>/<object>/<function,sympos>329 * /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
329 */330 */
330static int __klp_disable_patch(struct klp_patch *patch);331static int __klp_disable_patch(struct klp_patch *patch);
@@ -431,6 +432,22 @@ static struct attribute *klp_patch_attrs[] = { · 100 unmodified lines
431};432};
432ATTRIBUTE_GROUPS(klp_patch);433ATTRIBUTE_GROUPS(klp_patch);
433 434
435static 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
444static struct kobj_attribute patched_kobj_attr = __ATTR_RO(patched);
445static struct attribute *klp_object_attrs[] = {
446 &patched_kobj_attr.attr,
447 NULL,
448};
449ATTRIBUTE_GROUPS(klp_object);
450
434static void klp_free_object_dynamic(struct klp_object *obj)451static void klp_free_object_dynamic(struct klp_object *obj)
435{452{
436 kfree(obj->name);453 kfree(obj->name);
@@ -576,6 +593,7 @@ static void klp_kobj_release_object(struct kobject *kobj) · 139 unmodified lines
576static struct kobj_type klp_ktype_object = {593static struct kobj_type klp_ktype_object = {
577 .release = klp_kobj_release_object,594 .release = klp_kobj_release_object,
578 .sysfs_ops = &kobj_sysfs_ops,595 .sysfs_ops = &kobj_sysfs_ops,
596 .default_groups = klp_object_groups,
579};597};
580 598
581static void klp_kobj_release_func(struct kobject *kobj)599static void klp_kobj_release_func(struct kobject *kobj)