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/print.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'libs/libc/print.c') diff --git a/libs/libc/print.c b/libs/libc/print.c index b77c165..4c38cdc 100644 --- a/libs/libc/print.c +++ b/libs/libc/print.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -145,7 +144,7 @@ int log(const char *format, ...) return len; } -int err(int code, const char *format, ...) +NORETURN void err(int code, const char *format, ...) { if (errno != EOK) log("ERRNO: %d (%s)\n", errno, strerror(errno)); @@ -154,7 +153,6 @@ int err(int code, const char *format, ...) vfprintf(PATH_ERR, format, ap); va_end(ap); exit(code); - return -1; } int print(const char *str) @@ -251,10 +249,9 @@ NORETURN void panic(const char *format, ...) print("--- DON'T PANIC! ---\n"); print(buf); print_trace(5); - loop(); + while (1) + __asm__ volatile("cli\nhlt"); #else err(1, buf); #endif - while (1) - ; } -- cgit v1.2.3