From ce98400f8a9ebd4e62e76b9e292b7598d0d66cc0 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 2 Apr 2021 23:26:28 +0200 Subject: Added kernel section clear/protect after init This is a huge security improvement as it prevents potential exploits of using or modifying internal kernel functions or data. --- libs/libc/inc/def.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'libs/libc/inc/def.h') diff --git a/libs/libc/inc/def.h b/libs/libc/inc/def.h index 583a351..f1201b9 100644 --- a/libs/libc/inc/def.h +++ b/libs/libc/inc/def.h @@ -23,7 +23,7 @@ typedef unsigned long long u64; * Macros */ -#define UNUSED(__a) ((void)(__a)) +#define UNUSED(a) ((void)(a)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) @@ -32,6 +32,7 @@ typedef unsigned long long u64; #define ATTR __attribute__ #define NORETURN ATTR((noreturn)) +#define NOINLINE ATTR((noinline)) #define DEPRECATED ATTR((deprecated)) #define NONNULL ATTR((nonnull)) #define PURE ATTR((pure)) @@ -44,7 +45,11 @@ typedef unsigned long long u64; #define UNUSED_FUNC ATTR((unused)) #define NO_SANITIZE ATTR((no_sanitize("undefined"))) #define ALIGNED(align) ATTR((aligned(align))) -#define SECTION(section) ATTR((section(section))) + +#ifdef KERNEL +#define CLEAR NOINLINE ATTR((section(".temp_clear"))) +#define PROTECTED ATTR((section(".temp_protect"))) +#endif #define EOF (-1) #define NULL ((void *)0) -- cgit v1.2.3