Add ptrace interceptor support for LoongArch, ptrace.cpp has been
tested and passed.
Details
- Reviewers
SixWeining xen0n xry111 MaskRay XiaodongLoong - Group Reviewers
Restricted Project - Commits
- rG4ae3e13c7dbd: [sanitizer] Add ptrace interceptor support for LoongArch
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/test/asan/TestCases/Linux/ptrace.cpp | ||
---|---|---|
36 | aarch64 should be printed with %llx here , but this is not related to our change anyway. |
compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h | ||
---|---|---|
276 | __loongarch__ or __loongarch_grlen == 64? I'm not sure. Same as below. |
compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h | ||
---|---|---|
276 |
This part of the kernel ptrace treats 32 and 64 bits the same, so I used __loongarch__ for better compatibility with 32-bit implementations in the future |
$ ./test/asan/LOONGARCH64LinuxConfig/TestCases/Linux/Output/ptrace.cpp.tmp ================================================================= ==3270112==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffff14fd188 at pc 0x5555575d8674 bp 0x7ffffbccdee0 sp 0x7ffffbccd670 WRITE of size 360 at 0x7ffff14fd188 thread T0 #0 0x5555575d8670 (/home/loongson/llvm-work/llvm-project-test2/llvm-project/build_crt/test/asan/LOONGARCH64LinuxConfig/TestCases/Linux/Output/ptrace.cpp.tmp+0x68670) #1 0x55555767b8d4 in main /home/loongson/llvm-work/llvm-project-test2/llvm-project/compiler-rt/test/asan/TestCases/Linux/ptrace.cpp:115:11 #2 0x7ffff2f71678 (/usr/lib64/libc.so.6+0x25678) #3 0x7ffff2f71764 in __libc_start_main (/usr/lib64/libc.so.6+0x25764) #4 0x555557596d84 in _start /opt/mylaos/build/glibc-2.36/csu/../sysdeps/loongarch/start.S:61 Address 0x7ffff14fd188 is located in stack of thread T0 at offset 392 in frame #0 0x55555767b3f0 in main /home/loongson/llvm-work/llvm-project-test2/llvm-project/compiler-rt/test/asan/TestCases/Linux/ptrace.cpp:87 This frame has 4 object(s): [32, 392) 'regs' (line 95) [464, 472) 'pregs' (line 96) <== Memory access at offset 392 partially underflows this variable [496, 512) 'regset_io' (line 98) <== Memory access at offset 392 partially underflows this variable [528, 800) 'fpregs' (line 121) <== Memory access at offset 392 partially underflows this variable HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/loongson/llvm-work/llvm-project-test2/llvm-project/build_crt/test/asan/LOONGARCH64LinuxConfig/TestCases/Linux/Output/ptrace.cpp.tmp+0x68670) Shadow bytes around the buggy address: 0x7ffff14fcf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ffff14fcf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ffff14fd000: f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 00 00 0x7ffff14fd080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ffff14fd100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x7ffff14fd180: 00[f2]f2 f2 f2 f2 f2 f2 f2 f2 00 f2 f2 f2 00 00 0x7ffff14fd200: f2 f2 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 0x7ffff14fd280: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 0x7ffff14fd300: f8 f8 f8 f8 f3 f3 f3 f3 f3 f3 f3 f3 00 00 00 00 0x7ffff14fd380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x7ffff14fd400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==3270112==ABORTING
This is not related to our change anyway.
The current stack display has some problems, the location of the function definition cannot be found at level #0.
in LoongArch:
#0 0x5555575d8670 (/home/loongson/llvm-work/llvm-project-test2/llvm-project/build_crt/test/asan/LOONGARCH64LinuxConfig/TestCases/ Linux/Output/ptrace.cpp.tmp+0x68670) #1 0x55555767b8d4 in main /home/loongson/llvm-work/llvm-project-test2/llvm-project/compiler-rt/test/asan/TestCases/Linux/ptrace.cpp: 115:11
in x86_64:
#0 0x561c13d22b18 in __interceptor_ptrace /home/loongson/tang/llvm-work/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc #1 0x561c13dbdc9a in main /home/loongson/tang/llvm-work/llvm-project/compiler-rt/test/asan/TestCases/Linux/ptrace.cpp:108:11
This phenomenon will cause some other test cases to fail.
Does the test still fail now?
ptrace.cpp test passed.
The current stack display has some problems, the location of the function definition cannot be found at level #0.
Calltrace display problem has been fixed by D137384 .
__loongarch__ or __loongarch_grlen == 64? I'm not sure. Same as below.