linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Ensure that walk_page_range()'s start and end are page-aligned
@ 2012-02-10 15:53 Dan Smith
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Smith @ 2012-02-10 15:53 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel

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@us.ibm.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 14+ messages in thread
* [PATCH] Ensure that walk_page_range()'s start and end are page-aligned
@ 2012-02-10 19:39 Dan Smith
  2012-02-10 19:45 ` Michal Nazarewicz
  2012-02-13 10:12 ` David Rientjes
  0 siblings, 2 replies; 14+ messages in thread
From: Dan Smith @ 2012-02-10 19:39 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel

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@us.ibm.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-02-24 21:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-10 15:53 [PATCH] Ensure that walk_page_range()'s start and end are page-aligned Dan Smith
  -- strict thread matches above, loose matches on Subject: below --
2012-02-10 19:39 Dan Smith
2012-02-10 19:45 ` Michal Nazarewicz
2012-02-10 19:57   ` Dan Smith
2012-02-10 20:13     ` Michal Nazarewicz
2012-02-13 10:12 ` David Rientjes
2012-02-13 14:52   ` Dan Smith
2012-02-13 21:55     ` David Rientjes
2012-02-14 14:59       ` Dan Smith
2012-02-14 21:04         ` David Rientjes
2012-02-15 14:39           ` Dan Smith
2012-02-24 19:19       ` Dan Smith
2012-02-24 20:55         ` Andrew Morton
2012-02-24 21:03           ` Dan Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).