简体   繁体   English

如何使用 Ebpf 阻止文件打开?

[英]How to Stop File From Opening Using Ebpf?

I want to use EBPF and place a probe on the open syscall, so when a user wants to open a certain file I will check its name and if it is the targeted name I will stop it from opening.我想使用 EBPF 并在打开的系统调用上放置一个探测器,因此当用户想要打开某个文件时,我将检查它的名称,如果它是目标名称,我将阻止它打开。 The only thing is I do not know how to actually achieve this goal.唯一的问题是我不知道如何真正实现这个目标。

In addition, I would appreciate if you could specify if a certain solution works with uprobe or root probe.此外,如果您能指定某个解决方案是否适用于 uprobe 或 root 探针,我将不胜感激。 Thanks a lot.非常感谢。

TL;DR. TL;博士。 There's currently no way to do this using BPF.目前没有办法使用 BPF 来做到这一点。


There is currently no option in the Linux kernel to enforce policies on syscalls using eBPF.目前Linux 内核中没有选项可以使用 eBPF 对系统调用强制执行策略。 This may change with the introduction of eBPF-based LSMs (Linux Security Modules) though (see Kernel Runtime Security Instrumentation , KRSI — the other BPF security module , and KRSI and proprietary BPF programs ).不过,这可能会随着基于 eBPF 的 LSM(Linux 安全模块)的引入而改变(参见内核运行时安全检测KRSI——另一个 BPF 安全模块,以及KRSI 和专有 BPF 程序)。

You can however enforce policies on syscalls with seccomp-bpf , but it uses cBPF, the old BPF bytecode, instead of eBPF.但是,您可以使用 seccomp-bpf 对系统调用实施策略,但它使用 cBPF(旧的 BPF 字节码)而不是 eBPF。 It is nevertheless not possible to inspect syscall arguments passed by pointers with seccomp-bpf , for security reasons ;然而,出于安全原因无法检查由 seccomp-bpf 指针传递的系统调用参数 so you wouldn't be able to check the name of the file being opened.所以你将无法检查正在打开的文件的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM