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

发布于 2024-12-05 05:07:49 字数 363 浏览 0 评论 0原文

我正在为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

煮酒 2024-12-12 05:07:49

防御性编程习惯+1。

免责声明
如果这不是很明显:我只是在这里集思广益。显然我们不能立即给出答案,而且我的想法不适合评论;我会删除它,因为它不会带来解决方案

我当然会确保 Opera 没有 forked/exec 本身(抱歉,这可能会侮辱你的智力:));

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

编辑

编辑

我想说进程 ID 必须已更改(或 procfs 重新挂载,对用户进程可见) ?):

在/proc下我们可以找到一般的系统信息和特定的进程信息和统计信息。 Linux通过inode号来区分不同类型的信息。 Linux 中的 inode 号表示为 32 位数字,PID(进程标识符)表示为 16 位数字。通过这种模式,Linux 将 inode 号分成 16 位的两半。左半部分被解释为 PID 号,右半部分被解释为一类信息。由于 PID=0 无效,Linux 使用该值来指示 inode 包含全局信息。 (来源

+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?):

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)

飘落散花 2024-12-12 05:07:49

感谢 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 :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文