Skip to content
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_SEIZE not supported #3031

Closed
luser opened this issue Mar 16, 2018 · 2 comments
Closed

PTRACE_SEIZE not supported #3031

luser opened this issue Mar 16, 2018 · 2 comments

Comments

@luser
Copy link

luser commented Mar 16, 2018

  • Your Windows build number: Microsoft Windows [Version 10.0.16299.309]

  • What you're doing and what's happening:

The PTRACE_SEIZE request to the ptrace syscall is not supported. Example program:

/* gcc -o ptrace-test ptrace.c */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <unistd.h>

int main(int argc, char** argv) {
  pid_t pid = fork();
  if (pid == 0) {
    sleep(60);
    exit(0);
  }
  if (ptrace(PTRACE_SEIZE, pid, NULL, 0) == 0) {
    printf("ptrace succeeded\n");
  } else {
    perror("ptrace failed");
  }
  return 0;
}

Example output:

luser@DESKTOP-32V9ND8:/mnt/c/build$ gcc -o ptrace-test ptrace.c
luser@DESKTOP-32V9ND8:/mnt/c/build$ ./ptrace-test
ptrace failed: Invalid argument
  • What's wrong / what should be happening instead:
    PTRACE_SEIZE should work similarly to PTRACE_ATTACH (which does work). Per the man page:
PTRACE_SEIZE (since Linux 3.4)
              Attach to the process specified in pid, making it a tracee of
              the calling process.  Unlike PTRACE_ATTACH, PTRACE_SEIZE does
              not stop the process.

This prevents rr from working, and I'm sure it impacts other programs as well.

@therealkenc
Copy link
Collaborator

Thanks for the excellent repro on PTRACE_SEIZE, since you weren't thanked earlier (we don't get enough of them). Better in WSL2.

image

@vishwaraj101
Copy link

vishwaraj101 commented Mar 29, 2022

Hi Getting error while using frida python inside wsl 2:
Using python 3.8.10 in ubuntu

➜ testbed ./fuzz.py
Traceback (most recent call last):
File "./fuzz.py", line 62, in
session = frida.attach(pid)
File "/home/raj/.local/lib/python3.8/site-packages/frida/init.py", line 62, in attach
return get_local_device().attach(target, **kwargs)
File "/home/raj/.local/lib/python3.8/site-packages/frida/core.py", line 26, in wrapper
return f(*args, **kwargs)
File "/home/raj/.local/lib/python3.8/site-packages/frida/core.py", line 156, in attach
return Session(self._impl.attach(self._pid_of(target)))
frida.NotSupportedError: unexpected error while attaching to process with pid 634 (PTRACE_SEIZE returned 'Invalid argument')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants