Skip to content
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

seccomp failure on Android trying to call openat2 from open_beneath #196

Closed
hrydgard opened this issue Nov 10, 2021 · 4 comments
Closed

Comments

@hrydgard
Copy link

I'm trying to run some code that uses cap-std on Android 10 (on a kernel that definitely does not support the syscall), and I hit the following crash in openat2, called by open_beneath from open_impl:

 signal 31 (SIGSYS), code 1 (SYS_SECCOMP), fault addr --------
 Cause: seccomp prevented call to disallowed arm64 system call 437

 backtrace:
       #00 pc 00000000000703d0  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32) 
       #01 pc 0000000002e8e404  ourapp.so (rsix::imp::libc::syscalls::openat2::h04809da1ec63d9ef+44) 
       #02 pc 0000000002e8aa9c  ourapp.so (cap_primitives::rsix::linux::fs::open_impl::open_beneath::h3811b95d26505c84+312) 
       #03 pc 0000000002e8a800  ourapp.so (cap_primitives::rsix::linux::fs::open_impl::open_impl::h725b24260261d337+40)
       ...

Looking back up into cap-std, it seems that the detection method for presence of openat2 is inadequate, because instead of simply returning ENOSYS as the linked code assumes, Android forcibly kills the process with a SIGSYS signal.

rsix::io::Error::NOSYS => {

So there needs to be some sort of kernel version check instead I guess?

@sunfishcode
Copy link
Member

Thanks for the report! I've now filed #197 which implements a kernel version check, which may fix the problem. I don't have an Android device to test it on though. Would you be able to test this fix?

@hrydgard
Copy link
Author

Thank you! I will test it tomorrow.

@hrydgard
Copy link
Author

I can confirm that your version check indeed solves the problem!

@sunfishcode
Copy link
Member

Thanks! This is now released in 0.21.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants