Rtoax / ulpatch

ULPatch is open source user space live patch tool.
https://rtoax.github.io/ulpatch/
GNU General Public License v2.0
4 stars 2 forks source link

Ubuntu23.04/x86_64: remote open failed #14

Closed Rtoax closed 2 months ago

Rtoax commented 2 months ago
ulpatch/tests/hello$ ./hello
print_hello                     : 0x0056350895f260
puts                            : 0x007fdd9627af40
Hello World. 0, 255
Hello World. 1, 255
Hello World. 1, 255
...
ulpatch/tests/hello$ sudo ./test.sh -u patch-pthread.ulp
Already install ulpatch
make: Nothing to be done for 'build'.
Wrong ELF magic
/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2: unable to find lowest load address.
remote open failed.
56350895e000-56350895f000 r--p 00000000 fc:02 798284                     /home/rongtao/Git/ulpatch/tests/hello/hello
56350895f000-563508960000 r-xp 00001000 fc:02 798284                     /home/rongtao/Git/ulpatch/tests/hello/hello
563508960000-563508961000 r--p 00002000 fc:02 798284                     /home/rongtao/Git/ulpatch/tests/hello/hello
563508961000-563508962000 r--p 00002000 fc:02 798284                     /home/rongtao/Git/ulpatch/tests/hello/hello
563508962000-563508963000 rw-p 00003000 fc:02 798284                     /home/rongtao/Git/ulpatch/tests/hello/hello
563509dbd000-563509dde000 rw-p 00000000 00:00 0                          [heap]
7fdd949fd000-7fdd949fe000 ---p 00000000 00:00 0 
7fdd949fe000-7fdd951fe000 rw-p 00000000 00:00 0 
7fdd951fe000-7fdd951ff000 ---p 00000000 00:00 0 
7fdd951ff000-7fdd959ff000 rw-p 00000000 00:00 0 
7fdd959ff000-7fdd95a00000 ---p 00000000 00:00 0 
7fdd95a00000-7fdd96200000 rw-p 00000000 00:00 0 
7fdd96200000-7fdd96222000 r--p 00000000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7fdd96222000-7fdd9639a000 r-xp 00022000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7fdd9639a000-7fdd963f2000 r--p 0019a000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7fdd963f2000-7fdd963f6000 r--p 001f1000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7fdd963f6000-7fdd963f8000 rw-p 001f5000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7fdd963f8000-7fdd96405000 rw-p 00000000 00:00 0 
7fdd96484000-7fdd96487000 rw-p 00000000 00:00 0 
7fdd9649b000-7fdd9649d000 rw-p 00000000 00:00 0 
7fdd9649d000-7fdd9649e000 r--p 00000000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7fdd9649e000-7fdd964c6000 r-xp 00001000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7fdd964c6000-7fdd964d0000 r--p 00029000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7fdd964d0000-7fdd964d2000 r--p 00033000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7fdd964d2000-7fdd964d4000 rw-p 00035000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7fffbaa8d000-7fffbaaae000 rw-p 00000000 00:00 0                          [stack]
7fffbaafe000-7fffbab02000 r--p 00000000 00:00 0                          [vvar]
7fffbab02000-7fffbab04000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]
/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2: unable to find lowest load address.
No ULPatch founded in process 11384
Rtoax commented 2 months ago

The detail:

ulpatch/tests/hello$ sudo ./test.sh -u patch-pthread.ulp -d
...
15:29:11 [DEBUG][ehdr.c ehdr_magic_ok:20] Wrong ELF magic
15:29:11 [DEBUG][task.c task_syscall:1948] result 7f0cd6b8b000
15:29:11 [DEBUG][task.c task_syscall:1948] result fffffffffffffff3
15:29:11 [DEBUG][task.c task_syscall:1948] result 0
15:29:11 [ERROR][patch.c create_mmap_vma_file:233] remote open failed.
Rtoax commented 2 months ago

After fix https://github.com/Rtoax/ulpatch/issues/15, this issue still not be solved.

Rtoax commented 2 months ago

opensnoop

$ sudo opensnoop.bt | grep hello
19875  ulpatch             8   0 /home/rongtao/Git/ulpatch/tests/hello/hello
19875  ulpatch             9   0 /home/rongtao/Git/ulpatch/tests/hello/hello
19509  hello              -1  13 /tmp/ulpatch/19509/map_files/patch-BAsaXo
19877  ulpinfo             6   0 /home/rongtao/Git/ulpatch/tests/hello/hello
19877  ulpinfo             7   0 /home/rongtao/Git/ulpatch/tests/hello/hello
$ ll /tmp/ulpatch/19509/map_files/patch-BAsaXo 
-rw-r--r-- 1 root root 1824 May  7 18:34 /tmp/ulpatch/19509/map_files/patch-BAsaXo
Rtoax commented 2 months ago

Because the remove task hello don't have the permission to open the patch file. If i run hello with sudo, problem solved. I think we should get the target task permission and set the patch file to that permission.

Rtoax commented 2 months ago

This issue was fixed by commit https://github.com/Rtoax/ulpatch/commit/82297ea5f5c54aaa397ea23d290d3549884f08e1