Stack protector
This commit is contained in:
parent
0960df714d
commit
3c732f27db
3 changed files with 21 additions and 3 deletions
1
Makefile
1
Makefile
|
|
@ -18,6 +18,7 @@ VISOR_SOURCES_x86_64 := \
|
||||||
VISOR_SOURCES := \
|
VISOR_SOURCES := \
|
||||||
src/alloc.c \
|
src/alloc.c \
|
||||||
src/efi.c \
|
src/efi.c \
|
||||||
|
src/ssp.c \
|
||||||
src/strlcpy.c \
|
src/strlcpy.c \
|
||||||
$(VISOR_SOURCES_$(ARCH)) \
|
$(VISOR_SOURCES_$(ARCH)) \
|
||||||
# end of sources list
|
# end of sources list
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ ARCH = x86_64
|
||||||
CROSS_PATH = /usr/bin
|
CROSS_PATH = /usr/bin
|
||||||
|
|
||||||
# C Compiler & Linker commands
|
# C Compiler & Linker commands
|
||||||
CC = gcc
|
CC = $(CROSS_PATH)/$(ARCH)-linux-gcc
|
||||||
LD = ld
|
LD = $(CROSS_PATH)/$(ARCH)-linux-ld
|
||||||
|
|
||||||
# Compilation flags
|
# Compilation flags
|
||||||
CFLAGS = -std=c17 -Wall -ffreestanding -fpic -nostdlib -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -mno-sse -mno-mmx -mno-80387
|
CFLAGS = -std=c17 -Wall -ffreestanding -fpic -nostdlib -fstack-protector-all -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -mno-sse -mno-mmx -mno-80387
|
||||||
CPPFLAGS = -Ignuefi/inc -Iinclude
|
CPPFLAGS = -Ignuefi/inc -Iinclude
|
||||||
LDFLAGS = -shared -Bsymbolic -Lgnuefi -Tgnuefi/elf_$(ARCH)_efi.lds -nostdlib
|
LDFLAGS = -shared -Bsymbolic -Lgnuefi -Tgnuefi/elf_$(ARCH)_efi.lds -nostdlib
|
||||||
LIBS = -lgnuefi -lefi
|
LIBS = -lgnuefi -lefi
|
||||||
|
|
|
||||||
17
src/ssp.c
Normal file
17
src/ssp.c
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <efi.h>
|
||||||
|
#include <efilib.h>
|
||||||
|
|
||||||
|
#define STACK_CHK_GUARD 0x595e9fbd94fda766
|
||||||
|
|
||||||
|
uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
|
||||||
|
|
||||||
|
_Noreturn void
|
||||||
|
__stack_chk_fail(void)
|
||||||
|
{
|
||||||
|
Print(L"stack smashing detected");
|
||||||
|
for (;;) {
|
||||||
|
__asm__ ("cli\n\thlt\n\t" ::);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue