summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-08 11:50:09 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-08 11:50:09 +0100
commitfe44d10437a3508f62ac21e03cd712aba0c1683b (patch)
tree96c049d0412f097c7dffb2ba31b3f118ea903fb5
parent477b65fe9d50014273f9f2357bdeb2dc82693db2 (diff)
Kernel: Protect region from 0 to 512.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
-rw-r--r--Private/NewKit/Json.hpp2
-rw-r--r--Private/Source/PageManager.cxx6
2 files changed, 6 insertions, 2 deletions
diff --git a/Private/NewKit/Json.hpp b/Private/NewKit/Json.hpp
index d52f1d4a..1c404397 100644
--- a/Private/NewKit/Json.hpp
+++ b/Private/NewKit/Json.hpp
@@ -56,7 +56,7 @@ struct JsonStreamTraits final {
for (SizeT i = 1; i < len; i++) {
if (full_array[i] == ' ') continue;
- JsonType type(255, 255);
+ JsonType type(kPathLen, kPathLen);
if (probe_key) {
type.AsKey().Data()[key_len] = full_array[i];
diff --git a/Private/Source/PageManager.cxx b/Private/Source/PageManager.cxx
index d6455a18..7dec0343 100644
--- a/Private/Source/PageManager.cxx
+++ b/Private/Source/PageManager.cxx
@@ -10,6 +10,9 @@
#include <KernelKit/DebugOutput.hpp>
#include <NewKit/PageManager.hpp>
+//! null deref will throw (Page Zero detected, aborting program!)
+#define kProtectedRegionEnd 512
+
namespace HCore {
PTEWrapper::PTEWrapper(Boolean Rw, Boolean User, Boolean ExecDisable,
UIntPtr VirtAddr)
@@ -23,11 +26,12 @@ PTEWrapper::PTEWrapper(Boolean Rw, Boolean User, Boolean ExecDisable,
m_Present(true),
m_Accessed(false) {
// special case for the null region.
- if (VirtAddr == 0) {
+ if (VirtAddr <= kProtectedRegionEnd) {
m_Wt = false;
m_Rw = false;
m_Cache = false;
m_Shareable = false;
+ m_ExecDisable = true;
}
}