ladybird/Kernel/Memory
Daniel Bertalan fa8507d1ce Kernel: Fix UB caused by taking a reference to a packed struct's member
Taking a reference or a pointer to a value that's not aligned properly
is undefined behavior. While `[[gnu::packed]]` ensures that reads from
and writes to fields of packed structs is a safe operation, the
information about the reduced alignment is lost when creating pointers
to these values.

Weirdly enough, GCC's undefined behavior sanitizer doesn't flag these,
even though the doc of `-Waddress-of-packed-member` says that it usually
leads to UB. In contrast, x86_64 Clang does flag these, which renders
the 64-bit kernel unable to boot.

For now, the `address-of-packed-member` warning will only be enabled in
the kernel, as it is absolutely crucial there because of KUBSAN, but
might get excessively noisy for the userland in the future.

Also note that we can't append to `CMAKE_CXX_FLAGS` like we do for other
flags in the kernel, because flags added via `add_compile_options` come
after these, so the `-Wno-address-of-packed-member` in the root would
cancel it out.
2021-08-08 10:55:36 +02:00
..
AddressSpace.cpp Kernel: Remove unused Process pointer in Memory::AddressSpace 2021-08-08 00:03:45 +02:00
AddressSpace.h Kernel: Remove unused Process pointer in Memory::AddressSpace 2021-08-08 00:03:45 +02:00
AllocationStrategy.h Kernel: Rename Kernel/VM/ to Kernel/Memory/ 2021-08-06 14:05:58 +02:00
AnonymousVMObject.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
AnonymousVMObject.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
InodeVMObject.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
InodeVMObject.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
MappedROM.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
MemoryManager.cpp Kernel: Fix UB caused by taking a reference to a packed struct's member 2021-08-08 10:55:36 +02:00
MemoryManager.h Kernel: Move SpinLock.h into Locking/ 2021-08-07 11:48:00 +02:00
PageDirectory.cpp Everywhere: Replace AK::Singleton => Singleton 2021-08-08 00:03:45 +02:00
PageDirectory.h Kernel: Make identity mapping mechanism used during AP boot non-generic 2021-08-06 21:35:56 +02:00
PageFaultResponse.h Kernel: Rename Kernel/VM/ to Kernel/Memory/ 2021-08-06 14:05:58 +02:00
PhysicalPage.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
PhysicalPage.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
PhysicalRegion.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
PhysicalRegion.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
PhysicalZone.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
PhysicalZone.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
PrivateInodeVMObject.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
PrivateInodeVMObject.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
ProcessPagingScope.cpp Kernel: Rename Kernel/VM/ to Kernel/Memory/ 2021-08-06 14:05:58 +02:00
ProcessPagingScope.h Kernel: Rename Kernel/VM/ to Kernel/Memory/ 2021-08-06 14:05:58 +02:00
Region.cpp Kernel: Rename a very long enum to ShouldDeallocateVirtualRange 2021-08-06 21:45:05 +02:00
Region.h Kernel: Add convenience values to the Memory::Region::Access enum 2021-08-06 22:25:00 +02:00
RingBuffer.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
RingBuffer.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
ScatterGatherList.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
ScatterGatherList.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
SharedInodeVMObject.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
SharedInodeVMObject.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
TypedMapping.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
VirtualRange.cpp Kernel: Rename Range => VirtualRange 2021-08-06 14:05:58 +02:00
VirtualRange.h Kernel: Rename Range => VirtualRange 2021-08-06 14:05:58 +02:00
VirtualRangeAllocator.cpp Kernel: Rename Range => VirtualRange 2021-08-06 14:05:58 +02:00
VirtualRangeAllocator.h Kernel: Move SpinLock.h into Locking/ 2021-08-07 11:48:00 +02:00
VMObject.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
VMObject.h Kernel: Move Mutex into Locking/ 2021-08-07 11:48:00 +02:00