ladybird/Kernel/Syscalls
Tom c8d9f1b9c9 Kernel: Make copy_to/from_user safe and remove unnecessary checks
Since the CPU already does almost all necessary validation steps
for us, we don't really need to attempt to do this. Doing it
ourselves doesn't really work very reliably, because we'd have to
account for other processors modifying virtual memory, and we'd
have to account for e.g. pages not being able to be allocated
due to insufficient resources.

So change the copy_to/from_user (and associated helper functions)
to use the new safe_memcpy, which will return whether it succeeded
or not. The only manual validation step needed (which the CPU
can't perform for us) is making sure the pointers provided by user
mode aren't pointing to kernel mappings.

To make it easier to read/write from/to either kernel or user mode
data add the UserOrKernelBuffer helper class, which will internally
either use copy_from/to_user or directly memcpy, or pass the data
through directly using a temporary buffer on the stack.

Last but not least we need to keep syscall params trivial as we
need to copy them from/to user mode using copy_from/to_user.
2020-09-13 21:19:15 +02:00
..
access.cpp Kernel: Convert some more syscalls to Userspace<T> 2020-08-02 11:01:00 +02:00
alarm.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
beep.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
chdir.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
chmod.cpp Kernel: Use Userspace<T> for the chmod syscall 2020-08-10 12:52:15 +02:00
chown.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
chroot.cpp Kernel: Use Userspace<T> for the chroot syscall 2020-08-10 12:52:15 +02:00
clock.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
debug.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
disown.cpp Kernel: PID/TID typing 2020-08-10 11:51:45 +02:00
dup2.cpp Kernel+LibC+UserspaceEmulator: Bring back sys$dup2() 2020-08-15 11:11:34 +02:00
execve.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
exit.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
fcntl.cpp Kernel: Turn Process::FileDescriptionAndFlags into a proper class 2020-07-30 23:50:31 +02:00
fork.cpp Kernel: Rename Process::is_ring0/3 to Process::is_kernel/user_process 2020-09-10 19:57:15 +02:00
ftruncate.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
futex.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
get_dir_entries.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
get_stack_bounds.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
getrandom.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
getuid.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
hostname.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
ioctl.cpp Kernel: Remove SmapDisabler in sys$ioctl() 2020-07-31 00:17:25 +02:00
kill.cpp Kernel: Rename Process::is_ring0/3 to Process::is_kernel/user_process 2020-09-10 19:57:15 +02:00
link.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
lseek.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
mkdir.cpp Kernel: Convert some more syscalls to Userspace<T> 2020-08-02 11:01:00 +02:00
mknod.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
mmap.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
module.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
mount.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
open.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
perf_event.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
pipe.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
pledge.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
process.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
profiling.cpp Kernel: Remove ProcessInspectionHandle and make Process RefCounted 2020-08-02 17:15:11 +02:00
ptrace.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
purge.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
read.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
readlink.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
realpath.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
rename.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
rmdir.cpp Kernel: Convert some more syscalls to Userspace<T> 2020-08-02 11:01:00 +02:00
sched.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
select.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
sendfd.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
setkeymap.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
setpgid.cpp Kernel: Distinguish between new and old process groups with equal pgids 2020-08-19 21:21:34 +02:00
setuid.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
shbuf.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
shutdown.cpp Kernel: Add shutdown commands for other virtualizers 2020-08-30 10:31:39 +02:00
sigaction.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
socket.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
stat.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
sync.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
sysconf.cpp Kernel: Add _SC_PAGESIZE to sysconf 2020-07-31 18:26:33 +02:00
thread.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
times.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
ttyname.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
umask.cpp Kernel: Move syscall implementations out of Process.cpp 2020-07-30 23:40:57 +02:00
uname.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
unlink.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
unveil.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
utime.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
waitid.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
watch_file.cpp Kernel: Use Userspace<T> in more syscalls 2020-08-01 11:37:40 +02:00
write.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00