Title: [8936] trunk/fs/binfmt_flat.c: [!no_src_qa!]
Revision
8936
Author
bhsong
Date
2010-06-23 06:25:41 -0400 (Wed, 23 Jun 2010)

Log Message

[!no_src_qa!]
bug [#6034], fix wrong memory mapping while using L1 stack

we do mmap before we adjust stack_len to bigger, then some stack area is not covered by
page table(including argv, env and some data).
In fact, this bug should cause problems to both MPU and non-MPU. For non-MPU, that
means a process will touch the memory of other processes or something else.

Modified Paths

Diff

Modified: trunk/fs/binfmt_flat.c (8935 => 8936)


--- trunk/fs/binfmt_flat.c	2010-06-23 09:43:05 UTC (rev 8935)
+++ trunk/fs/binfmt_flat.c	2010-06-23 10:25:41 UTC (rev 8936)
@@ -534,6 +534,26 @@
 	/*
 	 * calculate the extra space we need to map in
 	 */
+	if (flags & FLAT_FLAG_L1STK) {
+#ifdef CONFIG_SMP
+		flags &= ~FLAT_FLAG_L1STK;
+		printk(KERN_NOTICE "BINFMT_FLAT: L1 stack is not supported in SMP kernel.\n");
+#else
+		if (stack_base == 0) {
+			printk("BINFMT_FLAT: requesting L1 stack for shared library\n");
+			ret = -ENOEXEC;
+			goto err;
+		}
+		stack_len = alloc_l1stack(stack_len, stack_base);
+		if (stack_len == 0) {
+			printk("BINFMT_FLAT: stack size with arguments exceeds scratchpad memory\n");
+			ret = -ENOMEM;
+			goto err;
+		}
+		*extra_stack = stack_len;
+#endif
+	}
+
 	extra = max_t(unsigned long, bss_len + stack_len,
 			relocs * sizeof(unsigned long));
 
@@ -805,26 +825,6 @@
 	
 	flush_icache_range(start_code, end_code);
 
-	if (flags & FLAT_FLAG_L1STK) {
-#ifdef CONFIG_SMP
-		flags &= ~FLAT_FLAG_L1STK;
-		printk(KERN_NOTICE "BINFMT_FLAT: L1 stack is not supported in SMP kernel.\n");
-#else
-		if (stack_base == 0) {
-			printk("BINFMT_FLAT: requesting L1 stack for shared library\n");
-			ret = -ENOEXEC;
-			goto err;
-		}
-		stack_len = alloc_l1stack(stack_len, stack_base);
-		if (stack_len == 0) {
-			printk("BINFMT_FLAT: stack size with arguments exceeds scratchpad memory\n");
-			ret = -ENOMEM;
-			goto err;
-		}
-		*extra_stack = stack_len;
-#endif
-	}
-
 	/* zero the BSS,  BRK and stack areas */
 	memset((void*)(datapos + data_len), 0, bss_len + 
 			(memp + memp_size - stack_len -		/* end brk */
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to