我如何运行valgrind到一个超级用户位的进程?

ani*_*ish 10 linux memory valgrind setuid

我按如下方式运行valgrind: -

/ usr/local/bin/valgrind"process_name"

在执行之后它给我跟随错误

==21731==
==21731== Warning: Can't execute setuid/setgid executable: 
==21731== Possible workaround: remove --trace-children=yes, if in effect
==21731==
valgrind: "process name": Permission denied
Run Code Online (Sandbox Code Playgroud)

我的valgrind权限如下: - -r-sr-xr-x/usr/local/bin/valgrind

我的进程权限如下: - -r-sr-xr-x"process_name"

平台:Linux VMLINUX3 2.6.9-78.0.22.ELsmp(RHEL)

Valgrind版本:valgrind-3.5.0

任何有关这方面的帮助将不胜感激

小智 4

对于开发 FUSE 文件系统的人来说,这是一个永恒的问题。此链接可能会有所帮助(实际上太多了,无法合并到一个答案中)。解决方法包括及时更换 fusionmount,以及(视情况而定)valgrind 的一些附加选项以防止其追踪儿童。

事实上,如果你在 valgrind 下运行我的 FS,你会得到以下输出(是的,有足够多的人遇到这个问题,我实际上在启动时检测到了 valgrind 并显示了链接):

root@tower:~ # valgrind xsfs /xs
==9479== Memcheck, a memory error detector.
==9479== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
==9479== Using LibVEX rev 1884, a library for dynamic binary translation.
==9479== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
==9479== Using valgrind-3.4.1, a dynamic binary instrumentation framework.
==9479== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
==9479== For more details, rerun with: -v
==9479==
******** Valgrind has been detected by xsfs
******** If you have difficulties getting xsfs to work under Valgrind,
******** see the following thread:
******** http://www.nabble.com/valgrind-and-fuse-file-systems-td13112112.html
******** Sleeping for 5 seconds so this doesn't fly by ....
Run Code Online (Sandbox Code Playgroud)

简单的事情就是在以 root 身份运行的一次性虚拟机中进行所有调试,您可以在其中放弃 setuid 位,然后就可以完成它。确保测试代码没有任何泄漏或违规,测试任何不使用熔丝的链接库代码很容易。将您的构建交给“valgrind-clean”,并注意您已在文档中这样做了。

然后,抓取一些位来valgrind/valgrind.h检测它,并向那些继续运行它的人显示一条简短消息。解决这个问题的黑客需要根合作,坦率地说,在沙箱中也更容易完成。

拒绝在 setuid 位打开的情况下拒绝在 valgrind 下运行也很容易,如果人们确实想要这样做,则会显示一条有用的消息来将其关闭。