diff --git a/agent/src/ebpf/kernel/include/task_struct_utils.h b/agent/src/ebpf/kernel/include/task_struct_utils.h index 82721c366c3..a411edb29c4 100644 --- a/agent/src/ebpf/kernel/include/task_struct_utils.h +++ b/agent/src/ebpf/kernel/include/task_struct_utils.h @@ -127,10 +127,9 @@ static __inline void *infer_and_get_socket_from_fd(int fd_num, // TAG: STRUCT_TASK_FILES_OFFSET // 成员 files 在 struct task_struct 中的偏移量 - // 0xd08 for kernel-devel-4.19.91-26.6.al7 +#ifdef LINUX_VER_5_2_PLUS // 0xa48 for 5.10.0-60.18.0.50.h322_1.hce2.aarch64 // 0xc60 for 5.10.0-106.18.0.68.oe2209.x86_64 -#ifdef LINUX_VER_5_2_PLUS int files_offset_array[] = { 0x790, 0xa80, 0xa88, 0xa90, 0xa98, 0xaa0, 0xaa8, 0xab0, 0xab8, 0xac0, 0xac8, 0xad0, 0xad8, 0xae0, 0xae8, 0xaf0, 0xaf8, 0xb00, 0xb08, 0xb10, @@ -140,12 +139,14 @@ static __inline void *infer_and_get_socket_from_fd(int fd_num, 0xcc8, 0xa48, 0xc60 }; #else + // 0xd08 for kernel-devel-4.19.91-26.6.al7 // 0x740 for 4.19.113-300.el7.x86_64 + // 0x6c0 for 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) int files_offset_array[] = { - 0x790, 0xa80, 0xa88, 0xa90, 0xa98, 0xaa0, 0xaa8, 0xab0, 0xab8, 0xac0, - 0xac8, 0xad0, 0xad8, 0xae0, 0xae8, 0xaf0, 0xaf8, 0xb00, 0xb08, 0xb10, - 0xb18, 0xb20, 0xb28, 0xb48, 0xb50, 0xb58, 0xb60, 0xb68, 0xb70, 0xb78, - 0xb80, 0xb88, 0xb90, 0xb98, 0xba0, 0x740, 0xbb8, 0xbc0, 0xbc8, 0xbd0, + 0x6c0, 0x790, 0xa80, 0xa88, 0xa90, 0xa98, 0xaa0, 0xaa8, 0xab0, 0xab8, + 0xac0, 0xac8, 0xad0, 0xad8, 0xae0, 0xae8, 0xaf0, 0xaf8, 0xb00, 0xb08, + 0xb10, 0xb18, 0xb20, 0xb28, 0xb48, 0xb50, 0xb58, 0xb60, 0xb68, 0xb70, + 0xb78, 0xb88, 0xb90, 0xb98, 0xba0, 0x740, 0xbb8, 0xbc0, 0xbc8, 0xbd0, 0xbd8, 0xbe0, 0xbe8, 0xbf0, 0xbf8, 0xc00, 0xc08, 0xc10, 0xcc8, 0xd08, }; #endif diff --git a/agent/src/ebpf/user/common.c b/agent/src/ebpf/user/common.c index ee7fbe266aa..678740bbf2a 100644 --- a/agent/src/ebpf/user/common.c +++ b/agent/src/ebpf/user/common.c @@ -523,6 +523,15 @@ int fetch_kernel_version(int *major, int *minor, int *patch) if (sscanf(sys_info.release, "%u.%u.%u", major, minor, patch) != 3) return ETR_INVAL; + // Get the real version of Debian + //#1 SMP Debian 4.19.289-2 (2023-08-08) + if (strstr(sys_info.version, "Debian")) { + int num; + if (sscanf(sys_info.version, "%*s %*s %*s %u.%u.%u-%u %*s", + major, minor, patch, &num) != 4) + return ETR_INVAL; + } + return ETR_OK; }