【问题标题】:how do i run valgrind to a process which has super user bit on?如何将 valgrind 运行到具有超级用户位的进程?
【发布时间】:2009-11-09 15:29:03
【问题描述】:

我运行 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 "进程名"

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

Valgrind 版本:valgrind-3.5.0

对此的任何帮助将不胜感激

【问题讨论】:

    标签: linux memory valgrind setuid


    【解决方案1】:

    对于开发 FUSE 文件系统的人来说,这是一个永恒的问题。 This link may help(在一个答案中整合起来实在是太多了)。解决方法包括及时更换 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 位并完成它。确保您测试您的代码没有任何泄漏或违规,它很容易测试任何不使用保险丝的链接库代码。将你的构建交给“valgrind-clean”,并注意你已经在文档中这样做了。

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

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

    【讨论】:

      【解决方案2】:

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

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

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

      【讨论】:

      • 要是在所有情况下都这么简单就好了。 FUSE 依赖于一个 setuid 助手,它不能被 underpriv 用户取消设置以进行调试,因此在 FUSE 文件系统中检测内存泄漏非常困难。但是,对于手头的主题来说,这是一个很好的答案,很抱歉离题了,这是我每天的挫败感之一:)
      • 没错,因为(几乎)总是有例外,但通常这种方法应该可以解决问题。
      • 仅以 root 身份运行 valgrind 似乎还不够,但 chown 有效! :)
      【解决方案3】:

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

      【讨论】:

      【解决方案4】:

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

      【讨论】:

      • 有时候,这是不可能的:)
      【解决方案5】:

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

      【讨论】:

      • suid 不代表root。这意味着设置用户ID,其中“用户”可以是任何东西。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-21
      • 2014-08-26
      • 1970-01-01
      • 2013-07-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多