# Sigreturn-Oriented Programming (SROP)

### Overview

A **sigreturn** is a special type of [syscall](/notes/binexp/stack/syscalls.md). The purpose of sigreturn is to return from the **signal handler** and to clean up the stack frame after a signal has been unblocked.

What this involves is storing *all* the register values on the stack. Once the signal is unblocked, all the values are popped back in (RSP points to the bottom of the **sigreturn frame**, this collection of register values).

### Exploitation

By leveraging a `sigreturn`, we can control *all register values at once* - amazing! Yet this is also a drawback - we can't pick-and-choose registers, so if we don't have a stack leak it'll be hard to set registers like RSP to a workable value. Nevertheless, this is a super powerful technique - especially with limited gadgets.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ir0nstone.gitbook.io/notes/binexp/stack/syscalls/sigreturn-oriented-programming-srop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
