cadets / freebsd-old

FreeBSD src tree http://www.FreeBSD.org/
Other
12 stars 7 forks source link

`copyinstr` (and others) need user address translation #142

Closed dstolfa closed 2 years ago

dstolfa commented 2 years ago

Running

dtrace -E -n 'vm*:syscall:::entry {  trace(copyinstr(curthread->td_proc->p_comm)); }'

Causes the following failure:

/usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c:621:8: runtime error: member access within null pointer of type 'const dt_idsig_t' (aka 'const struct dt_idsig')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c:621:8 in 
AddressSanitizer:DEADLYSIGNAL
=================================================================
==3404==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x0008014bcd98 bp 0x7fffffffd470 sp 0x7fffffffd340 T0)
==3404==The signal is caused by a READ memory access.
==3404==Hint: address points to the zero page.
    #0 0x8014bcd98 in dt_cg_arglist /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c:621:8
    #1 0x8014a7114 in dt_cg_node /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c:2103:4
    #2 0x8014a5367 in dt_cg /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c:2266:2
    #3 0x8014a2d8e in dt_action_trace /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c:706:2
    #4 0x801497c70 in dt_compile_fun /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c
    #5 0x801489dff in dt_compile_one_clause /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c:1673:4
    #6 0x801489dff in dt_compile_clause /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c:1699:3
    #7 0x801489dff in dt_compile /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c:2559:5
    #8 0x801486824 in dtrace_program_strcompile /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c:2624:10
    #9 0x10faad0 in compile_str /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c:2175:22
    #10 0x10f51dc in main /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c:3056:3
    #11 0x107278c in _start /usr/home/ds815/hypertrace/lib/csu/amd64/crt1_c.c:75:7
    #12 0x80112d007  (<unknown module>)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /usr/home/ds815/hypertrace/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c:621:8 in dt_cg_arglist
==3404==ABORTING
dstolfa commented 2 years ago

I have renamed this to reflect the current state of things. We no longer segfault, however we need to perform user -> kernel address translation in the guest so that host HyperTrace can actually access the data. This is true for other subroutines that do similar things.