Add per klp_object sysfs entry "patched". It makes it easier to debug typos in the module name.
Unified · Split
| @@ -55,6 +55,14 @@ Description: · 54 unmodified lines | ||
| 55 | 55 | The object directory contains subdirectories for each function |
| 56 | 56 | that is patched within the object. |
| 57 | 57 | |
| 58 | +What: /sys/kernel/livepatch/<patch>/<object>/patched | |
| 59 | +Date: August 2022 | |
| 60 | +KernelVersion: 6.1.0 | |
| 61 | +Contact: live-patching@vger.kernel.org | |
| 62 | +Description: | |
| 63 | + An attribute which indicates whether the object is currently | |
| 64 | + patched. | |
| 65 | + | |
| 58 | 66 | What: /sys/kernel/livepatch/<patch>/<object>/<function,sympos> |
| 59 | 67 | Date: Nov 2014 |
| 60 | 68 | KernelVersion: 3.19.0 |
| @@ -325,6 +325,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs, · 324 unmodified lines | ||
| 325 | 325 | * /sys/kernel/livepatch/<patch>/transition |
| 326 | 326 | * /sys/kernel/livepatch/<patch>/force |
| 327 | 327 | * /sys/kernel/livepatch/<patch>/<object> |
| 328 | + * /sys/kernel/livepatch/<patch>/<object>/patched | |
| 328 | 329 | * /sys/kernel/livepatch/<patch>/<object>/<function,sympos> |
| 329 | 330 | */ |
| 330 | 331 | static int __klp_disable_patch(struct klp_patch *patch); |
| @@ -431,6 +432,22 @@ static struct attribute *klp_patch_attrs[] = { · 100 unmodified lines | ||
| 431 | 432 | }; |
| 432 | 433 | ATTRIBUTE_GROUPS(klp_patch); |
| 433 | 434 | |
| 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 | + | |
| 434 | 451 | static void klp_free_object_dynamic(struct klp_object *obj) |
| 435 | 452 | { |
| 436 | 453 | kfree(obj->name); |
| @@ -576,6 +593,7 @@ static void klp_kobj_release_object(struct kobject *kobj) · 139 unmodified lines | ||
| 576 | 593 | static struct kobj_type klp_ktype_object = { |
| 577 | 594 | .release = klp_kobj_release_object, |
| 578 | 595 | .sysfs_ops = &kobj_sysfs_ops, |
| 596 | + .default_groups = klp_object_groups, | |
| 579 | 597 | }; |
| 580 | 598 | |
| 581 | 599 | static void klp_kobj_release_func(struct kobject *kobj) |