-
-
Notifications
You must be signed in to change notification settings - Fork 895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ptrace #736
ptrace #736
Conversation
a437e5e
to
4bb76a9
Compare
33c0421
to
fc70899
Compare
What kinda works:
What does not work:
|
70665ee
to
f1eb124
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this, it's really cool to finally have it (mostly) working!
}); | ||
unlock(&pids_lock); | ||
} else if (interrupt == INT_DEBUG) { | ||
lock(&pids_lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need to lock pids_lock, as the signal is being sent to current?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signal_delivery_stop
requires pids_lock
:
Line 109 in f1eb124
unlock(&pids_lock); |
} else if (interrupt == INT_DEBUG) { | ||
lock(&pids_lock); | ||
send_signal(current, SIGTRAP_, (struct siginfo_) { | ||
.sig = SIGTRAP_, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be needed
Line 60 in 95dc3f5
sigqueue->info.sig = sig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't have that at first, but IIRC this was necessary because the signal is swallowed by signal_delivery_stop
and made available via ptrace(PTRACE_GETSIGINFO, …)
, at which point the signal needed to be correct.
@@ -616,6 +616,17 @@ int __do_execve(const char *file, struct exec_args argv, struct exec_args envp) | |||
|
|||
current->did_exec = true; | |||
vfork_notify(current); | |||
|
|||
if (current->traced) { | |||
lock(&pids_lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking the lock, or sending a signal? I think both are necessary…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking the lock, but no need to discuss it here, there are like 500 other comments about it
kernel/fork.c
Outdated
|
||
if (current->traced) { | ||
current->ptrace.trap_event = PTRACE_EVENT_FORK_; | ||
lock(&pids_lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing unlock(&pids_lock), but I dunno if the lock is necessary (see other comments)
aa2ae50
to
38806cc
Compare
This comment has been minimized.
This comment has been minimized.
922102b
to
1d714a7
Compare
kernel/ptrace.c
Outdated
user_regs_->edi = cpu->edi; | ||
user_regs_->ebp = cpu->ebp; | ||
user_regs_->eax = cpu->eax; | ||
// user_regs_->xds = cpu->xds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation on these comments is a bit funky compared to set_user_regs
c231b48
to
77aa1b2
Compare
213fbc3
to
77aa1b2
Compare
It's back