Title: [9142] trunk/arch/blackfin/kernel/process.c: Fix bug[#6254] [#5805] access_ok: check address range accross border properly.
Revision
9142
Author
sonicz
Date
2010-09-16 04:37:37 -0400 (Thu, 16 Sep 2010)

Log Message

Fix bug[#6254] [#5805] access_ok: check address range accross border properly.

When init section is released to kernel memory management system, it may
be merged into the same buddy block if it is adjacent to generic
allocable memory region. In this case, an address range may across the
border. 

Modified Paths

Diff

Modified: trunk/arch/blackfin/kernel/process.c (9141 => 9142)


--- trunk/arch/blackfin/kernel/process.c	2010-09-15 06:14:52 UTC (rev 9141)
+++ trunk/arch/blackfin/kernel/process.c	2010-09-16 08:37:37 UTC (rev 9142)
@@ -454,8 +454,22 @@
 	if (0)
 #endif
 	{
-		if (in_mem(addr, size, memory_start, memory_end))
-			return 1;
+		/* When init section is released to kernel memory management system,
+		 * it may be merged into the same buddy block if it is adjacent to
+		 * generic allocable memory region. In this case, an address range
+		 * may across the border.
+		 */
+		if (__init_end == memory_start)
+			if (in_mem(addr, size, (unsigned long)__init_begin, (unsigned long)memory_end))
+				return 1;
+		else {
+			if (in_mem(addr, size, memory_start, memory_end))
+				return 1;
+
+			if (in_mem(addr, size, (unsigned long)__init_begin, (unsigned long)__init_end))
+				return 1;
+		}
+
 		if (in_mem(addr, size, memory_mtd_end, physical_mem_end))
 			return 1;
 # ifndef CONFIG_ROMFS_ON_MTD
@@ -465,13 +479,23 @@
 			if (in_mem(addr, size, memory_mtd_start, memory_mtd_end))
 				return 1;
 	} else {
-		if (in_mem(addr, size, memory_start, physical_mem_end))
-			return 1;
+		/* When init section is released to kernel memory management system,
+		 * it may be merged into the same buddy block if it is adjacent to
+		 * generic allocable memory region. In this case, an address range
+		 * may across the border.
+		 */
+		if (__init_end == memory_start)
+			if (in_mem(addr, size, (unsigned long)__init_begin, (unsigned long)physical_mem_end))
+				return 1;
+		else {
+			if (in_mem(addr, size, memory_start, physical_mem_end))
+				return 1;
+
+			if (in_mem(addr, size, (unsigned long)__init_begin, (unsigned long)__init_end))
+				return 1;
+		}
 	}
 
-	if (in_mem(addr, size, (unsigned long)__init_begin, (unsigned long)__init_end))
-		return 1;
-
 	if (in_mem_const(addr, size, L1_CODE_START, L1_CODE_LENGTH))
 		return 1;
 	if (in_mem_const_off(addr, size, _etext_l1 - _stext_l1, L1_CODE_START, L1_CODE_LENGTH))
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to