crashpad::PtraceBroker Class Reference

Implements a PtraceConnection over a socket. More...

`#include "util/linux/ptrace_broker.h"`

## Classes

struct | GetThreadInfoResponse
| The response sent for a Request with type kTypeGetThreadInfo. More...
struct | Request
| A request sent to a PtraceBroker from a PtraceClient. More...

## Public Types

enum | OpenResult : int32_t
| A result used in operations that accept paths. More...
enum | ReadError : int32_t
| A result used in operations that read from memory or files. More...

## Public Member Functions

| PtraceBroker (int sock, pid_t pid, bool is_64_bit)
| Constructs this object. More...
void | SetFileRoot (const char *root)
| Restricts the broker to serving the contents of files under root. More...
int | Run ()
| Begin serving requests on the configured socket. More...

## Detailed Description

Implements a PtraceConnection over a socket.

This class is the server half of the connection. The broker should be run in a process with `ptrace` capabilities for the target process and may run in a compromised context.

## Member Enumeration Documentation

## OpenResult

enum crashpad::PtraceBroker::OpenResult : int32_t

A result used in operations that accept paths.

Positive values of this enum are reserved for sending errno values.

Enumerator
kOpenResultAccessDenied | Access to the path is denied.
kOpenResultTooLong | The path name is too long.
kOpenResultSuccess | The file was successfully opened.

## ReadError

enum crashpad::PtraceBroker::ReadError : int32_t

A result used in operations that read from memory or files.

Positive values of this enum are reserved for sending errno values.

Enumerator
kReadErrorAccessDenied | Access to this data is denied.

## Constructor & Destructor Documentation

## PtraceBroker()

crashpad::PtraceBroker::PtraceBroker | ( | int | sock,
|  | pid_t | pid,
|  | bool | is_64_bit
| ) |  |

Constructs this object.

Parameters

  [in] | sock | A socket on which to read requests from a connected PtraceClient. Does not take ownership of the socket.
  [in] | pid | The process ID of the process the broker is expected to trace. Setting this value exends the default file root to "/proc/[pid]/" and enables memory reading via /proc/[pid]/mem. The broker will deny any requests to read memory from processes whose processID is not pid. If pid is -1, the broker will serve requests to read memory from any process it is able to via `ptrace PEEKDATA`.
  [in] | is_64_bit | Whether this broker should be configured to trace a 64-bit process.

## Member Function Documentation

## Run()

int crashpad::PtraceBroker::Run | ( |  | ) |

Begin serving requests on the configured socket.

This method returns when a PtraceBrokerRequest with type kTypeExit is received or an error is encountered on the socket.

This method calls `sbrk`, which may break other memory management tools, such as `malloc`.

Returns
  0 if Run() exited due to an exit request. Otherwise an error code.

## SetFileRoot()

void crashpad::PtraceBroker::SetFileRoot | ( | const char * | root | ) |

Restricts the broker to serving the contents of files under root.

If this method is not called, the broker defaults to only serving files under "/proc/" or "/proc/[pid]/" if a pid was set.

Calling this function disables reading from a memory file if one has not already been opened.

Parameters

  [in] | root | A NUL-terminated c-string containing the path to the new root. root must not be `nullptr`, must end in a '/', and the caller should ensure that root remains valid for the lifetime of the broker.

The documentation for this class was generated from the following files:

- util/linux/ptrace_broker.h
- util/linux/ptrace_broker.cc