Linux procfs inode 号在进程运行时发生变化
我正在为 Linux 开发安全软件(SW)。 我们的软件所做的一件事是,当某个进程启动时,软件 stat() 会记录该进程的 /proc/ 条目并记住该条目的 inode 号。 当稍后软件需要确定进程仍在运行(并且尚未重新启动)时,它会再次查找进程的 inode 并与记住的 inode 进行比较。 一切都很好,直到最近我开始收到特定应用程序的错误警报 - Opera 浏览器 11.10beta。 基本上看来,当 Opera 运行时,其 /proc/PID 条目的索引节点号已更改,我们认为这是不可能的。 这是软件安全概念工作中的一个相当大的扳手 - 很大程度上依赖于这样一个事实:当进程正在运行时,其 /proc/ 条目的 inode 保持不变。
有人可以告知为什么会出现这种行为吗? 谢谢。
I'm working on security software(SW) for Linux.
One thing that our SW does on is that when some process is started, the SW stat()s the process's /proc/ entry and remembers the entry's inode number.
When later on the SW needs to ascertain that the process is still running (and hasn't been restarted), it again looks up process's inode and compares to the one remembered.
All was fine and dandy until recently I began receiving false alerts for a specifc application - Opera browser 11.10beta.
Basically it appears that while Opera was running, the inode number for its /proc/PID entry has changed, which we considered an impossibility.
This is a rather big spanner in the works of the SW's security concept - so much relied on the fact that while a process is running, its /proc/ entry's inode remains unchanged.
Could someone please advise as to why such behaviour may be exhibited.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
防御性编程习惯+1。
免责声明
如果这不是很明显:我只是在这里集思广益。显然我们不能立即给出答案,而且我的想法不适合评论;我会删除它,因为它不会带来解决方案
我当然会确保 Opera 没有
forked
/exec
本身(抱歉,这可能会侮辱你的智力:));接下来,看看命名空间和 chroot
编辑
编辑
我想说进程 ID 必须已更改(或 procfs 重新挂载,对用户进程可见) ?):
+1 for the defensive programming habits.
Disclaimer
In case it isn't obious: I'm just brainstorming along here. It is clear we cannot just give the answer instantaneously, and my thoughts didn't fit in a comment; I will delete this is it doesn't lead to a solution
I'd certainly make sure that the opera hasn't
forked
/exec
-ed itself (sorry that probably insults your intelligence :));Next, have a look at namespaces and chrooting
Edit
Edit
I'd say that the process ID must have changed (or procfs remounted, visibly to the user process?):
感谢 sehe 指出了正确的方向,并感谢 Random832 最终解决了这个问题。
我运行了一个进程并监视其 PID ls -i /proc/21314 。唉!该目录下的每个条目的索引节点号在大约 1 年后发生了更改。 15分钟。
所以 inode 号在 procfs 中从来就不是永久的:(
Thanks to sehe for pointing in the right direction and to Random832 for finally nailing it.
I ran a process and monitored its PID ls -i /proc/21314 . Alas! Every single entry under that directory had its inode number changed after approx. 15 minutes.
So inode numbers were never meant to be permanent in procfs :(