Linux: Where is the “real” segfault handler?

Linux: Where is the “real” segfault handler? … here is a solution to the problem.

Linux: Where is the “real” segfault handler?

If I read/write/jump to a mapped address, ie.

.text
    .global _start
_start:
     movl   $1,%edx
     jmp     *%edx

This results in a segfault.

I want to know, what is the actual part of the system (kernel).
Intercept reads/writes to unmapped addresses (how?) )
And throw a “user mode” signal?

Solution

Everything comes from the schema trap table. This is often referred to as entry. S (split between entry_32 and entry_64.S on x86) and has assembler chaining, doing many things (depending on configuration) before going into the kernel’s C code.

Therefore, invalid memory accesses should come in via page_fault or general_protection and may end up executing force_sig_info and then eventually queued back to user space in send_signal (kernel/signal.c).

Related Problems and Solutions