Linux procfs inode 编号在进程运行时发生变化

标签 linux inode procfs

我正在为 Linux 开发安全软件 (SW)。 我们的 SW 所做的一件事是,当某个进程启动时,SW stat()s 进程的/proc/条目并记住条目的 inode 号。 当 SW 稍后需要确定该进程仍在运行(并且尚未重新启动)时,它会再次查找进程的 inode 并与内存的 inode 进行比较。 一切都很好,直到最近我开始收到针对特定应用程序的错误警报 - Opera 浏览器 11.10beta。 基本上看起来,当 Opera 运行时,它的/proc/PID 条目的 inode 号已经改变,我们认为这是不可能的。 这是 SW 安全概念工作中的一个相当大的 Spanner - 非常依赖这样一个事实,即当一个进程正在运行时,其/proc/条目的 inode 保持不变。

有人可以建议为什么会出现这种行为。 谢谢。

最佳答案

+1 防御性编程习惯。

免责声明 以防万一:我只是在这里集思广益。很明显我们不能立即给出答案,我的想法不适合发表评论;我将删除它,因为它不会导致解决方案

我肯定会确保歌剧没有forked/exec-ed 本身(抱歉,这可能会侮辱你的智慧:));

接下来,看看命名空间和 chrooting

编辑

编辑

我会说进程 ID 一定已经更改(或者 procfs 重新挂载,对用户进程可见?):

Under /proc we can find general system information and specific process information and statistics. Linux distinguishes different types of information with the inode number. An inode number in Linux is represented as a 32 bit number and a PID (Process Identifier) is represented as a 16 bit number. With this schema, Linux splits the inode number in two halves of 16 bit. The left half is interpreted as a PID number and the right one is interpreted as a class of information. Since a PID=0 is not valid, Linux uses this value to indicate that inode contains global information. (source)

关于Linux procfs inode 编号在进程运行时发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7470184/

相关文章:

linux - 如何在我的 Fortran 代码中检索架构类型(Linux 与 Windows)

linux - awk - 根据错误代码查找排名靠前的 url

c - 有没有办法在 C 中为 i_block 创建迭代器风格的函数?

file - 通过操作 inode 在没有临时文件的情况下添加文件?

linux - 将某些命令/配置恢复为默认值

linux - 在 sed 替换中使用 $HOSTNAME

linux - 写入 securityfs 文件

c - Unix readdir (3) 和 stat (2) 给出不同的 inode

Linux 应用程序在没有套接字的情况下发送 UDP