-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fixed ptrace 'Operation not permitted' #15287
Conversation
…ess; cleaned up the code
// Attaching to a process that has already been started with PTRACE_TRACEME. | ||
// sets errno to "Operation not permitted" which may be misleading. | ||
// GETSIGINFO can be called multiple times and would fail without attachment. | ||
if (-1 == r_debug_ptrace(dbg, PTRACE_GETSIGINFO, ptid, NULL, |
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 space before ( and piut the == -1 in the right side of the statement
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.
Updated
// GETSIGINFO can be called multiple times and would fail without attachment. | ||
if (-1 == r_debug_ptrace(dbg, PTRACE_GETSIGINFO, ptid, NULL, | ||
(r_ptrace_data_t)&sig)) { | ||
if (-1 == r_debug_ptrace (dbg, PTRACE_ATTACH, ptid, NULL, |
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.
same here
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.
Updated
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.
lgtm
This issue is a result of running PT_ATTACH on a forked PID when you're only supposed to PT_ATTACH remote pids. linux_set_options probably always worked for you when testing in fork mode but it wouldn't work in remote attachment since you have to attach first + there's was error handling there.
When using fork_and_ptraceme_for_linux the child sets himself up to be traced for you.
I used GETSIGINFO to check the attachment status since it doesn't have any consequences(same result even if you run it multiple times) and always works on an attached process.
Also went ahead and cleaned up the code around the changes.
closes #14506