1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:07:34 +00:00

Kernel: Make Region weakable and use WeakPtr<Region> instead of Region*

This turns use-after-free bugs into null pointer dereferences instead.
This commit is contained in:
Andreas Kling 2020-02-24 13:24:30 +01:00
parent 79576f9280
commit 30a8991dbf
5 changed files with 14 additions and 8 deletions

View file

@ -28,6 +28,7 @@
#include <AK/InlineLinkedList.h>
#include <AK/String.h>
#include <AK/Weakable.h>
#include <Kernel/Heap/SlabAllocator.h>
#include <Kernel/VM/RangeAllocator.h>
@ -41,7 +42,9 @@ enum class PageFaultResponse {
Continue,
};
class Region final : public InlineLinkedListNode<Region> {
class Region final
: public InlineLinkedListNode<Region>
, public Weakable<Region> {
friend class MemoryManager;
MAKE_SLAB_ALLOCATED(Region)