syscall #17
@@ -6,7 +6,7 @@ SOURCES := $(shell find src -name '*.c')
|
||||
OBJFILES := $(patsubst $(SRC)/%.c, $(BUILDDIR)/%.o, $(SOURCES))
|
||||
|
||||
CC := x86_64-elf-gcc
|
||||
CC_FLAGS=-Wall -Wextra -std=gnu99 -nostdlib -ffreestanding -fno-stack-protector -fno-omit-frame-pointer -fno-stack-check -fno-PIC -ffunction-sections -fdata-sections -mcmodel=kernel
|
||||
CC_FLAGS=-Wall -Wextra -std=gnu99 -nostdlib -ffreestanding -fstack-protector -fno-omit-frame-pointer -fno-stack-check -fno-PIC -ffunction-sections -fdata-sections -mcmodel=kernel
|
||||
CC_PROBLEMATIC_FLAGS=-Wno-unused-parameter -Wno-unused-variable
|
||||
|
||||
LD := x86_64-elf-ld
|
||||
|
||||
@@ -55,4 +55,7 @@
|
||||
/* time */
|
||||
#define TIMER_FREQUENCY 1000
|
||||
|
||||
/* ssp */
|
||||
#define STACK_CHK_GUARD 0x7ABA5C007ABA5C00
|
||||
|
||||
#endif
|
||||
|
||||
+16
-1
@@ -12,6 +12,15 @@
|
||||
#include <kernel.h>
|
||||
#include <time/date.h>
|
||||
|
||||
__attribute__((noinline))
|
||||
void smash_it()
|
||||
{
|
||||
char buf[16]; (void)buf;
|
||||
for (size_t i=0; i<256; i++) {
|
||||
buf[i] = (char)i;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* pedicel_main - Kernel shell main function
|
||||
* @arg: argument (optional)
|
||||
@@ -38,7 +47,8 @@ void pedicel_main(void* arg)
|
||||
"panic - trigger a test panic\r\n"
|
||||
"syscall - trigger int 0x80\r\n"
|
||||
"pf - trigger a page fault\r\n"
|
||||
"now - get current date\r\n");
|
||||
"now - get current date\r\n"
|
||||
"smash - smash the stack\r\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -64,6 +74,11 @@ void pedicel_main(void* arg)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(input_buf, "smash", 5) == 0) {
|
||||
smash_it();
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%s: command not found\r\n", input_buf);
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,15 @@ void thing_main(void* arg)
|
||||
|
||||
extern uintptr_t kheap_start;
|
||||
|
||||
/* Stack Smashing Protection */
|
||||
|
||||
uint64_t __stack_chk_guard = STACK_CHK_GUARD;
|
||||
|
||||
void __stack_chk_fail(void)
|
||||
{
|
||||
panic(NULL, "SSP: Stask Smashing Detected!!! (very spicy)");
|
||||
}
|
||||
|
||||
/*
|
||||
* kmain - Kernel entry point
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user