diff --git a/config/examples/sparc64_rules.xml b/config/examples/sparc64_rules.xml index eb15e59..e282fdb 100644 --- a/config/examples/sparc64_rules.xml +++ b/config/examples/sparc64_rules.xml @@ -38,10 +38,6 @@ CFLAGS+= -Wundef -Wendif-labels -Wstrict-aliasing -Wwrite-strings -Wmissing-prot INCLUDES := -I$(SRCDIR)/include -I$(SRCDIR)/kernel/include -I$(ODIR)/target/include AS_FLAGS := -Wa,-xarch=v9b -Wa,-64 -g -ifeq ($(shell uname), OpenBSD) - CFLAGS+= -fno-stack-protector -endif - # # pre rules # diff --git a/include/libc/string.h b/include/libc/string.h index be81cab..53054a2 100644 --- a/include/libc/string.h +++ b/include/libc/string.h @@ -99,4 +99,9 @@ static inline unsigned char __toupper(unsigned char c) { extern int errno_int; +// Propolice support +extern long __guard[8]; + +void __stack_smash_handler(const char *func, int damaged); + #endif /* _H_STRING */ diff --git a/libc/misc.c b/libc/misc.c index 01a8d2f..d9c00d6 100644 --- a/libc/misc.c +++ b/libc/misc.c @@ -75,3 +75,24 @@ strtol( const char *nptr, char **endptr, int base ) return sum * sign; } + +// Propolice support +long __guard[8] = { +#ifdef CONFIG_BIG_ENDIAN + (0 << 24) | (0 << 16) | ('\n' << 8) | 255, +#else + (255 << 24) | ('\n' << 16) | (0 << 8) | 0, +#endif + 0, 0, 0, 0, 0, 0, 0 +}; + +void __stack_smash_handler(const char *func, int damaged) +{ + printk("Propolice detected a stack smashing attack %x at function %s," + " freezing\n", damaged, func); + + // Freeze + // XXX: Disable interrupts? + for(;;) + ; +}