简体   繁体   English

seccomp-bpf-如何使用bpf过滤系统调用的参数?

[英]seccomp-bpf - how can i use bpf to filter the arguments of a system call?

I have a function f() which returns 0 or 1 - 0 for false, 1 for true. 我有一个函数f(),它为false返回0或1-0,为true返回1。 What I'd like to do is set a rule with seccomp-bpf so that the system call "fopen" is only allowed if f( --fopen's first parameter-- ) == 1. 我想做的是使用seccomp-bpf设置一条规则,以便仅当f(--fopen的第一个参数-)== 1时才允许系统调用“ fopen”。

How would I do this? 我该怎么做?

as far as I understand seccomp-bpf it's impossible for an arbitrary f(). 据我了解seccomp-bpf,对于任意f()都是不可能的。 If f could be translated as a BPF sequence, just apply it to the first parameter. 如果f可以转换为BPF序列,只需将其应用于第一个参数。

another alternative is to use ptrace or a combination of seccomp-buf and ptrace to finegrained limit the capabilities of fopen call 另一种选择是使用ptrace或seccomp-buf和ptrace的组合来细化限制fopen调用的功能

an example of such combined use is sydbox http://dev.exherbo.org/~alip/sydbox/sydbox.html 此类组合用法的一个示例是sydbox http://dev.exherbo.org/~alip/sydbox/sydbox.html

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

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