---
title: "What happens on a trap"
---

> Documentation Index
> Fetch the complete documentation index at: https://example.com/llms.txt
> Use this file to discover all available pages before exploring further.

# What happens on a trap

When you attach a uprobe, Linux replaces the target function's first machine instruction with a breakpoint (`int3` on x86-64, `brk` on ARM64). When the NF thread hits it, the CPU traps into kernel mode.

The kernel runs your eBPF program, single-steps the original instruction out-of-line, and returns to user space. A `uretprobe` adds a *second* trap on function return.

> **Key idea:** Unlike kernel tracepoints (already in ring 0), every uprobe forces a user→kernel→user context switch on the application's own thread.

Source: https://example.com/ebpf-field-guide/networking-and-packet-path/tls-and-uprobes/mechanics/index.mdx
