-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation/clarification on SeccompCmpArgLen #59
Comments
Hi. Have a look here to see why this arg len was introduced: firecracker-microvm/firecracker#1227 Let me know if this solves the issue. I think you're right, we should better document this enum |
Thanks for the link! I've now read the thread and am able to reproduce the issue in both libseccomp and libseccomp-rs. I think to summarize (mostly the same as serban300's summary): glibc's ioctl definition takes a
While you can cast
So when a 32 bit int greater than 0x8000_0000 gets passed as a signed 32 bit parameter, the sign bit gets extended to the upper 32 bits. On the seccomp/BPF side, libseccomp and libseccomp-rs repros |
So I'm wondering if the best thing to do would be to create a "quirks file" either in seccompiler or in extrasafe that simply keeps track of which syscalls have 32 bit arguments. The only risk I can think of is that a syscall expanding the type of a parameter, which seems unlikely, but even that can probably be mitigated by requiring that the msb all be 0 or 1 in the filter so that nothing gets through. The alternative is that this work is done in each project that ues seccomp individually. Do you know if anyone spoke to the libseccomp people or the seccomp maintainers about this issue? |
Ah, I think they are aware because I found this section in the manpage:
|
I don't think maintaining in seccompiler a list of syscalls that use 32-bit and 64-bit params is feasible. This is quite a confusing issue, so maybe having it better documented somewhere would help. Both in the readme and in the rust docs of |
I think this is why seccomp hasn't seen wider adoption and why people praise openbsd's pledge and unveil over it - it's just simpler to use. 99.99% of developers have no idea whether they're using an ioctl parameter with the 32nd bit set or not when they develop a web application with a directory traversal vulnerability. I'll experiment with a quirks list inside extrasafe. Regarding the documentation, I can maybe write a PR but I have a bunch of other things I also need to do so it might take some time. |
Maybe, for basic use-cases, but I believe seccomp is arguably more flexbile for an advanced user. Now, system call filtering is a very difficult thing to get right for an application, simply because most of them are not calling system calls directly and don't have control over which system calls their dependencies are using. Anyway, the vast majority of use-cases shouldn't be concerned IMO with restricting parameters of system calls. For the majority of them, I think simple filtering on the syscall number is probably enough.
same here. I'll leave this issue open to track the documentation change, in case anybody gets some time to write it |
Is it basically always okay to use SeccompCmpArgLen::Qword on 64 bit systems? I'm doing so in my tests and I don't seem to see any issues, but I also don't have anything close to exhaustive tests of all syscalls.
Libseccomp seems to always do the full 64 bit comparison on 64 bit systems: https://github.com/seccomp/libseccomp/blob/main/src/db.c#L1665
I don't have any plans currently to support 32 bit systems but I'm just not sure when I might encounter issues. Does it exist basically so that the backend can generate either 32 or 64 bit ebpf regardless of what the host architecture is? i.e. When actually running the ebpf, you should always use Qword on 64 bit systems and Dword on 32 bit systems?
The text was updated successfully, but these errors were encountered: