lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 24 Feb 2012 11:19:25 -0800
From:	Dan Smith <danms@...ibm.com>
To:	akpm@...ux-foundation.org
Cc:	David Rientjes <rientjes@...gle.com>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, dave@...ux.vnet.ibm.com
Subject: Re: [PATCH] Ensure that walk_page_range()'s start and end are page-aligned

DR> but it doesn't "ensure" walk_page_range() always has start and end
DR> addresses that are page aligned

Below is a changed version of the patch which always does the
check. Since failing that condition indicates a kernel bug, WARN_ON()
makes sure it gets some visibility.

Andrew, can you take this?

-- 
Dan Smith
IBM Linux Technology Center
email: danms@...ibm.com

commit b06c2032d63f20d5a5513b3890776aeead397aa5
Author: Dan Smith <danms@...ibm.com>
Date:   Fri Feb 24 11:07:05 2012 -0800

    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

diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index 2f5cf10..97ee963 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -196,6 +196,11 @@ int walk_page_range(unsigned long addr, unsigned long end,
 	if (addr >= end)
 		return err;
 
+	if (WARN_ONCE((addr & ~PAGE_MASK) || (end & ~PAGE_MASK),
+		      "address range is not page-aligned")) {
+		return -EINVAL;
+	}
+
 	if (!walk->mm)
 		return -EINVAL;
 
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