ladybird/Kernel/VM
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
..
AnonymousVMObject.cpp Kernel: Move all code into the Kernel namespace 2020-02-16 01:27:42 +01:00
AnonymousVMObject.h Kernel: Switch to using AK::is and AK::downcast 2020-07-26 17:51:00 +02:00
ContiguousVMObject.cpp Kernel: Allow contiguous allocations in physical memory 2020-03-08 14:13:30 +01:00
ContiguousVMObject.h Kernel: Switch to using AK::is and AK::downcast 2020-07-26 17:51:00 +02:00
InodeVMObject.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
InodeVMObject.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
MappedROM.h Kernel: Fix various forward declarations 2020-09-12 13:46:15 +02:00
MemoryManager.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
MemoryManager.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
PageDirectory.cpp Kernel: Switch singletons to use new Singleton class 2020-08-25 09:48:48 +02:00
PageDirectory.h Kernel: Release page tables when no longer needed 2020-08-28 09:21:24 +02:00
PhysicalPage.cpp Kernel: Make PhysicalPage not movable and use atomic ref counting 2020-08-25 09:48:48 +02:00
PhysicalPage.h Kernel: Make PhysicalPage not movable and use atomic ref counting 2020-08-25 09:48:48 +02:00
PhysicalRegion.cpp Kernel: Optimize single physical page allocation and randomize returns 2020-09-09 13:02:14 +02:00
PhysicalRegion.h Kernel: Optimize single physical page allocation and randomize returns 2020-09-09 13:02:14 +02:00
PrivateInodeVMObject.cpp Kernel: Split InodeVMObject into two subclasses 2020-02-28 20:20:35 +01:00
PrivateInodeVMObject.h Kernel: Add some InodeVMObject type assertions in Region::clone() 2020-03-01 11:23:10 +01:00
ProcessPagingScope.cpp Kernel: Turn Thread::current and Process::current into functions 2020-07-01 12:07:01 +02:00
ProcessPagingScope.h Kernel: Move ProcessPagingScope to its own files 2020-03-01 15:38:09 +01:00
PurgeableVMObject.cpp Kernel: Only remap regions if memory was purged from them 2020-09-01 22:08:43 +02:00
PurgeableVMObject.h Kernel: Switch to using AK::is and AK::downcast 2020-07-26 17:51:00 +02:00
RangeAllocator.cpp Kernel: Unbreak building with extra debug macros, part 2 2020-08-30 09:43:49 +02:00
RangeAllocator.h Kernel: Add mechanism to identity map the lowest 2MB 2020-06-04 18:15:23 +02:00
Region.cpp Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
Region.h Kernel: Make copy_to/from_user safe and remove unnecessary checks 2020-09-13 21:19:15 +02:00
SharedInodeVMObject.cpp Kernel: Split InodeVMObject into two subclasses 2020-02-28 20:20:35 +01:00
SharedInodeVMObject.h Kernel: Add some InodeVMObject type assertions in Region::clone() 2020-03-01 11:23:10 +01:00
TypedMapping.h Kernel: Add non-const version of TypedMapping::operator->() 2020-05-23 15:57:19 +02:00
VMObject.cpp Refactor: Replace usages of FixedArray with Vector. 2020-09-08 14:01:21 +02:00
VMObject.h Refactor: Replace usages of FixedArray with Vector. 2020-09-08 14:01:21 +02:00