summaryrefslogtreecommitdiffstats
path: root/kernel/livepatch
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.com>2022-10-05 13:00:03 +0200
committerPetr Mladek <pmladek@suse.com>2022-10-05 13:00:03 +0200
commit59b2a38c6afdc9341ac4fcff455bfdf77113ed37 (patch)
tree251697325d8c728343834929b0b56d2c1860c02d /kernel/livepatch
parentselftests/livepatch: normalize sysctl error message (diff)
parentselftests/livepatch: add sysfs test (diff)
downloadlinux-59b2a38c6afdc9341ac4fcff455bfdf77113ed37.tar.xz
linux-59b2a38c6afdc9341ac4fcff455bfdf77113ed37.zip
Merge branch 'for-6.1/sysfs-patched-object' into for-linus
Diffstat (limited to 'kernel/livepatch')
-rw-r--r--kernel/livepatch/core.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 42f7e716d56b..e1648f6a2daf 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -325,6 +325,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,
* /sys/kernel/livepatch/<patch>/transition
* /sys/kernel/livepatch/<patch>/force
* /sys/kernel/livepatch/<patch>/<object>
+ * /sys/kernel/livepatch/<patch>/<object>/patched
* /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
*/
static int __klp_disable_patch(struct klp_patch *patch);
@@ -431,6 +432,22 @@ static struct attribute *klp_patch_attrs[] = {
};
ATTRIBUTE_GROUPS(klp_patch);
+static ssize_t patched_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct klp_object *obj;
+
+ obj = container_of(kobj, struct klp_object, kobj);
+ return sysfs_emit(buf, "%d\n", obj->patched);
+}
+
+static struct kobj_attribute patched_kobj_attr = __ATTR_RO(patched);
+static struct attribute *klp_object_attrs[] = {
+ &patched_kobj_attr.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(klp_object);
+
static void klp_free_object_dynamic(struct klp_object *obj)
{
kfree(obj->name);
@@ -576,6 +593,7 @@ static void klp_kobj_release_object(struct kobject *kobj)
static struct kobj_type klp_ktype_object = {
.release = klp_kobj_release_object,
.sysfs_ops = &kobj_sysfs_ops,
+ .default_groups = klp_object_groups,
};
static void klp_kobj_release_func(struct kobject *kobj)