+
+Delivered-To: eric.y.miao@gmail.com
+Received: by 10.229.89.5 with SMTP id c5cs439662qcm;
+ Fri, 18 Dec 2009 19:48:56 -0800 (PST)
+Received: by 10.220.122.229 with SMTP id m37mr3710050vcr.75.1261194536337;
+ Fri, 18 Dec 2009 19:48:56 -0800 (PST)
+Return-Path: <linux-arm-kernel-bounces+eric.y.miao=gmail.com@lists.infradead.org>
+Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34])
+ by mx.google.com with ESMTP id 15si5178130vws.113.2009.12.18.19.48.55;
+ Fri, 18 Dec 2009 19:48:56 -0800 (PST)
+Received-SPF: neutral (google.com: 18.85.46.34 is neither permitted nor denied by domain of linux-arm-kernel-bounces+eric.y.miao=gmail.com@lists.infradead.org) client-ip=18.85.46.34;
+Authentication-Results: mx.google.com; spf=neutral (google.com: 18.85.46.34 is neither permitted nor denied by domain of linux-arm-kernel-bounces+eric.y.miao=gmail.com@lists.infradead.org) smtp.mail=linux-arm-kernel-bounces+eric.y.miao=gmail.com@lists.infradead.org
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux))
+ id 1NLqHA-0005fo-Vx; Sat, 19 Dec 2009 03:46:40 +0000
+Received: from mho-01-ewr.mailhop.org ([204.13.248.71])
+ by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux))
+ id 1NLqH4-0005fB-Se for linux-arm-kernel@lists.infradead.org;
+ Sat, 19 Dec 2009 03:46:39 +0000
+Received: from c-67-160-239-110.hsd1.ca.comcast.net ([67.160.239.110]
+ helo=[127.0.0.1]) by mho-01-ewr.mailhop.org with esmtpa (Exim 4.68)
+ (envelope-from <tony@atomide.com>)
+ id 1NLqH4-000HuN-CC; Sat, 19 Dec 2009 03:46:34 +0000
+X-Mail-Handler: MailHop Outbound by DynDNS
+X-Originating-IP: 67.160.239.110
+X-Report-Abuse-To: abuse@dyndns.com (see
+ http://www.dyndns.com/services/mailhop/outbound_abuse.html for
+ abuse reporting information)
+X-MHO-User: U2FsdGVkX1+sI1hhEpkgqBCPoi5GTu+G
+Subject: [PATCH 4/5] arm: Fix init_atags_procfs() to check tag->hdr.size
+To: linux-arm-kernel@lists.infradead.org
+From: Tony Lindgren <tony@atomide.com>
+Date: Fri, 18 Dec 2009 19:46:30 -0800
+Message-ID: <20091219034630.26198.35713.stgit@localhost>
+In-Reply-To: <20091219034151.26198.26570.stgit@localhost>
+References: <20091219034151.26198.26570.stgit@localhost>
+User-Agent: StGit/0.15-6-gbbd0
+MIME-Version: 1.0
+X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) )
+ MR-646709E3
+X-CRM114-CacheID: sfid-20091218_224635_034795_3362075B
+X-CRM114-Status: GOOD ( 24.83 )
+X-Spam-Score: 0.0 (/)
+X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary:
+ Content analysis details: (0.0 points)
+ pts rule name description
+ ---- ----------------------
+ -------------------------------------------------- _SUMMARY_
+Cc: linux-omap@vger.kernel.org
+X-BeenThere: linux-arm-kernel@lists.infradead.org
+X-Mailman-Version: 2.1.12
+Precedence: list
+List-Id: <linux-arm-kernel.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>,
+ <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/>
+List-Post: <mailto:linux-arm-kernel@lists.infradead.org>
+List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,
+ <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+Sender: linux-arm-kernel-bounces@lists.infradead.org
+Errors-To: linux-arm-kernel-bounces+eric.y.miao=gmail.com@lists.infradead.org
+
+The tag->hdr.size cannot be larger than XXX.
+Otherwise we can getsomething similar during boot:
+
+Unable to handle kernel paging request at virtual address 61a05020
+...
+
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+---
+ arch/arm/include/asm/setup.h | 12 +++++++++---
+ arch/arm/kernel/atags.c | 2 +-
+ arch/arm/kernel/compat.c | 2 +-
+ arch/arm/kernel/setup.c | 4 ++--
+ arch/arm/mach-orion5x/common.c | 2 +-
+ 5 files changed, 14 insertions(+), 8 deletions(-)
+
+diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
+index 5ccce0a..3ca36bb 100644
+--- a/arch/arm/include/asm/setup.h
++++ b/arch/arm/include/asm/setup.h
+@@ -21,6 +21,11 @@
+ /* The list ends with an ATAG_NONE node. */
+ #define ATAG_NONE 0x00000000
+
++/* Some sanity checks are needed */
++#define ATAG_MAX_SZ PAGE_SIZE
++#define atag_valid(tag) \
++ ((tag)->hdr.size && ((tag)->hdr.size <= ATAG_MAX_SZ))
++
+ struct tag_header {
+ __u32 size;
+ __u32 tag;
+@@ -173,9 +178,10 @@ struct tagtable {
+ int (*parse)(const struct tag *);
+ };
+
+-#define tag_member_present(tag,member) \
+- ((unsigned long)(&((struct tag *)0L)->member + 1) \
+- <= (tag)->hdr.size * 4)
++#define tag_member_present(tag,member) \
++ (atag_valid(tag) && \
++ (((unsigned long)(&((struct tag *)0L)->member + 1) \
++ <= (tag)->hdr.size * 4))
+
+ #define tag_next(t) ((struct tag *)((__u32 *)(t) + (t)->hdr.size))
+ #define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
+diff --git a/arch/arm/kernel/atags.c b/arch/arm/kernel/atags.c
+index 42a1a14..14d0993 100644
+--- a/arch/arm/kernel/atags.c
++++ b/arch/arm/kernel/atags.c
+@@ -51,7 +51,7 @@ static int __init init_atags_procfs(void)
+ return -EINVAL;
+ }
+
+- for (; tag->hdr.size; tag = tag_next(tag))
++ for (; atag_valid(tag); tag = tag_next(tag))
+ ;
+
+ /* include the terminating ATAG_NONE */
+diff --git a/arch/arm/kernel/compat.c b/arch/arm/kernel/compat.c
+index 0a13854..3e63ee1 100644
+--- a/arch/arm/kernel/compat.c
++++ b/arch/arm/kernel/compat.c
+@@ -220,7 +220,7 @@ void __init convert_to_tag_list(struct tag *tags)
+
+ void __init squash_mem_tags(struct tag *tag)
+ {
+- for (; tag->hdr.size; tag = tag_next(tag))
++ for (; atag_valid(tag); tag = tag_next(tag))
+ if (tag->hdr.tag == ATAG_MEM)
+ tag->hdr.tag = ATAG_NONE;
+ }
+diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
+index c6c57b6..53d7181 100644
+--- a/arch/arm/kernel/setup.c
++++ b/arch/arm/kernel/setup.c
+@@ -556,7 +556,7 @@ request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
+ */
+ static int __init parse_tag_core(const struct tag *tag)
+ {
+- if (tag->hdr.size > 2) {
++ if ((atag_valid(tag) && (tag->hdr.size > 2))) {
+ if ((tag->u.core.flags & 1) == 0)
+ root_mountflags &= ~MS_RDONLY;
+ ROOT_DEV = old_decode_dev(tag->u.core.rootdev);
+@@ -660,7 +660,7 @@ static int __init parse_tag(const struct tag *tag)
+ */
+ static void __init parse_tags(const struct tag *t)
+ {
+- for (; t->hdr.size; t = tag_next(t))
++ for (; atag_valid(t); t = tag_next(t))
+ if (!parse_tag(t))
+ printk(KERN_WARNING
+ "Ignoring unrecognised tag 0x%08x\n",
+diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c
+index f87fa12..8afee34 100644
+--- a/arch/arm/mach-orion5x/common.c
++++ b/arch/arm/mach-orion5x/common.c
+@@ -717,7 +717,7 @@ void __init orion5x_init(void)
+ void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
+ char **from, struct meminfo *meminfo)
+ {
+- for (; t->hdr.size; t = tag_next(t))
++ for (; atag_valid(t); t = tag_next(t))
+ if (t->hdr.tag == ATAG_MEM &&
+ (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
+ t->u.mem.start & ~PAGE_MASK)) {
+
+
+_______________________________________________
+linux-arm-kernel mailing list
+linux-arm-kernel@lists.infradead.org
+http://lists.infradead.org/mailman/listinfo/linux-arm-kernel