proot-me / proot

chroot, mount --bind, and binfmt_misc without privilege/setup for Linux
https://proot-me.github.io
GNU General Public License v2.0
2.02k stars 378 forks source link

[Ubuntu 14.04] proot warning/error #73

Closed saibe closed 9 years ago

saibe commented 9 years ago

Hello,

In my project using proot/mock over stlinux, when I aunch a 'make boot', I have some warning. It looks not matter since the command does what it should. I just share to you the warning message in case you have some details about it.

$ make boot

LANG=C LC_ALL=C stlinux_arm_boot -r -t "10.48.1.48:b2196stxh301:a9_0,active_cores=a9_0:dbu,ca9_freq=1500,debug=uart,debugram_base=0x47FF8000,debugram_size=32768,boardrev=2" -macaddr="eth0:00:80:E1:01:2F:A7" -ex "set pagination off" -b "/local/view/SDK2-15.3_INT_004_CF_L/build/build/sdk2-build.b2196-h301_a9/../build-b2196-h301_a9/kernel/vmlinux" -dtb "/local/view/SDK2-15.3_INT_004_CF_L/build/build/sdk2-build.b2196-h301_a9/../build-b2196-h301_a9/kernel/arch/arm/boot/devicetree/sdk2_stih301-b2196.dtb" -xpk "extra.gdb" -a "0x42000000" -s "251658240" -- "console=ttyAS0,115200" "CONSOLE=/dev/ttyAS0" "loglevel=1" "ip=::::b2196-h301_a9:eth0:dhcp" "root=/dev/nfs" "nfsroot=10.48.0.156:/var/lib/mock/st-redhat6.4-x86_64-SDK2-15.3_INT_004_CF_L/root/opt/STM/STLinux-2.4/devkit/armv7/target,tcp,nfsvers=3" "mtdparts=stm-nand-bch.0:0x500000(boot),-(rfs)" "bpa2parts=BPA2_Region|aud-coded|aud-transcoded|vid-coded|vid-transcoded|vid-raw-input|vid-output-0|vid-decimated-1|vid-copied-1|vid-macroblock-0|vid-extra-data-0|vid-extra-data-1|v4l2-coded-video-buffers|vid-enc-data-0|vid-enc-scaled-0|vid-encoded-0|v4l2-clut|v4l2-grab|gfx-memory|aud-codec-data|vid-codec-data|aud-output-0|aud-output-1|vid-output-1|vid-decimated-0|vid-copied-0|vid-macroblock-1|blitter|vid-enc-data-1|vid-enc-scaled-1|vid-encoded-1|coredisplay-video|multicom|hades-l3|BPA2_Region0|BPA2_Region1:207M:0x53000000,v4l2-vb2|v4l2-stmc8jpg|v4l2-stmvout|v4l2-compo:24M:0x51800000,coprocs:32M:0x40000000,modules|audio:8M:0x51000000,bigphysarea|te-buffers|m2m-ca3:63M:0x48000000,STMCReserve:32768:0x47FF8000" "vmalloc=502m" "mem=251658240@0x42000000"

Warning: disabling Linux kernel awareness layer due to -r or -n options.

Kernel auto-detected as non-SMP

Booting from device tree blob /tmp/stlinux_arm_boot_xlk25YH7.29419

Booting ....

proot warning: ptrace(POKEDATA): Input/output error

proot error: can't transfer load script: Bad address

The target is assumed to be little endian

cedric-vincent commented 9 years ago

This issue is under investigation, thanks for the bug report. I'll keep you informed.

cedric-vincent commented 9 years ago

I'm not able to reproduce this issue on my workstation (using a CentOS-6-x86 rootfs and a version of STLinux downloaded from http://stlinux.com/). However, I spotted a dangerous code pattern in the code in charge of the load script transfer [1]. It should first call alloc_mem() then call write_data(), instead of changing explicitly the stack pointer after calling write_data().

I'll send soon you a version of PRoot that replaces this dangerous code, so you'll be able to test whether it fixes the issue you reported.

[1] https://github.com/cedric-vincent/PRoot/blob/v5.0.0/src/execve/exit.c#L302

cedric-vincent commented 9 years ago

Hello @saibe,

Could you please give the following binary a try? It is a statically linked version of PRoot v5.0.0 that contains commit f91ec1a.

https://drive.google.com/file/d/0B4dzkhnYQiNUZXFCT1FkckVQNEk/view

md5sum = fe45a94d95a4abbf9042e9fb9c793369

Don't forget to mark this binary executable since the "x" bit doesn't survive HTTP download.

Regards, Cédric.

ydroneaud commented 9 years ago

Hi

I'm also able to reproduce such issue.

The issue is related to the fact gdb is a 32bits binary trying to run iconv, which is a 64bits binary. Initially I"ve thought it was related to vfork() as gdb use vfork(), but plain fork() also exhibit the issue. For a reduced test case, please have a look at https://gist.github.com/ydroneaud/e1a98d5163732eecff1e

BTW, commit f91ec1a140f7930a82ff7eb0e61cd34350fdc447 doesn't fix the issue.

Regards.

cedric-vincent commented 9 years ago

@ydroneaud: many thanks for your work on this issue; it helps me a lot!

I'll [try to] make a fix tomorrow.

ydroneaud commented 9 years ago

(Note: I'm using Fedora 20 x86_64 and not Ubuntu, but I believe it doesn't matter :)

ydroneaud commented 9 years ago

It seems commit fd7ca5f8e92bd3b66d1fa1c31dc12db0ed5e88f9 fixes the issue (on my test case and with gdb).

cedric-vincent commented 9 years ago

@ydroneaud Thanks for the tests. This commit will be shipped in the upcoming release (v5.1.0), by the end of this month I hope.