From 712d0f3342d2df43e4d441799824a487fcd85245 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Sat, 12 Apr 2025 16:29:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0super=5Faccess.c=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=8D=E5=90=8C=E5=86=85=E6=A0=B8=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E7=BB=93=E6=9E=84=E4=BD=93=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/kpm/super_access.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/kernel/kpm/super_access.c b/kernel/kpm/super_access.c index 166c3388..8f2791ca 100644 --- a/kernel/kpm/super_access.c +++ b/kernel/kpm/super_access.c @@ -26,7 +26,8 @@ #include #include "kpm.h" #include "compact.h" -#include // 需要包含 offsetof 宏 +#include +#include // 结构体成员元数据 struct DynamicStructMember { @@ -65,7 +66,21 @@ struct DynamicStructInfo { // ================================================================================== -#include +#include + + +#define KERNEL_VERSION_6_6 KERNEL_VERSION(6, 6, 0) + +#define KERNEL_VERSION_6_1 KERNEL_VERSION(6, 1, 0) + +#define KERNEL_VERSION_5_15 KERNEL_VERSION(5, 15, 0) + +#define KERNEL_VERSION_5_10 KERNEL_VERSION(5, 10, 0) + +#define KERNEL_VERSION_4_14 KERNEL_VERSION(4, 14, 0) + + +#include <../fs/mount.h> #include // 定义元数据 @@ -86,28 +101,32 @@ DYNAMIC_STRUCT_BEGIN(vfsmount) DYNAMIC_STRUCT_END(vfsmount) DYNAMIC_STRUCT_BEGIN(mnt_namespace) - DEFINE_MEMBER(mnt_namespace, count) DEFINE_MEMBER(mnt_namespace, ns) DEFINE_MEMBER(mnt_namespace, root) DEFINE_MEMBER(mnt_namespace, seq) DEFINE_MEMBER(mnt_namespace, mounts) +#if LINUX_VERSION_CODE < KERNEL_VERSION_5_15 + DEFINE_MEMBER(mnt_namespace, count) +#endif DYNAMIC_STRUCT_END(mnt_namespace) #include #ifdef CONFIG_KPROBES - DYNAMIC_STRUCT_BEGIN(kprobe) DEFINE_MEMBER(kprobe, addr) DEFINE_MEMBER(kprobe, symbol_name) DEFINE_MEMBER(kprobe, offset) DEFINE_MEMBER(kprobe, pre_handler) DEFINE_MEMBER(kprobe, post_handler) +#if LINUX_VERSION_CODE < KERNEL_VERSION_5_15 DEFINE_MEMBER(kprobe, fault_handler) +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION_5_10 DEFINE_MEMBER(kprobe, break_handler) +#endif DEFINE_MEMBER(kprobe, flags) DYNAMIC_STRUCT_END(kprobe) - #endif #include @@ -143,7 +162,9 @@ DYNAMIC_STRUCT_BEGIN(netlink_kernel_cfg) DEFINE_MEMBER(netlink_kernel_cfg, cb_mutex) DEFINE_MEMBER(netlink_kernel_cfg, bind) DEFINE_MEMBER(netlink_kernel_cfg, unbind) +#if LINUX_VERSION_CODE < KERNEL_VERSION_6_1 DEFINE_MEMBER(netlink_kernel_cfg, compare) +#endif DYNAMIC_STRUCT_END(netlink_kernel_cfg) // ===================================================================================================================== @@ -156,7 +177,7 @@ struct DynamicStructInfo* dynamic_struct_infos[] = { STRUCT_INFO(vfsmount), STRUCT_INFO(mnt_namespace), #ifdef CONFIG_KPROBES - STRUCT_INFO(kprobe) + STRUCT_INFO(kprobe), #endif STRUCT_INFO(vm_area_struct), STRUCT_INFO(vm_operations_struct),