-
Notifications
You must be signed in to change notification settings - Fork 69
Description
The GDB output when analysing v8 coredumps is confusing due to the program headers pointed by the AT_PHDR auxv value contained in the coredump not matching the program headers in the executable. It seems the coredump does not contain a PT_LOAD that corresponds to the mapping containing the in-memory program headers (pointed by the AT_PHDR auxv entry). I observe that the in-memory program headers are invalid.
gef> info auxv
3 AT_PHDR Program headers for program 0x100040
4 AT_PHENT Size of program header entry 56
5 AT_PHNUM Number of program headers 12
6 AT_PAGESZ System page size 4096
8 AT_FLAGS Flags 0x0
9 AT_ENTRY Entry point of program 0x32afec1
7 AT_BASE Base address of interpreter 0x47ce0000
24 AT_EHDRFLAGS ELF header e_flags 0x10000
15 AT_EXECPATH Executable path 0xffffbff7ff80 "/home/zyj20/v8/out/cheri-uncompressed-debug-fuzz/d8"
18 AT_OSRELDATE OSRELDATE 1500026
16 AT_CANARY Canary for SSP 0xffffbff7ff40
17 AT_CANARYLEN Length of the SSP canary 64
19 AT_NCPUS Number of CPUs 4
20 AT_PAGESIZES Pagesizes 0xffffbff7ff20
21 AT_PAGESIZESLEN Number of pagesizes 32
22 AT_TIMEKEEP Pointer to timehands 0xfffffffff020
23 AT_STACKPROT Initial stack protection 0x3
25 AT_HWCAP Machine-dependent CPU capability hints 0x10119ffb
26 AT_HWCAP2 Extension of AT_HWCAP 0x0
27 AT_BSDFLAGS ELF BSD flags 0xa0000001
28 AT_ARGC Argument count 1
29 AT_ARGV Argument vector 0xffffbff7f380
30 AT_ENVC Environment count 31
31 AT_ENVV Environment vector 0xffffbff7f3a0
32 AT_PS_STRINGS Pointer to ps_strings 0xffffbff7ffc0
35 AT_USRSTACKBASE Top of user stack 0xfffffff80000
36 AT_USRSTACKLIM Grow limit of user stack 0x40000000
37 ??? 0xffffbff7fa60
0 AT_NULL End of vector 0x0
gef> p *(Elf64_Phdr *)0x100040
$1 = {
p_type = 0x4d0,
p_flags = 0x0,
p_offset = 0x100022001fff22,
p_vaddr = 0x37fa10d,
p_paddr = 0x48,
p_filesz = 0x100022004e6ab1,
p_memsz = 0x42857e5,
p_align = 0x78
}
In svr4_exec_displacement in GDB, there is a verification that the program headers pointed by the AT_PHDR auxv value and the on-disk program headers match:
https://github.com/CTSRD-CHERI/gdb/blob/6b6284a9a2bbbe50548b7d1271e6984c26b12c24/gdb/solib-svr4.c#L2753
In this case, the verification fails and the svr4_exec_displacement function returns 0. Therefore, the displacement is not correct leading to confusing debug output.
As a temporary measure, I zero out the AT_PHDR value to skip the verification.
This is the original GDB output, without zeroing AT_PHDR.
Reading symbols from /home/zyj20/v8/out/cheri-uncompressed-debug-fuzz/d8...
[New LWP 219834]
Cannot access memory at address 0xdc5d40004040c04c
Cannot access memory at address 0xdc5d40004040c03c
Cannot access memory at address 0xdc5d40004040c03c
Core was generated by `./d8'.
Program terminated with signal SIGPROT, CHERI protection violation.
Capability tag fault.
#0 0x00000000033e82fc in v8::internal::ValidatePropertyCallbackInfo<v8::Boolean> (info=...) at ../../src/api/api.cc:11544
11544 CHECK(info.Data()->IsValue());
gef> bt
#0 0x00000000033e82fc in v8::internal::ValidatePropertyCallbackInfo<v8::Boolean> (info=...) at ../../src/api/api.cc:11544
#1 0x00000000033e8154 in v8::internal::ValidatePropertyCallbackInfo<v8::Boolean> (info=...) at ../../src/api/api.cc:11539
#2 0x00000000032f0e08 in Cr_z_inflate_fast_chunk_ (strm=0x32f0e09 <Cr_z_inflate_fast_chunk_+524> [rxRE,0x100000-0x8b60000] (sentry),
start=0xdc5d4000) at ../../third_party/zlib/contrib/optimizations/inffast_chunk.c:142
#3 0x0000000047cff298 in ?? ()
Backtrace stopped: frame did not save the PC
gef> info aux
3 AT_PHDR Program headers for program 0x100040
This is the GDB output of the patched coredump, with zeroed AT_PHDR, and correct backtraces.
Reading symbols from /home/zyj20/v8/out/cheri-uncompressed-debug-fuzz/d8...
[New LWP 219834]
Core was generated by `./d8'.
Program terminated with signal SIGPROT, CHERI protection violation.
Capability tag fault.
#0 0x00000000033e82fc in __sanitizer_cov_trace_pc_guard (
guard=0x7d0fe78 <.L__sancov_gen_.7231cbb79ecf2923ad1e8777c20ac37a.8> [rwRW,0x7d0fe78-0x7d0fe7c]) at ../../src/d8/cov.cc:89
89 shmem->edges[index / 8] |= 1 << (index % 8);
gef> bt
#0 0x00000000033e82fc in __sanitizer_cov_trace_pc_guard (
guard=0x7d0fe78 <.L__sancov_gen_.7231cbb79ecf2923ad1e8777c20ac37a.8> [rwRW,0x7d0fe78-0x7d0fe7c]) at ../../src/d8/cov.cc:89
#1 0x00000000033e8434 in v8::base::Malloc (size=0xdc5d40004d604840) at ../../src/base/platform/memory.h:32
#2 0x00000000033e8154 in __sanitizer_cov_trace_pc_guard_init (start=0x7d03010 <__start___sancov_guards> [rwRW,0x7d03000-0x7f9a800],
stop=0x7f9a624 [rwRW,0x7f9a624-0x7f9a624]) at ../../src/d8/cov.cc:45
#3 0x00000000032f0e08 in sancov.module_ctor_trace_pc_guard ()
#4 0x0000000047cff298 in objlist_call_init (list=<optimized out>, lockstate=<optimized out>) at /usr/src/libexec/rtld-elf/rtld.c:3686
#5 0x0000000047cfdb78 in _rtld (aux=<optimized out>, exit_proc=0xfffffff7ffe0 [rwRW,0xfffffff7ffe0-0xfffffff7fff0],
objp=<optimized out>) at /usr/src/libexec/rtld-elf/rtld.c:1133
#6 0x0000000047cfa498 in rtld_start () at /usr/src/libexec/rtld-elf/aarch64/rtld_start.S:77
gef> info aux
3 AT_PHDR Program headers for program 0x0
I can't attach the example d8 coredump and the corresponding d8 binary in this issue.