12

我正在运行 valgrind,如下所示:-

/usr/local/bin/valgrind“进程名”

执行后它给我以下错误

==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

我的 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

5 回答 5

4

我想最简单的答案是在调试时删除 setuid/setgid 位。当然,如果程序真的需要 root 权限,您可能必须以 root 身份运行 valgrind,或者由于 valgrind 本身似乎是 setuid,只需将其更改为 root:root。如果您在此之后执行 valgrind ,它将拥有 root 权限(它的子进程也将拥有 - 已调试进程)。

然后,您应该能够在该应用程序上运行 valgrind。

请小心,因为您将在系统中引入一个大的安全漏洞。更安全的解决方案是仅为应该能够运行(setuid)valgrind 并从那里开始的用户创建特殊组......

于 2009-11-09T15:41:45.883 回答
4

对于开发 FUSE 文件系统的人来说,这是一个永恒的问题。这个链接可能会有所帮助(在一个答案中整合起来实在是太多了)。解决方法包括及时更换 fusermount,以及(取决于)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 ....

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

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

在 setuid 位打开的情况下拒绝在 valgrind 下运行也很容易,如果他们真的想这样做,会显示一个有用的信息,让人们将其关闭。

于 2009-11-09T15:48:46.437 回答
1

我假设您尝试使用 --trace-children=no 运行它?如果您有 root 访问权限,这里似乎有一个解决方法。

于 2009-11-09T15:40:33.297 回答
-1

以 root(或任何 set-uid 用户)身份运行 valgrind 命令,那么程序将不必使用设置 uid。

于 2009-11-09T15:37:39.173 回答
-1

即使以root用户身份运行也会发生这种情况:)最好的方法是更改​​权限以删除“s”,然后运行

于 2014-06-06T11:40:44.667 回答