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

Assertion "IS_IN_SYSENTER(tracee)" #13

Closed
SDRausty opened this issue Apr 7, 2018 · 38 comments
Closed

Assertion "IS_IN_SYSENTER(tracee)" #13

SDRausty opened this issue Apr 7, 2018 · 38 comments

Comments

@SDRausty
Copy link

SDRausty commented Apr 7, 2018

@Root-voidX asked, "A few questions about Arch Linux in Termux PRoot #59" including:

does this work on 8.0?

After working on this issue; Here is what we have:

screenshot_20180407-114201

Assertion "IS_IN_SYSENTER(tracee)" failed:
Proot warning: signal 6 recieved when proot --link2symlink -0 $PREFIX/bin/applets/tar xf $file is called. Busybox tar never finishes unpacking the downloaded system image file. Insight is welcome.

@michalbednarski
Copy link
Collaborator

I'm working on fix, for now you should be able to work around this with export PROOT_NO_SECCOMP=1

It's because in Linux 4.8 order of PTRACE_SYSCALL event and seccomp event was swapped (Linux commit, mailing list post, upstream PRoot issue)

@SDRausty

This comment was marked as spam.

@SDRausty

This comment was marked as spam.

@SDRausty

This comment was marked as spam.

@michalbednarski
Copy link
Collaborator

michalbednarski commented Apr 16, 2018 via email

@SDRausty

This comment was marked as spam.

@SDRausty

This comment was marked as spam.

@SDRausty

This comment was marked as spam.

@SDRausty

This comment was marked as spam.

@SDRausty

This comment was marked as spam.

@michalbednarski
Copy link
Collaborator

It seems that termux-exec is active and is prepending /data/data/com.termux/... to executable paths If this is path is not available inside proot, please "unset LD_PRELOAD"

Exactly as message says, first program failed to execute and proot noticed termux-exec in LD_PRELOAD, that command was not either not run from your script, there's some bug in your script and it kept LD_PRELOAD, or bug in something above (as a generic note nesting proot is not supported and causes issues, make sure you're not inside proot (e.g. termux-chroot) already)


In this issue there's probably something between libc, proot and kernel, so I cannot point anything in script snippets. I'm trying to set up reproduction AOSP environment, but running AArch64 AOSP Oreo with modified kernel somehow became surprisingly difficult.

@SDRausty

This comment was marked as spam.

@michalbednarski
Copy link
Collaborator

I've finally got reproduction environment so I can finally start really working on it (but keep in mind that from reproducing problem to having solution is still some work to do and I have job/family/life to spent time on too, so please be patient)

I actually think it's an issue with android 8.0 itself

Can you confirm what is happening with Android 8 Oreo?
a) Android 8 works well with Termux, only some users are having issues.
b) Almost all Android 8 users are having a hard time with Termux.

You need to realize that it's not just about Android version, but also about Linux (kernel) version, which isn't tightly coupled to Android versions, OEMs can choose to use different kernel versions with particular Android version (AFAIK their choice of kernel version depends on for what version they have drivers ready for). For example, on my phone I've got Android 8.0 with Linux 4.4 and TermuxArch runs fine there.

The changes that broke proot are:

  1. Linux changed order of events triggered by SECCOMP_RET_TRACE and PTRACE_SYSCALL (that is worked around by PROOT_NO_SECCOMP=1 unless we have this with combination of 2.)
  2. Android Oreo introduced seccomp policy that denied non-Bionic syscalls (set_robust_list caused program to get SIGSYS signal and it was used by glibc, the workaround for this was already put in proot to replace SIGSYS signal with ENOSYS errno returned from syscall, but that mechanism broke in combination with 1.) (also, this isn't problem as long as process doesn't call banned syscalls, which is why install is working)

there's some bug in your script

unset LD_PRELOAD

That's what should have avoided termux-exec problem, yet somehow we've got it (but that is separate issue probably unrelated to main one in this thread). Bug in script is only one of possibilities and I'd expect that error was actually caused by manually running command (as I don't really know how could unset fail)

Correct me if I misunderstood. It is possible that this user is already in a PRoot environment or similar.

Some users like to autostart termux-chroot script, in which case there can be problems with nested PRoots

@Root-voidX
Copy link

@michalbednarski

I was original poster for the issue in termux-arch.

It could be possible that it is a kernel issue.

Linux localhost 4.9.65-13087505 #1 SMP PREEMPT Sun Feb 25 18:48:40 KST 2018 aarch64 Android

