[英]Why can't the address of sys_call_table be derived using that of system_wq in System.map?
After trying the suggested solution for deriving the KASLR offset shift on a previous question on this topic, i realized that the run time address of system_wq
is different from that in /boot/System.map-$(uname -r)
whether or not KASLR is enabled (although it does remain the same across different KASLR-disabled boots, which obviously doesn't happen on the opposite case).试图推导的KASLR偏移移位建议的解决方案后, 以前的问题,关于这个主题,我认识到,运行时间地址system_wq
不同于在/boot/System.map-$(uname -r)
是否KASLR已启用(尽管它在不同的禁用 KASLR 的靴子中确实保持不变,这显然不会发生在相反的情况下)。
The following snippet should calculate the sys_call_table
address using the run time address of system_wq
and the System.map addresses of both system_wq
and sys_call_table
(assume sysmap_*
to contain the corresponding System.map addresses).下面的代码段应计算sys_call_table
使用的运行时间地址地址system_wq
以及两者的System.map地址system_wq
和sys_call_table
(假设sysmap_*
以包含对应System.map地址)。 dmesg
outputs are below the snippet. dmesg
输出位于代码段下方。
runtime_sys_call_table = (unsigned long *)
((unsigned long)system_wq - (sysmap_system_wq - sysmap_sys_call_table));
printk("System.map system_wq: 0x%lx\n", sysmap_system_wq);
printk("System.map sys_call_table: 0x%lx\n", sysmap_sys_call_table);
printk("Run time system_wq: 0x%lx\n", (unsigned long)system_wq);
printk("Expected run time sys_call_table: 0x%lx\n", (unsigned long)runtime_sys_call_table);
Boot 1 :引导 1 :
[ 126.922753] [lkm] lkm_init: System.map system_wq: 0xffffffff821204b8
[ 127.230661] [lkm] lkm_init: System.map sys_call_table: 0xffffffff81c002a0
[ 127.230662] [lkm] lkm_init: Run time system_wq: 0xffff91fcbe40ae00
[ 127.230662] [lkm] lkm_init: Expected run time sys_call_table: 0xffff91fcbdeeabe8
Boot 2 :引导 2 :
[ 140.689652] [lkm] lkm_init: System.map system_wq: 0xffffffff821204b8
[ 140.993379] [lkm] lkm_init: System.map sys_call_table: 0xffffffff81c002a0
[ 140.993381] [lkm] lkm_init: Run time system_wq: 0xffff9a69be40ae00
[ 140.993382] [lkm] lkm_init: Expected run time sys_call_table: 0xffff9a69bdeeabe8
Boot 1 :引导 1 :
[ 143.699539] [lkm] lkm_init: System.map system_wq: 0xffffffff821204b8
[ 144.002094] [lkm] lkm_init: System.map sys_call_table: 0xffffffff81c002a0
[ 144.002095] [lkm] lkm_init: Run time system_wq: 0xffff88803e40ae00
[ 144.002096] [lkm] lkm_init: Expected run time sys_call_table: 0xffff88803deeabe8
Boot 2 :引导 2 :
[ 133.828917] [lkm] lkm_init: System.map system_wq: 0xffffffff821204b8
[ 134.132394] [lkm] lkm_init: System.map sys_call_table: 0xffffffff81c002a0
[ 134.132395] [lkm] lkm_init: Run time system_wq: 0xffff88803e40ae00
[ 134.132395] [lkm] lkm_init: Expected run time sys_call_table: 0xffff88803deeabe8
1 . 1 . Why does the run time address of sys_call_table
match that of System.map (which i know because system calls were successfully hooked) when KASLR is disabled while that of system_wq
does not?为什么运行时间地址sys_call_table
,而当KASLR被禁用匹配System.map(我知道,因为系统调用是成功上钩)的system_wq
不?
2 . 2 . Why does the snippet fail to calculate the run time address of sys_call_table
whether or not KASLR is enabled?为什么无论是否启用 KASLR,代码段都无法计算sys_call_table
的运行时地址?
3 . 3 . If it is the case that the run time address of system_wq
will differ from that of System.map anyway, then what other exported symbols can be used to derive sys_call_table
?如果system_wq
的运行时地址无论如何都会与 System.map 的运行时地址不同,那么还有哪些其他导出符号可以用于派生sys_call_table
?
Ian Abbott's comment solved my problem and made all questions obsolete. Ian Abbott 的评论解决了我的问题并使所有问题都过时了。 For clarification, my confusion was the fact that system_wq
is a simple pointer to struct workqueue_struct
, which made me think it already contained the address i wanted;为了澄清起见,我的困惑是system_wq
是一个简单的指向struct workqueue_struct
指针,这让我认为它已经包含了我想要的地址; I then thought I only had to cast it as I did with sys_call_table
, which is actually an array of pointers, making (unsigned long)sys_call_table
a correct address for sys_call_table
whereas (unsigned long)&system_wq
would be for system_wq
.那么我想我只需要投它,因为我做了与sys_call_table
,这实际上是一个指针数组,使得(unsigned long)sys_call_table
正确地址sys_call_table
,而(unsigned long)&system_wq
将是system_wq
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.