termux / proot

An chroot-like implementation using ptrace.
https://wiki.termux.com/wiki/PRoot
Other
762 stars 160 forks source link

Issue with proot on android pie #71

Closed strikersix23 closed 5 years ago

strikersix23 commented 5 years ago

Issue with proot not working with http streams causing termux arch to not install and my Ubuntu root-fs not being able to update packages

strikersix23 commented 5 years ago

Here is a picture with my modified Ubuntu script Screenshot_2019-08-08_13-07-08

michalbednarski commented 5 years ago

In 387aa91bf5203d67f27a4838cfa871b657f71ce5 I've just fixed similar issue but affecting only 32bit x86. It looks like you're on 32bit arm which uses sendmmsg directly (not through socketcall) and sendmmsg is there allowed by Android seccomp and used by prooted glibc.

Could you try running following command and reporting result

echo apt update | PROOT_VERBOSE=9 ./start.sh |& busybox nc termbin.com 9999
strikersix23 commented 5 years ago

Here I did what you said sorry for the late response https://termbin.com/8dy8

strikersix23 commented 5 years ago

Yes I'm on arm32 android 9 pie

strikersix23 commented 5 years ago

[Uploading og1r.txt…]() here's a better

strikersix23 commented 5 years ago

michalbednarski your last commit does not fix it

michalbednarski commented 5 years ago

I think I've identified issue, pushed to new_order_void_syscall_fix branch (8b169bc1774d4f7277363b76ca52fceced9eaf24). Please test and if it works then I'll submit this to apt repo (I didn't reproduce locally so I'm not sure)

strikersix23 commented 5 years ago

Still doesnt work its saying group id cannot be added https://termbin.com/xuoi

strikersix23 commented 5 years ago

Here is the exact error ./start.sh root@localhost:~# apt-get update Reading package lists... Done E: Method gave invalid 400 URI Failure message: Failed to set new user ids - setresuid (1: Operation not permitted) E: Method http has died unexpectedly! E: Sub-process http returned an error code (112)

strikersix23 commented 5 years ago

perhaps the setup script is the issue ubuntu.txt

strikersix23 commented 5 years ago

Yes it was an sh till I uploaded it

michalbednarski commented 5 years ago

I've pushed 71573314c1a8e974df1da781752e8815c3148471 to new_order_void_syscall_fix, please retest, looks like I was previously wrong about value used as void syscall

michalbednarski commented 5 years ago

Updated version is now available in Termux apt repo

corbinlc commented 5 years ago

@michalbednarski looks like this is not a complete solution. The first problem is that the result is being corrupted when the SIGSYS on void occurs. For example:

proot info: vpid 4: sysenter start: openat(0xffffff9c, 0xf2ec1aa8, 0x0, 0x0, 0x1f028930, 0x404000) = 0xffffff9c [0xff892d18, 0]
proot info: vpid 4: translate("/" + "/usr/share/locale-langpack/C/LC_MESSAGES/apt.mo")
proot info: vpid 4: sysenter end: void(0xfffffffe, 0xf2ec1aa8, 0x0, 0x0, 0x1f028930, 0x404000) = 0xfffffffe [0xff892d18, 0]
proot info: vpid 4: seccomp SIGSYS: void(0xffffff9c, 0xf2ec1aa8, 0x0, 0x0, 0x1f028930, 0x404000) = 0xffffff9c [0xff892d18, 0]

Notice the result changed from sysenter end to seccomp SIGSYS

So, what I did was save off the result and then restore it. See here: https://github.com/CypherpunkArmory/proot/commit/ff1fd341bab3beee0704c7e567ce3fef5d3a432c

But, for some people that is not quite enough (or causing a new issue) and they are getting SIGSEGV when trying to run something later.

CypherpunkArmory/UserLAnd#1046

This looks like something is getting corrupted related to brk I think.

proot info: vpid 7: sysenter start: brk(0xf168000, 0xbe1182e4, 0xbe918470, 0x4000, 0xbe918324, 0xbe9182e4) = 0xf168000 [0xbe9182d0, 0]
proot info: vpid 7: sysenter end: mremap(0xf124000, 0x40000, 0x44000, 0x0, 0x0, 0xbe9182e4) = 0xf124000 [0xbe9182d0, 0]
proot info: vpid 7: sysexit start: mmap2(0x0, 0x1000, 0x3, 0x22, 0xffffffff, 0x0) = 0x0 [0xbe9182b0, 0]
proot info: vpid 7: sysexit end: brk(0xf164000, 0xbe1182e4, 0xbe918470, 0x4000, 0xbe918324, 0xbe9182e4) = 0xf164000 [0xbe9182d0, 0]

See the oddity... from sysenter end to sysexit start the sysnum changed from mremap to mmap2

This is the log that came from: Proot_Debug_Log-alpine1.txt

I am not sure what to make of this, so I am hoping you have more wisdom. I also hope pointing out that the result is getting corrupted in general will help Termux users.

corbinlc commented 5 years ago

Please note that for some other users/devices/kernel versions, just restoring the result was enough: https://github.com/CypherpunkArmory/UserLAnd/issues/1014