750
|
|
|
jopasserat |
6 years ago
|
|
|
749
|
|
|
jopasserat |
6 years ago
|
|
|
748
|
|
|
Jonathan Passerat-Pa... |
6 years ago
|
|
|
747
|
|
|
Christophe Guillon |
6 years ago
|
|
|
746
|
|
|
Nicolas Cornu |
7 years ago
|
|
|
745
|
|
|
Jonathan Passerat-Pa... |
7 years ago
|
|
|
744
|
|
|
Jonathan Passerat-Pa... |
7 years ago
|
|
|
743
|
|
|
jopasserat |
7 years ago
|
|
|
742
|
|
|
Cédric VINCENT |
9 years ago
|
|
|
741
|
|
|
Cédric VINCENT |
9 years ago
|
|
|
740
|
|
Load dynamic shared objects to their explicit base address if any.
Usually, dynamic shared objects are mapped to the beginning of the virtual memory. For example:
$ readelf -aW /lib/ld-linux.so.2 [...] Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x00000000 0x00000000 0x1ec58 0x1ec58 R E 0x1000 LOAD 0x01ec80 0x0001fc80 0x0001fc80 0x00bb8 0x00c78 RW 0x1000 [...]
However, it appears that some versions of Fedora-20/i686 ship an ELF interpreter with a non-null base address:
$ readelf -aW /lib/ld-linux.so.2 [...] Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x43acf000 0x43acf000 0x1ec58 0x1ec58 R E 0x1000 LOAD 0x01ec80 0x43aeec80 0x43aeec80 0x00bb8 0x00c78 RW 0x1000 [...]
In such cases, PRoot should not add a base address to the load address, otherwise this ELF interpreter might get mapped to an unexpected location:
proot info: translate("/" + "/lib/ld-linux.so.2") proot info: -> "/usr/lib/ld-2.18.so" proot info: sysenter end: open(0xbfa63970, 0x0, 0x0, 0xbfa63a18, 0x0, 0x3) = 0xffffffda [0xbfa63970, 0] proot info: sysexit start: open(0xbfa63970, 0x0, 0x0, 0xbfa63a18, 0x0, 0x3) = 0x3 [0xbfa63970, 0] proot info: sysexit end: open(0xbfa63a7a, 0x0, 0x0, 0xbfa63a18, 0x0, 0x3) = 0x3 [0xbfa63984, 0] proot info: sysenter start: mmap2(0xf2acf000, 0x1f000, 0x5, 0x12, 0x3, 0x0) = 0xffffffda [0xbfa63978, 0] proot info: sysenter end: mmap2(0xf2acf000, 0x1f000, 0x5, 0x12, 0x3, 0x0) = 0xffffffda [0xbfa63978, 0] proot info: sysexit start: mmap2(0xf2acf000, 0x1f000, 0x5, 0x12, 0x3, 0x0) = 0xfffffff4 [0xbfa63978, 0] proot info: sysexit end: mmap2(0xf2acf000, 0x1f000, 0x5, 0x12, 0x3, 0x0) = 0xfffffff4 [0xbfa63978, 0] proot info: sysenter start: exit(0xb6, 0x1f000, 0xb6, 0xbfa63a20, 0x1, 0x3) = 0xffffffda [0xbfa63984, 0] proot info: sysenter end: exit(0xb6, 0x1f000, 0xb6, 0xbfa63a20, 0x1, 0x3) = 0xffffffda [0xbfa63984, 0] proot info: exited with status 182
I verified that the Linux kernel behaves the same:
else if (loc->elf_ex.e_type == ET_DYN) { #ifdef CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE if (current->flags & PF_RANDOMIZE) load_bias = 0; else load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr); #else load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr); #endif }
Reported-by: Frank TEO <frank.teo@st.com>
|
Cédric VINCENT |
9 years ago
|
|
|
739
|
|
|
Cédric VINCENT |
9 years ago
|
|
|
738
|
|
|
Cédric VINCENT |
9 years ago
|
|
|
737
|
|
|
Cédric VINCENT |
9 years ago
|
|
|
736
|
|
|
Cédric VINCENT |
9 years ago
|
|
|
735
|
|
|
Cédric VINCENT |
9 years ago
|
|
|
734
|
|
|
Cédric VINCENT |
9 years ago
|
|
|
733
|
|
|
Cédric VINCENT |
9 years ago
|
|
|
732
|
|
ptrace: Fix deduplication of WIFEXITED/WIFSIGNALED events
The Linux kernel reports the terminating event (WIFEXITED/WIFSIGNALED) issued by a process to both its parent and its tracer, except when they are the same. In this case the Linux kernel reports the terminating event only once to the tracing parent.
Previously, PRoot tried to honor this behavior by reporting only the first terminating event (toward the tracer) and by hiding the second one (toward the parent). Sadly, this strategy leads to zombie processes since the child status is not collected by its parent from a kernel point-of-view.
For instance, when using GDB against a simple program:
$ proot gdb ./a.out [...] (gdb) break main [...] (gdb) run [...] Breakpoint 1, 0x000000000040062c in main ()
Then looking at the process hierarchy:
- before:
$ pstree -pa 8786 gdb,8786 ./a.out |-a.out,8788 `-(a.out,8791)
- now (it is just like without PRoot):
$ pstree -pa 8786 gdb,8786 ./a.out `-a.out,8791
It works correcly because PRoot now hides the first terminating event (toward the tracer) and make the second one (toward the parent) appear by restarting the wait syscall if needed.
Ref.: https://github.com/cedric-vincent/PRoot/issues/67
|
Cédric VINCENT |
9 years ago
|
|
|
731
|
|
|
Cédric VINCENT |
9 years ago
|
|
|