That's the kernel version I am using. It's a snapdragon 845 so it's the latest version. Maybe it's a issue specifically to it?

@michalbednarski
Copy link
Collaborator

AFAIK issue is related to change in mainline kernel.

Could you check what result does this program print if run under proot

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
int main() {
	int a = open("nonexistent-test-file-a", O_RDONLY);
	int ae = errno;
	int b = open("nonexistent-test-dir/nonexistent-test-file-b", O_RDONLY);
	int be = errno;
	int c = open("nonexistent-test-file-c", O_RDONLY);
	int ce = errno;
	printf("[%d %d %d %d %d %d]\n", a, ae, b, be, c, ce);
}
clang testapp.c -o testapp
PROOT_NO_SECCOMP=1 proot ./testapp

@SDRausty

This comment was marked as spam.

@SDRausty

This comment was marked as spam.

@Root-voidX
Copy link

@michalbednarski @SDRausty

Here you go.

cd proot
$ ls
ktest.sh  testapp
$ bash ktest.sh

PRoot test results:

[-1 2 -1 38 -1 2]

$

michalbednarski added a commit that referenced this issue Apr 26, 2018
* Detect seccomp event order and handle both old and new one
* If new seccomp order is in use, syscalls with FILTER_SYSEXIT
  are handled immediately as we cannot reach syscall entry event
  as it already happened (but wasn't delivered as it wasn't requested)
* When we set PR_void syscall in non-seccomp handler, ignore next
  SIGSYS, beacuse Android seccomp policy disallows -1 syscall

#13
@michalbednarski
Copy link
Collaborator

