kprobes不在Ubuntu工作

时间:2014-04-21 11:14:57

标签: ubuntu ubuntu-13.10 systemtap

我正在尝试运行Systemtap中的一个标准示例脚本。 procmod_watcher.stp使用kprobes来监视fork,exec等。 但是当我尝试运行此脚本时,我收到一个错误。

semantic error: while resolving probe point: identifier 'kprobe' at /usr/share/systemtap/tapset/linux/nd_syscalls.stp:967:27
    source: probe nd_syscall.execve = kprobe.function("do_execve")

果然:stap -L 'kprobe.function("do_execve")'什么也没有回复。 怎么会这样?

我使用Ubuntu已按照以下说明操作: Systemtap on Ubuntu @sourceware

我还尝试编译自己的内核并确保通过配置启用Kprobes,debug_info和所有其他必需项。 我得到了同样的错误。

我在fedora上尝试了相同的脚本,它实际上是开箱即用的。但我只有一个带有fedora的虚拟机,并希望继续使用ubuntu一段时间。

在ubuntu上的systemtap中启用kprobes需要做什么?

2 个答案:

答案 0 :(得分:1)

kprobe.function探针依赖于systemtap读取System.map文件以获取函数列表。运行

stap -vv -L 'kprobe.function("do_execve")'

查看stap正在寻找该文件的位置;它可能在抱怨“内核符号表......不可用”。安排在那里放一个System.map符号链接,而stap应该找到它,并在其中找到do_execve函数。我们可以扩展stap的搜索路径以在其原始位置找到该文件;指针欢迎。或者,如果问题是权限,

sudo chmod a+r /boot/System.map*

这是为了解决https://wiki.ubuntu.com/Security/Features中被误导的部分 - 另见https://sourceware.org/bugzilla/show_bug.cgi?id=15172

答案 1 :(得分:0)

添加到@fche回答,SystemTap正在/lib/modules/$(uname -r)/build/System.map中寻找System.map。

在Ubuntu中,system.map放在/boot/System.map-$(uname -r)中 这样:

  1. 你需要运行stap作为sudo(因为只有root可以访问/ boot或做一些魔术组)
  2. 创建指向System.map的软链接:sudo ln -s /boot/System.map-$(uname -r) /lib/modules/$(uname -r)/build/System.map
  3. 我不建议在位置,安全性和所有文件中更改文件的读取标志...