Skip to contentSkip to conversation

fork,random: use get_random_canary() to set tsk->stack_canary

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

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 66/96 fork,random: use get_random_canary() to set tsk->stack_canary

From: Rik van Riel <[email protected]>
Subject: fork,random: use get_random_canary() to set tsk->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.

---

 kernel/fork.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/fork.c renamed from kernel/fork.c~forkrandom-use-get_random_canary-to-set-tsk-stack_canary +1 -1
diff -puN kernel/fork.c~forkrandom-use-get_random_canary-to-set-tsk-stack_canary kernel/fork.c
@@ -554,7 +554,7 @@ static struct task_struct *dup_task_stru
 	set_task_stack_end_magic(tsk);
 
 #ifdef CONFIG_CC_STACKPROTECTOR
-	tsk->stack_canary = get_random_long();
+	tsk->stack_canary = get_random_canary();
 #endif
 
 	/*

_