Skip to contentSkip to conversation

sh64: ascii armor the sh64 boot init stack canary

PATCH New [email protected] 1 participant 1 message Jul 12, 2017 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 69/96 sh64: ascii armor the sh64 boot init stack canary

From: Rik van Riel <[email protected]>
Subject: sh64: ascii armor the sh64 boot init stack canary

Use the ascii-armor canary to prevent unterminated C string overflows from being able to successfully overwrite the canary, even if they somehow obtain the canary value.

Inspired by execshield ascii-armor and Daniel Micay's linux-hardened tree.

---

 arch/sh/include/asm/stackprotector.h |    1 +
 1 file changed, 1 insertion(+)
arch/sh/include/asm/stackprotector.h renamed from arch/sh/include/asm/stackprotector.h~sh64-ascii-armor-the-sh64-boot-init-stack-canary +1 -0
diff -puN arch/sh/include/asm/stackprotector.h~sh64-ascii-armor-the-sh64-boot-init-stack-canary arch/sh/include/asm/stackprotector.h
@@ -19,6 +19,7 @@ static __always_inline void boot_init_st
 	/* Try to get a semi random initial value. */
 	get_random_bytes(&canary, sizeof(canary));
 	canary ^= LINUX_VERSION_CODE;
+	canary &= CANARY_MASK;
 
 	current->stack_canary = canary;
 	__stack_chk_guard = current->stack_canary;

_