Page MenuHomeFreeBSD

ptrace(2): expand ability to fetch syscall parameters
Needs ReviewPublic

Authored by kib on Fri, Mar 21, 1:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 26, 6:47 PM
Unknown Object (File)
Mon, Mar 24, 5:42 AM
Unknown Object (File)
Mon, Mar 24, 5:42 AM
Unknown Object (File)
Mon, Mar 24, 5:42 AM
Unknown Object (File)
Mon, Mar 24, 5:42 AM
Unknown Object (File)
Mon, Mar 24, 5:42 AM
Subscribers

Details

Reviewers
markj
jhb
Summary
Do not limit lwpinfo reporting of syscall number and args to SCE/SCX
events. When td_sa holds the values, we can report them. Clear
td_sa.code in TDA_SIG ast handler: this handler is run when the process
is traced, and it is run with the last ptracestop() points before the
return to userspace.

This allows debugger to infer the interrupted syscall immediately after
PT_ATTACH without the need to loose control to the debuggee' thread. It
should work even when the debuggee is stopped in AST.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.EditedFri, Mar 21, 1:35 AM

Program utilizing this behavior: https://github.com/kostikbel/pollinfo

sys/kern/kern_sig.c
347

I think this line needs a comment explaining the interaction with ptrace.

kib marked an inline comment as done.

Add part of the commit message into the comment.

IMO it would be nice to add a test case to tests/sys/kern/ptrace_test.c for this.

sys/kern/kern_sig.c
350

A bit clearer (esp. for someone not so familiar with how ptrace works) might be something like:

Clear td_sa.code: signal to ptrace that syscall arguments are unavailable after this point. This AST handler is the last chance for ptracestop() to signal the tracer before the tracee returns to userspace.
sys/kern/sys_process.c
1519

We don't want to clear pl_syscall_narg if td_sa.code == 0?

kib marked 2 inline comments as done.Mon, Mar 24, 1:26 AM
kib added inline comments.
sys/kern/sys_process.c
1519

I think it does not matter, but ok.

kib marked an inline comment as done.

Reword the comment.
Do not assign nargs if sa_code is zero.