+ fstack-protector-feature-add-the-canary-field-to-the.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     -fstack-protector feature: Add the canary field to the PDA area

has been added to the -mm tree.  Its filename is

     fstack-protector-feature-add-the-canary-field-to-the.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: -fstack-protector feature: Add the canary field to the PDA area
From: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>

This patch adds the per thread cookie field to the task struct and the PDA. 
Also it makes sure that the PDA value gets the new cookie value at context
switch, and that a new task gets a new cookie at task creation time.

Signed-off-by: Arjan van Ven <arjan@xxxxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>
Cc: Andi Kleen <ak@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 arch/x86_64/kernel/process.c |    8 ++++++++
 include/asm-x86_64/pda.h     |    6 +++++-
 include/linux/sched.h        |    5 +++++
 kernel/fork.c                |    5 +++++
 4 files changed, 23 insertions(+), 1 deletion(-)

diff -puN arch/x86_64/kernel/process.c~fstack-protector-feature-add-the-canary-field-to-the arch/x86_64/kernel/process.c
--- a/arch/x86_64/kernel/process.c~fstack-protector-feature-add-the-canary-field-to-the
+++ a/arch/x86_64/kernel/process.c
@@ -625,6 +625,14 @@ __switch_to(struct task_struct *prev_p, 
 	unlazy_fpu(prev_p);
 	write_pda(kernelstack,
 		  task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET);
+#ifdef CONFIG_CC_STACKPROTECTOR
+	write_pda(stack_canary, next_p->stack_canary);
+	/*
+	 * Build time only check to make sure the stack_canary is at
+	 * offset 40 in the pda; this is a gcc ABI requirement
+	 */
+	BUILD_BUG_ON(offsetof(struct x8664_pda, stack_canary) != 40);
+#endif
 
 	/*
 	 * Now maybe reload the debug registers and handle I/O bitmaps
diff -puN include/asm-x86_64/pda.h~fstack-protector-feature-add-the-canary-field-to-the include/asm-x86_64/pda.h
--- a/include/asm-x86_64/pda.h~fstack-protector-feature-add-the-canary-field-to-the
+++ a/include/asm-x86_64/pda.h
@@ -14,7 +14,11 @@ struct x8664_pda {
 	unsigned long kernelstack;	/* 16 */  /* top of kernel stack for current */
 	unsigned long oldrsp;		/* 24 */  /* user rsp for system call */
 	unsigned long debugstack;	/* 32 */  /* #DB/#BP stack. */
-	int irqcount;			/* 40 */  /* Irq nesting counter. Starts with -1 */
+#ifdef CONFIG_CC_STACKPROTECTOR
+	unsigned long stack_canary;	/* 40 */  /* stack canary value */
+					/* gcc-ABI: this canary MUST be at offset 40!!! */
+#endif
+	int irqcount;			/* 48 */  /* Irq nesting counter. Starts with -1 */
 	int cpunumber;		    /* Logical CPU number */
 	char *irqstackptr;	/* top of irqstack */
 	int nodenumber;		    /* number of current node */
diff -puN include/linux/sched.h~fstack-protector-feature-add-the-canary-field-to-the include/linux/sched.h
--- a/include/linux/sched.h~fstack-protector-feature-add-the-canary-field-to-the
+++ a/include/linux/sched.h
@@ -819,6 +819,11 @@ struct task_struct {
 	unsigned did_exec:1;
 	pid_t pid;
 	pid_t tgid;
+
+#ifdef CONFIG_CC_STACKPROTECTOR
+	/* Canary value for the -fstack-protector gcc feature */
+	unsigned long stack_canary;
+#endif
 	/* 
 	 * pointers to (original) parent process, youngest child, younger sibling,
 	 * older sibling, respectively.  (p->father can be replaced with 
diff -puN kernel/fork.c~fstack-protector-feature-add-the-canary-field-to-the kernel/fork.c
--- a/kernel/fork.c~fstack-protector-feature-add-the-canary-field-to-the
+++ a/kernel/fork.c
@@ -45,6 +45,7 @@
 #include <linux/cn_proc.h>
 #include <linux/delayacct.h>
 #include <linux/taskstats_kern.h>
+#include <linux/random.h>
 
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
@@ -174,6 +175,10 @@ static struct task_struct *dup_task_stru
 	tsk->thread_info = ti;
 	setup_thread_stack(tsk, orig);
 
+#ifdef CONFIG_CC_STACKPROTECTOR
+	tsk->stack_canary = get_random_int();
+#endif
+
 	/* One for us, one for whoever does the "release_task()" (usually parent) */
 	atomic_set(&tsk->usage,2);
 	atomic_set(&tsk->fs_excl, 0);
_

Patches currently in -mm which might be from arjan@xxxxxxxxxxxxxxx are

git-netdev-all.patch
lockdep-fix-sk_dst_check-deadlock.patch
fstack-protector-feature-annotate-the-pda-offsets.patch
fstack-protector-feature-add-the-kconfig-option.patch
fstack-protector-feature-add-the-canary-field-to-the.patch
fstack-protector-feature-add-the-__stack_chk_fail.patch
fstack-protector-feature-enable-the-compiler-flags.patch
slab-fix-lockdep-warnings.patch
slab-fix-lockdep-warnings-fix.patch
slab-fix-lockdep-warnings-fix-2.patch
sleazy-fpu-feature-i386-support.patch
make-prot_write-imply-prot_read.patch
lockdep-dont-pull-in-includes-when-lockdep-disabled.patch
lockdep-print-kernel-version.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux