From 2ac97283d813414973f83d177280aafa7fbaa66f Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 8 Apr 2025 13:38:35 +0200 Subject: kernel, storage, heap, abi: lots of improvements and tweaks. - Please read the commit details for in-depth insights. - Add stack smash prevention code. - Better prevention in BitMap Mgr. Signed-off-by: Amlal El Mahrouss --- dev/kernel/src/BitMapMgr.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'dev/kernel/src/BitMapMgr.cc') diff --git a/dev/kernel/src/BitMapMgr.cc b/dev/kernel/src/BitMapMgr.cc index 7f3f8500..51c4aed1 100644 --- a/dev/kernel/src/BitMapMgr.cc +++ b/dev/kernel/src/BitMapMgr.cc @@ -141,7 +141,15 @@ namespace Kernel return (VoidPtr)ptr_bit_set; } - base = reinterpret_cast(reinterpret_cast(base) + ((ptr_bit_set[kBitMapMagIdx] != kBitMapMagic) ? (size + pad) : ptr_bit_set[kBitMapSizeIdx])); + UIntPtr raw_base = reinterpret_cast(base); + UIntPtr offset = (ptr_bit_set[kBitMapMagIdx] != kBitMapMagic) + ? (size + pad) + : ptr_bit_set[kBitMapSizeIdx]; + + base = reinterpret_cast(raw_base + offset); + + if (base == nullptr) + return nullptr; } return nullptr; -- cgit v1.2.3