summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Lee Irwin III <wli@holomorphy.com>2005-05-26 22:43:11 -0700
committerChris Wright <chrisw@osdl.org>2005-06-11 19:45:21 -0700
commit43cdfc5ea9a5c7b7904dd040370f6655951412f0 (patch)
tree50c7a0cb88185a6b0a2dcc3cca1074b2135e6857
parentc27d379fe5e7a0709fdb63eeaec5c7c848747d8a (diff)
downloadlinux-stable-43cdfc5ea9a5c7b7904dd040370f6655951412f0.tar.gz
linux-stable-43cdfc5ea9a5c7b7904dd040370f6655951412f0.tar.bz2
linux-stable-43cdfc5ea9a5c7b7904dd040370f6655951412f0.zip
[PATCH] try_to_unmap_cluster() passes out-of-bounds pte to pte_unmap()
try_to_unmap_cluster() does: for (pte = pte_offset_map(pmd, address); address < end; pte++, address += PAGE_SIZE) { ... } pte_unmap(pte); It may take a little staring to notice, but pte can actually fall off the end of the pte page in this iteration, which makes life difficult for kmap_atomic() and the users not expecting it to BUG(). Of course, we're somewhat lucky in that arithmetic elsewhere in the function guarantees that at least one iteration is made, lest this force larger rearrangements to be made. This issue and patch also apply to non-mm mainline and with trivial adjustments, at least two related kernels. Discovered during internal testing at Oracle. Signed-off-by: William Irwin <wli@holomorphy.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Chris Wright <chrisw@osdl.org>
-rw-r--r--mm/rmap.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mm/rmap.c b/mm/rmap.c
index 4ff8183fa18e..895a454820b6 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -641,7 +641,7 @@ static void try_to_unmap_cluster(unsigned long cursor,
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
- pte_t *pte;
+ pte_t *pte, *original_pte;
pte_t pteval;
struct page *page;
unsigned long address;
@@ -673,7 +673,7 @@ static void try_to_unmap_cluster(unsigned long cursor,
if (!pmd_present(*pmd))
goto out_unlock;
- for (pte = pte_offset_map(pmd, address);
+ for (original_pte = pte = pte_offset_map(pmd, address);
address < end; pte++, address += PAGE_SIZE) {
if (!pte_present(*pte))
@@ -710,7 +710,7 @@ static void try_to_unmap_cluster(unsigned long cursor,
(*mapcount)--;
}
- pte_unmap(pte);
+ pte_unmap(original_pte);
out_unlock:
spin_unlock(&mm->page_table_lock);