ladybird/Kernel/FileSystem
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
..
BlockBasedFileSystem.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
BlockBasedFileSystem.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
Custody.cpp Kernel: Support read-only filesystem mounts 2020-05-29 07:53:30 +02:00
Custody.h Kernel: Support read-only filesystem mounts 2020-05-29 07:53:30 +02:00
DevPtsFS.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
DevPtsFS.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
ext2_fs.h Meta: Remove some copyright headers added in error 2020-01-25 10:34:32 +01:00
ext2_types.h Meta: Add a script check the presence of "#pragma once" in header files 2020-05-29 07:59:45 +02:00
Ext2FileSystem.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
Ext2FileSystem.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
FIFO.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
FIFO.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
File.cpp Kernel: Allow File::close() to fail 2020-06-02 21:49:47 +02:00
File.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
FileBackedFileSystem.cpp Kernel: Split BlockBasedFileSystem off FileBackedFileSystem 2020-07-05 12:26:27 +02:00
FileBackedFileSystem.h Kernel: Split BlockBasedFileSystem off FileBackedFileSystem 2020-07-05 12:26:27 +02:00
FileDescription.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
FileDescription.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
FileSystem.cpp Kernel: Switch singletons to use new Singleton class 2020-08-25 09:48:48 +02:00
FileSystem.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
Inode.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
Inode.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
InodeFile.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
InodeFile.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
InodeIdentifier.h Kernel: Deemphasize inode identifiers 2020-06-25 15:49:04 +02:00
InodeMetadata.h Refactor: Replace usages of FixedArray with Vector. 2020-09-08 14:01:21 +02:00
InodeWatcher.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
InodeWatcher.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
Plan9FileSystem.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
Plan9FileSystem.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
ProcFS.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
ProcFS.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
TmpFS.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
TmpFS.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
VirtualFileSystem.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
VirtualFileSystem.h Kernel: Fix various forward declarations 2020-09-12 13:46:15 +02:00