Skip to contentSkip to conversation

arm64: ascii armor the arm64 boot init stack canary

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

lore
Share & tools
lore
#0 lore raw

PATCH 68/96 arm64: ascii armor the arm64 boot init stack canary

From: Rik van Riel <[email protected]>
Subject: arm64: ascii armor the arm64 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/arm64/include/asm/stackprotector.h |    1 +
 1 file changed, 1 insertion(+)
arch/arm64/include/asm/stackprotector.h renamed from arch/arm64/include/asm/stackprotector.h~arm64-ascii-armor-the-arm64-boot-init-stack-canary +1 -0
diff -puN arch/arm64/include/asm/stackprotector.h~arm64-ascii-armor-the-arm64-boot-init-stack-canary arch/arm64/include/asm/stackprotector.h
@@ -30,6 +30,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;

_