I have initial fix for this issue (now on master branch here and on termux/termux-packages#2374).

Please remove PROOT_NO_SECCOMP=1 as it's use will prevent proot from detecting whenever it should use new behavior (In case of problems PROOT_NO_SECCOMP=1 PROOT_ASSUME_NEW_SECCOMP=1 could be used, however this will break on older Linux versions while not providing any should work across all versions)

Running debuggers inside proot on Linux >= 4.8 is not yet supported

@Root-voidX
Copy link

Sounds good, once @SDRausty commits this, I will try it. Thst is unfortunate that debugger doesn't work on 4.9. Worst comes to worse, I have a older rooted tablet where I can just chroot to play around with. Would love to use the latest and greatest though.

@SDRausty

This comment was marked as spam.

@michalbednarski
Copy link
Collaborator

I've pushed new proot version which fixes debugging and hang after which Ctrl-C exits proot and makes bash print [1] Stopped message (this was regression in yesterday commit, this happened when process inside proot got killed before it performed any syscall, this might be

But my zsh init file will not load, it will just hang until I press Ctrl-c and then it will return to the default prompt.

thing described by @SwiftLawnGnome in SDRausty/TermuxArch#74 (comment)).

Version from my yesterday commit is now in apt repo, for status on todays version see termux/termux-packages#2383

@SDRausty

This comment was marked as spam.

@SDRausty SDRausty closed this as completed May 1, 2018
@SDRausty SDRausty reopened this May 1, 2018
@SDRausty

This comment was marked as spam.

@Root-voidX
Copy link

Root-voidX commented May 1, 2018

@SDRausty

I ran the installer again on 8.0 on the newest kernal on s9+ using sd 845.

Can you explain these warnings and errors:

warning: could not get file information for boot/Image
warning: could not get file information for usr/lib/modules/4.16.0-1-ARCH/build/vmlinux
:: Processing package changes...
( 1/32) upgrading linux-api-headers                [#######] 100%
( 2/32) upgrading glibc                            [#######] 100%
warning: /etc/locale.gen installed as /etc/locale.gen.pacnew
Generating locales...
  en_US.UTF-8... done

OR THIS

linux.img
==> Starting build: 4.16.6-1-ARCH
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [autodetect]
sort: cannot read: '/sys/devices/platform/soc/soc:qcom,llccbw/devfreq/soc:qcom,llccbw/uevent': Permission denied
sort: cannot read: /sys/devices/virtual/mdnie/mdnie/uevent: Permission denied
modprobe: ERROR: missing parameters. See -h.
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: wd719x
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> ERROR: file not found: `fsck.rootfs'
==> WARNING: No fsck helpers found. fsck will not be run on boot.
/usr/lib/initcpio/functions: line 636: /dev/stdin: No such file or directory
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux.img
==> WARNING: errors were encountered during the build. The image may not be complete.
==> Building image from preset: /etc/mkinitcpio.d/linux-aarch64.preset: 'fallback'
  -> -k 4.16.6-1-ARCH -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
==> Starting build: 4.16.6-1-ARCH
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: wd719x
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
/usr/lib/initcpio/functions: line 636: /dev/stdin: No such file or directory
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-fallback.img
==> Image generation successful
error: command failed to execute correctly
( 2/12) Warn about old perl modules
( 3/12) Updating journal message catalog...
( 4/12) Reloading system manager configuration...
  Skipped: Current root is not booted.
( 5/12) Updating udev hardware database...
( 6/12) Applying kernel sysctl settings...
  Skipped: Current root is not booted.
( 7/12) Creating system user accounts...
( 8/12) Creating temporary files...
[tmp.conf:15] Failed to replace specifiers: /tmp/systemd-private-%b-*
[tmp.conf:16] Failed to replace specifiers: /tmp/systemd-private-%b-*/tmp
[tmp.conf:17] Failed to replace specifiers: /var/tmp/systemd-private-%b-*
[tmp.conf:18] Failed to replace specifiers: /var/tmp/systemd-private-%b-*/tmp
error: command failed to execute correctly

Otherwise it installed and I can run arch kinda:
https://imgur.com/a/kupJv4r

I just wanna make sure those errors dont cause fatal errors later on.

@SDRausty

This comment was marked as spam.

@SDRausty SDRausty closed this as completed May 1, 2018
@Root-voidX
Copy link

@SDRausty yeah it seems they are mostly warnings and proot seems to suppress them and continue working. So I guess it's all good. I'll let you guys know of any other issues in the termux-arch github thanks for the help.

@SDRausty

This comment was marked as spam.

@michalbednarski
Copy link
Collaborator

@SDRausty
/dev/shm is directory used by POSIX shared memory (shm_open), it should be directory where apps can write (but not same as /tmp, though if it would be it probably wouldn't break anything))

@Root-voidX
These are caused by kernel related scripts, but as unprivileged app we can't manage kernel and devices. It seems that kernel and firmware packages can be removed (pacman -R linux-aarch64 linux-firmware, TermuxArch uses kernel and firmware from host Android anyway, however it is possible that those packages are dependency for something else)

@Root-voidX
Copy link

Root-voidX commented May 1, 2018

@michalbednarski

Would you suggest keeping them anyway. Seems like the errors were suppressed. Pacman indicates a successful install?

@SDRausty

This comment was marked as spam.

@Root-voidX
Copy link

Interesting tidbit, arch loaded in that latest firmware and kernal for my device in an update. Install went fine with no errors, a bunch of read warnings but that's about it.

@SDRausty

This comment was marked as spam.

@kazz2020
Copy link

kazz2020 commented Nov 6, 2018

Hi
I dont know where to write this so sorry if that is wrong place :/
I have Honor 8x android 8.1 and after installing LXDE on Kali nethunter in Termux (in kali apt update && apt upgrade are ok) i have such error:

Setting up man-db (2.8.4-2+b1) ...
Building database of manual pages ... ./tracee/event.c:517: int handle_tracee_event(Tracee *, int): assertion "!IS_IN_SYSENTER(tracee)" failed proot warning: signal 6 received from process 7750
$
I can admit that everything was ok on my ze520kl android 8.0 version.
Does anybody has solution for my problem?

@ghost
Copy link

ghost commented Feb 21, 2019

In ubuntu, sudo works as long as you don't use --link2symlink...
But then you cant apt install anything....

*on an non-rooted device

@ghost
Copy link

ghost commented Feb 21, 2019

@bakaika It is completely different issue. Not #13.

@ghost
Copy link

ghost commented Feb 21, 2019

Oh sorry. What issue is it?

@ghost
Copy link

ghost commented Feb 21, 2019

Open new.

Grimler91 pushed a commit that referenced this issue Jul 25, 2022
* Detect seccomp event order and handle both old and new one
* If new seccomp order is in use, syscalls with FILTER_SYSEXIT
  are handled immediately as we cannot reach syscall entry event
  as it already happened (but wasn't delivered as it wasn't requested)
* When we set PR_void syscall in non-seccomp handler, ignore next
  SIGSYS, beacuse Android seccomp policy disallows -1 syscall

#13
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

4 participants