Skip to content

PTRACE_SEIZE not supported #3031

Closed
Closed

Description

@luser
  • 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.

Activity

  1. therealkenc commented on Aug 6, 2020

    @therealkenc

    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

  2. vishwaraj101 commented on Mar 29, 2022

    @vishwaraj101

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions