我尝试为正在运行的 Tomcat 进程安装 seccomp BPF 过滤器。将 gdb 附加到该进程后,我调用 dlopen 函数来加载共享库(.so 文件),该函数返回了一个 han...
我尝试为正在运行的 Tomcat 进程安装 seccomp BPF 过滤器。附加 gdb
到该进程后,我调用该 dlopen
函数加载共享库(.so 文件),该函数返回一个句柄。句柄是一个整数,而不是零。但是,当我使用该 gdb x
命令检查句柄的内存内容时,gdb 提示符显示错误: Cannot access memory at address
。随后,我尝试使用句柄作为参数进行调用 dlsym
,然后 gdb 因发生信号而终止。以下 SIGSEGV
是图示:
(gdb) set $handle=dlopen("/opt/seccompfilter.so",1)
(gdb) x $handle
0xffffffffaaef8730: Cannot access memory at address 0xffffffffaaef8730
(gdb) call dlsym((void *)$handle, "install_filter")
[Thread 0x7f6250aed700 (LWP 2069) exited]
Program received signal SIGSEGV, Segmentation fault.
_dl_lookup_symbol_x (undef_name=0x5636aaef81d0 "install_filter",
undef_map=0xffffffffaaef8730, ref=0x7ffe774956a0,
symbol_scope=0xffffffffaaef8ab8, version=0x0, type_class=0,
flags=2, skip_map=0x0) at dl-lookup.c:733
733 while ((*scope)->r_list[i] != skip_map)
The program being debugged was signaled while in a function called
from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(__dlsym) will be abandoned.
When the function is done executing, GDB will silently stop.
我正在尝试了解哪里出了问题。这是我的工作环境:
CentOS 7 kernel-3.10.0-1160.90.1.el7.x86_64
gdb 7.6.1-120.el7
glibc 2.17
上执行相同步骤时 Ubuntu 20.04 ,一切都成功了。问题是什么?
我尝试调用 dlopen 函数来加载 libc.so.6
共享库,但得到了相同的结果。