]> Git Repo - J-linux.git/commitdiff
Merge tag 'livepatching-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <[email protected]>
Mon, 10 Oct 2022 18:36:19 +0000 (11:36 -0700)
committerLinus Torvalds <[email protected]>
Mon, 10 Oct 2022 18:36:19 +0000 (11:36 -0700)
Pull livepatching updates from Petr Mladek:

 - Fix race between fork and livepatch transition revert

 - Add sysfs entry that shows "patched" state for each object (module)
   that can be livepatched by the given livepatch

 - Some clean up

* tag 'livepatching-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching:
  selftests/livepatch: add sysfs test
  livepatch: add sysfs entry "patched" for each klp_object
  selftests/livepatch: normalize sysctl error message
  livepatch: Add a missing newline character in klp_module_coming()
  livepatch: fix race between fork and KLP transition

1  2 
kernel/livepatch/core.c

diff --combined kernel/livepatch/core.c
index ec06ce59d7283b4696d607f9025b39e618c30ee3,e1648f6a2daf066ce7eec4526d7fcf3fcf211a33..9ada0bc5247be5de41c3c21476b1dd2cd9f20a9a
@@@ -213,7 -213,7 +213,7 @@@ static int klp_resolve_symbols(Elf_Shd
         * we use the smallest/strictest upper bound possible (56, based on
         * the current definition of MODULE_NAME_LEN) to prevent overflows.
         */
 -      BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 128);
 +      BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 512);
  
        relas = (Elf_Rela *) relasec->sh_addr;
        /* For each rela in this klp relocation section */
  
                /* Format: .klp.sym.sym_objname.sym_name,sympos */
                cnt = sscanf(strtab + sym->st_name,
 -                           ".klp.sym.%55[^.].%127[^,],%lu",
 +                           ".klp.sym.%55[^.].%511[^,],%lu",
                             sym_objname, sym_name, &sympos);
                if (cnt != 3) {
                        pr_err("symbol %s has an incorrectly formatted name\n",
@@@ -325,6 -325,7 +325,7 @@@ int klp_apply_section_relocs(struct mod
   * /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 +432,22 @@@ static struct attribute *klp_patch_attr
  };
  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 +593,7 @@@ static void klp_kobj_release_object(str
  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)
@@@ -1171,7 -1189,7 +1189,7 @@@ int klp_module_coming(struct module *mo
                return -EINVAL;
  
        if (!strcmp(mod->name, "vmlinux")) {
-               pr_err("vmlinux.ko: invalid module name");
+               pr_err("vmlinux.ko: invalid module name\n");
                return -EINVAL;
        }
  
This page took 0.062018 seconds and 4 git commands to generate.