From patchwork Fri May 16 09:35:20 2014
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Xiubo Li
X-Patchwork-Id: 4189911
Return-Path:
X-Original-To: patchwork-linux-arm@patchwork.kernel.org
Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org
Received: from mail.kernel.org (mail.kernel.org [198.145.19.201])
by patchwork2.web.kernel.org (Postfix) with ESMTP id 1DFBEBFF02
for ;
Fri, 16 May 2014 10:28:24 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id 507A5202E9
for ;
Fri, 16 May 2014 10:28:23 +0000 (UTC)
Received: from bombadil.infradead.org (bombadil.infradead.org
[198.137.202.9])
(using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 746A920295
for ;
Fri, 16 May 2014 10:28:21 +0000 (UTC)
Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org)
by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux))
id 1WlFKi-0005rN-Ad; Fri, 16 May 2014 10:25:44 +0000
Received: from mail-bn1lp0140.outbound.protection.outlook.com
([207.46.163.140] helo=na01-bn1-obe.outbound.protection.outlook.com)
by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat
Linux)) id 1WlFKe-0005hR-Nr
for linux-arm-kernel@lists.infradead.org;
Fri, 16 May 2014 10:25:41 +0000
Received: from DM2PR03CA008.namprd03.prod.outlook.com (10.141.52.156) by
DM2PR03MB509.namprd03.prod.outlook.com (10.141.87.12) with Microsoft
SMTP Server (TLS) id 15.0.944.11; Fri, 16 May 2014 10:25:17 +0000
Received: from BY2FFO11FD049.protection.gbl (2a01:111:f400:7c0c::185) by
DM2PR03CA008.outlook.office365.com (2a01:111:e400:2414::28) with
Microsoft SMTP Server (TLS) id 15.0.944.11 via Frontend Transport;
Fri, 16 May 2014 10:25:17 +0000
Received: from az84smr01.freescale.net (192.88.158.2) by
BY2FFO11FD049.mail.protection.outlook.com (10.1.15.186) with
Microsoft SMTP Server (TLS) id 15.0.939.9 via Frontend Transport;
Fri, 16 May 2014 10:25:16 +0000
Received: from rock.ap.freescale.net (rock.ap.freescale.net [10.193.20.106])
by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id
s4GAM2eA028751; Fri, 16 May 2014 03:22:04 -0700
From: Xiubo Li
To: , ,
, ,
, ,
Subject: [PATCH v3] arm: ioremap: Fix static vm area boundary check.
Date: Fri, 16 May 2014 17:35:20 +0800
Message-ID: <1400232920-25079-1-git-send-email-Li.Xiubo@freescale.com>
X-Mailer: git-send-email 1.8.0
X-EOPAttributedMessage: 0
X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI;
SFV:NSPM;
SFS:(6009001)(199002)(189002)(83322001)(19580405001)(99396002)(77096999)(6806004)(44976005)(50226001)(83072002)(4396001)(31966008)(19580395003)(74662001)(69596002)(68736004)(84676001)(74502001)(102836001)(97736001)(50986999)(81542001)(92566001)(87936001)(21056001)(92726001)(79102001)(87286001)(77156001)(81156002)(86362001)(50466002)(89996001)(20776003)(81342001)(80022001)(36756003)(85852003)(76482001)(77982001)(46102001)(48376002)(47776003)(62966002)(64706001)(2101003);
DIR:OUT; SFP:; SCL:1; SRVR:DM2PR03MB509; H:az84smr01.freescale.net;
FPR:;
MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en;
MIME-Version: 1.0
X-Forefront-PRVS: 02135EB356
Received-SPF: Fail (: domain of freescale.com does not designate
192.88.158.2 as permitted sender) receiver=; client-ip=192.88.158.2;
helo=az84smr01.freescale.net;
Authentication-Results: spf=fail (sender IP is 192.88.158.2)
smtp.mailfrom=Li.Xiubo@freescale.com;
X-OriginatorOrg: freescale.com
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20140516_032540_986555_C92121E1
X-CRM114-Status: UNSURE ( 8.79 )
X-CRM114-Notice: Please train this message.
X-Spam-Score: -0.0 (/)
Cc: Xiubo Li , linux-kernel@vger.kernel.org
X-BeenThere: linux-arm-kernel@lists.infradead.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id:
List-Unsubscribe:
,
List-Archive:
List-Post:
List-Help:
List-Subscribe:
,
Sender: "linux-arm-kernel"
Errors-To:
linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org
X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,
UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org
X-Virus-Scanned: ClamAV using ClamSMTP
For each vmalloc area, there is one guard page at the end of it.
so the vm->size = PAGE_ALIGN(offset + request size) + guard page size.
Signed-off-by: Richard Lee
Signed-off-by: Xiubo Li
Cc: Nicolas Pitre
Cc: Santosh Shilimkar
Cc: Joonsoo Kim
---
arch/arm/mm/ioremap.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index be69333..758e8f7 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -49,14 +49,18 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,
struct vm_struct *vm;
list_for_each_entry(svm, &static_vmlist, list) {
+ phys_addr_t paddr_end, phys_addr_end;
+
vm = &svm->vm;
if (!(vm->flags & VM_ARM_STATIC_MAPPING))
continue;
if ((vm->flags & VM_ARM_MTYPE_MASK) != VM_ARM_MTYPE(mtype))
continue;
- if (vm->phys_addr > paddr ||
- paddr + size - 1 > vm->phys_addr + vm->size - 1)
+ /* The PAGE_SIZE here is vmalloc area's guard page */
+ phys_addr_end = vm->phys_addr + vm->size - PAGE_SIZE - 1;
+ paddr_end = paddr + size - 1;
+ if (vm->phys_addr > paddr || paddr_end > phys_addr_end)
continue;
return svm;