如何使用 ebpf 终止进程?
我想从 bpf 函数(execve)内部将 send_sig_info 发送到进程,但它不会加载。 我知道他们从内核 5.3 开始添加了一个辅助函数,但我正在开发较低的内核。 有没有办法从 bpf 函数终止进程?
I want to send_sig_info to a process from inside bpf function (execve) but it won't load.
I know that they added a helper function since kernel 5.3 but I'm working on a lower kernel.
Is there a way to kill a process from bpf function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您指的是 Linux v5.3 中引入的
bpf_send_signal
帮助程序。据我所知,在引入该助手之前,无法从 BPF 程序终止进程。如果您试图从
execve(2)
执行中终止当前进程,您可以改用 seccomp-bpf。请注意,由于 seccomp-bpf 依赖于 cBPF 而不是 eBPF,因此您将无法过滤参数(故意的,因为存在 TOCTTOU 攻击的风险)。I believe you are referring to the
bpf_send_signal
helper, introduced in Linux v5.3. As far as I know, before that helper was introduced, there was no way to terminate a process from a BPF program.If you are trying to kill the current process from it's
execve(2)
execution, you may be able to rely on seccomp-bpf instead. Note that, since seccomp-bpf relies on cBPF instead of eBPF, you won't be able to filter on the arguments (on purpose, because of the risk of TOCTTOU attacks).