]> Git Repo - linux.git/commitdiff
Merge branch 'for-6.1/sysfs-patched-object' into for-linus
authorPetr Mladek <[email protected]>
Wed, 5 Oct 2022 11:00:03 +0000 (13:00 +0200)
committerPetr Mladek <[email protected]>
Wed, 5 Oct 2022 11:00:03 +0000 (13:00 +0200)
1  2 
kernel/livepatch/core.c
tools/testing/selftests/livepatch/functions.sh

diff --combined kernel/livepatch/core.c
index 42f7e716d56bf72812a95ec89ae1368f78bc7188,67eb9f9168f34b0a72ee32ff4e2a4c79013d89b8..e1648f6a2daf066ce7eec4526d7fcf3fcf211a33
@@@ -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;
        }
  
index d5001c9eb72eb57a5cd5d45b5efd89e08a3978b5,433e23dd9dcb8c29d8017068129a0ae51b7d3be0..c8416c54b4637b1380810f0c9f71bc99e1710b8e
@@@ -6,6 -6,7 +6,7 @@@
  
  MAX_RETRIES=600
  RETRY_INTERVAL=".1"   # seconds
+ KLP_SYSFS_DIR="/sys/kernel/livepatch"
  
  # Kselftest framework requirement - SKIP code is 4
  ksft_skip=4
@@@ -86,7 -87,7 +87,7 @@@ function set_ftrace_enabled() 
  
        if [[ "$result" != "$1" ]] ; then
                if [[ $can_fail -eq 1 ]] ; then
 -                      echo "livepatch: $err" > /dev/kmsg
 +                      echo "livepatch: $err" | sed 's#/proc/sys/kernel/#kernel.#' > /dev/kmsg
                        return
                fi
  
@@@ -308,3 -309,36 +309,36 @@@ function check_result 
  
        cleanup_dmesg_file
  }
+ # check_sysfs_rights(modname, rel_path, expected_rights) - check sysfs
+ # path permissions
+ #     modname - livepatch module creating the sysfs interface
+ #     rel_path - relative path of the sysfs interface
+ #     expected_rights - expected access rights
+ function check_sysfs_rights() {
+       local mod="$1"; shift
+       local rel_path="$1"; shift
+       local expected_rights="$1"; shift
+       local path="$KLP_SYSFS_DIR/$mod/$rel_path"
+       local rights=$(/bin/stat --format '%A' "$path")
+       if test "$rights" != "$expected_rights" ; then
+               die "Unexpected access rights of $path: $expected_rights vs. $rights"
+       fi
+ }
+ # check_sysfs_value(modname, rel_path, expected_value) - check sysfs value
+ #     modname - livepatch module creating the sysfs interface
+ #     rel_path - relative path of the sysfs interface
+ #     expected_value - expected value read from the file
+ function check_sysfs_value() {
+       local mod="$1"; shift
+       local rel_path="$1"; shift
+       local expected_value="$1"; shift
+       local path="$KLP_SYSFS_DIR/$mod/$rel_path"
+       local value=`cat $path`
+       if test "$value" != "$expected_value" ; then
+               die "Unexpected value in $path: $expected_value vs. $value"
+       fi
+ }
This page took 0.067411 seconds and 4 git commands to generate.