Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux: where's the "real" segmentation fault handler?

If I read/write/jump to an ummapped address ie.

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

this causes a segmentation fault.

I wonder, what's the actual part of the system (kernel) that intercepts reads/writes to unmapped addresses (how ?) and throws the "user mode" signal ?

like image 211
gpilotino Avatar asked Mar 14 '26 18:03

gpilotino


1 Answers

Everything flows from the architectures trap table. This is usually called entry.S (split on x86 between entry_32 and entry_64.S) and has assembler linkage that does a number of things (depending on config) before heading into the C code of the kernel proper.

So an invalid memory access should enter through either page_fault or general_protection and will probably end up doing force_sig_info before finally being queued back to user space in send_signal (kernel/signal.c).

like image 152
stsquad Avatar answered Mar 17 '26 09:03

stsquad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!