Problem description
zsh terminates with Bad system call when sourcing fzf completion configuration.
Steps to reproduce
git clone https://github.com/junegunn/fzf.git
zsh -f
source fzf/shell/completion.zsh
Bad system call
Expected behavior
Sourcing this file should work without failures.
Additional information
$ termux-info
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.org/packages/ stable main
# science-repo (sources.list.d/science.list)
deb https://dl.bintray.com/grimler/science-packages-24 science stable
# game-repo (sources.list.d/game.list)
deb https://dl.bintray.com/grimler/game-packages-24 games stable
Updatable packages:
All packages up to date
Android version:
9
Kernel build information:
Linux localhost 4.4.153-perf+ #1 SMP PREEMPT Mon Feb 24 20:28:46 CST 2020 aarch64 Android
Device manufacturer:
OnePlus
Device model:
ONEPLUS A5010
Running zsh under proot -0 fixes the issue, but I'm not sure that running whole shell under root is good practice. Plus proot -0 workaround isn't possible to use with login shell it seems.
Does this happen when you source other files as well or only this one?
If it only happens for fzf's completion.zsh then the syscall is probably done in fzf and there is nothing we can do from the termux side of things
I was able to trigger issue only with this file. But keep in mind that this issue triggers only on termux, other platforms work fine. Also please keep in mind that this completion script doesn't do anything "special", it's pure zsh functionality. This script doesn't call fzf binary, crash is in zsh.
I debugged this execution a little using zsh -f -x to trace where it fails. Crash is at https://github.com/junegunn/fzf/blob/master/shell/completion.zsh#L327, and by following code and comments here is shorter pure zsh reproducible case.
zsh -f
comp_options="options=(${(j: :)${(kv)options[@]}})"
eval $comp_options
Bad system call
Let's debug this further. There is one specific option that triggers Bad system call. I bisected options array, and it's privileged off.
So final reproduction for this case is:
zsh -f
unsetopt PRIVILEGED
Bad system call
other platforms work fine
Yeah, it happens because android's selinux policy does not allow syscalls that are typically allowed in "normal" GNU/Linux distros.
So final reproduction for this case is
zsh -f
unsetopt PRIVILEGED
Bad system call
Thanks!
Zsh does setreuid and setregid calls - that's why seccomp is triggered.
Should be fixed by https://github.com/termux/termux-packages/commit/3ca0a5506e4332c43b7970bebf5e6f0c82ef0f40.
pkg upgrade
Most helpful comment
Should be fixed by https://github.com/termux/termux-packages/commit/3ca0a5506e4332c43b7970bebf5e6f0c82ef0f40.
pkg upgrade