sortix-mirror/kernel/include/sortix
Jonas 'Sortie' Termansen 2e03bd94d3 Add protection against sigreturn oriented programming (SROP).
This change hardens against invalid calls to sigreturn, which is a very
useful gadget when compromising a process. The system call now verifies
it is a real return from a signal and aborts the process otherwise. This
should render such attacks impossible in threads that are not servicing a
signal, and infeasible in threads that are handling signals they are yet to
return from.

The kernel now keeps track for each thread how many signals are being
handled but haven't returned yet.

Each thread now has a random signal value. It is re-randomized when the
thread handles a signal and the current signal counter is zero. This is
xorred with the context address and used as canary on the stack during
signal dispatch, protecting the saved context on the stack. This works
mostly like the regular stack protector.

The kernel now keeps track of the stack pointer for a single handled
signal per thread. It doesn't seem worth it to keep track of multiple
handled signals, as more than one is rare. Note that each delivered signal
will not necessarily result in a sigreturn because it is valid for a thread
to longjmp(3) out of a signal handler to a valid jmp_buf.

The sigreturn system call will abort if either:

- It was not called from the kernel sigreturn page.
- The thread is not currently processing a signal.
- The thread is processing a single signal, and the stack pointer did not
  have the expected value.
- It fails to read the context on the stack.
- The canary is wrong.
2016-05-15 22:43:29 +02:00
..
__ Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
kernel Add protection against sigreturn oriented programming (SROP). 2016-05-15 22:43:29 +02:00
clock.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
dirent.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
display.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
exit.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
fcntl.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
fork.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
initrd.h Remove compatibility with Sortix 0.9. 2016-05-15 01:31:48 +02:00
ioctl.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
itimerspec.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
kblayout.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
keycodes.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
limits.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
mman.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
mount.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
poll.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
psctl.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
resource.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
seek.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
sigaction.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
sigevent.h Compile libc with -ffreestanding. 2016-05-15 22:43:29 +02:00
siginfo.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
signal.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
sigprocmask.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
sigset.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
sigval.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
socket.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
stack.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
stat.h Fix S_IROTH having the wrong value. 2016-03-28 16:25:42 +02:00
statvfs.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
syscall.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
tar.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
termios.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
termmode.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
time.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
timespec.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
tmns.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
types.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
ucontext.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
uio.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
unistd.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
uthread.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
vga.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
wait.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00
winsize.h Relicense Sortix to the ISC license. 2016-03-05 22:21:50 +01:00