[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1328902796-30389-1-git-send-email-danms@us.ibm.com>
Date: Fri, 10 Feb 2012 11:39:56 -0800
From: Dan Smith <danms@...ibm.com>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: [PATCH] Ensure that walk_page_range()'s start and end are page-aligned
The inner function walk_pte_range() increments "addr" by PAGE_SIZE after
each pte is processed, and only exits the loop if the result is equal to
"end". Current, if either (or both of) the starting or ending addresses
passed to walk_page_range() are not page-aligned, then we will never
satisfy that exit condition and begin calling the pte_entry handler with
bad data.
To be sure that we will land in the right spot, this patch checks that
both "addr" and "end" are page-aligned in walk_page_range() before starting
the traversal.
Signed-off-by: Dan Smith <danms@...ibm.com>
Cc: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org
---
mm/pagewalk.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index 2f5cf10..9242bfc 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -196,6 +196,8 @@ int walk_page_range(unsigned long addr, unsigned long end,
if (addr >= end)
return err;
+ VM_BUG_ON((addr & ~PAGE_MASK) || (end & ~PAGE_MASK));
+
if (!walk->mm)
return -EINVAL;
--
1.7.9
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists