mirror of
https://github.com/dynup/kpatch
synced 2024-12-29 08:42:02 +00:00
0bb5c106ef
Restructure kpatch's sysfs interface and mirror the sysfs tree after livepatch's sysfs layout. With the current sysfs layout, we cannot distinguish which object a function belongs to, and we cannot tell which modules/objects are patched. Therefore, restructure the kpatch sysfs tree such that module/object information is available. With the new layout, each patched object has its own directory, with each function being a subdirectory of its object. Implement this by embedding a kobject struct within the kpatch_module, kpatch_func, and kpatch_object structs and supplying their ktypes and kobject release methods. Before: /sys/kernel/kpatch └── patches └── <patch_module> ├── checksum ├── enabled └── functions ├── <function> # from <object1> │ ├── new_addr │ └── old_addr ├── <function> # from <object2> │ ├── new_addr │ └── old_addr └─── <function> # from <object3> ├── new_addr └── old_addr After: /sys/kernel/kpatch └── <patch_module> ├── <object1> │ └── <function,sympos> │ ├── new_addr │ └── old_addr ├── <object2> │ └── <function,sympos> │ ├── new_addr │ └── old_addr ├── checksum ├── enabled └── <object3> └── <function,sympos> ├── new_addr └── old_addr
28 lines
477 B
Bash
Executable File
28 lines
477 B
Bash
Executable File
#!/bin/bash
|
|
|
|
#set -x
|
|
|
|
rmmod testmod 2> /dev/null
|
|
rmmod kpatch 2> /dev/null
|
|
insmod testmod.ko || exit 1
|
|
insmod kpatch.ko || exit 1
|
|
if [[ "$(cat /sys/kernel/testmod/value)" != "2" ]]
|
|
then
|
|
exit 1
|
|
fi
|
|
insmod kpatch-patch.ko
|
|
dmesg | tail
|
|
if [[ "$(cat /sys/kernel/testmod/value)" != "3" ]]
|
|
then
|
|
exit 1
|
|
fi
|
|
echo 0 > /sys/kernel/kpatch/kpatch_patch/enabled
|
|
rmmod kpatch-patch
|
|
if [[ "$(cat /sys/kernel/testmod/value)" != "2" ]]
|
|
then
|
|
exit 1
|
|
fi
|
|
rmmod kpatch
|
|
rmmod testmod
|
|
echo "SUCCESS"
|