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] [day] [month] [year] [list]
Message-ID: <tip-92c77f7c4d5dfaaf45b2ce19360e69977c264766@git.kernel.org>
Date:   Thu, 28 Mar 2019 06:16:09 -0700
From:   tip-bot for Ralph Campbell <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     rcampbell@...dia.com, linux@...elenboom.it,
        boris.ostrovsky@...cle.com, mchehab@...pensource.com,
        linux-kernel@...r.kernel.org, hans.verkuil@...co.com,
        mingo@...nel.org, tglx@...utronix.de, craigb@...gle.com,
        hpa@...or.com, torvalds@...ux-foundation.org, sean@...s.org,
        fengguang.wu@...el.com, peterz@...radead.org,
        gregkh@...uxfoundation.org
Subject: [tip:x86/urgent] x86/mm: Don't exceed the valid physical address
 space

Commit-ID:  92c77f7c4d5dfaaf45b2ce19360e69977c264766
Gitweb:     https://git.kernel.org/tip/92c77f7c4d5dfaaf45b2ce19360e69977c264766
Author:     Ralph Campbell <rcampbell@...dia.com>
AuthorDate: Mon, 25 Mar 2019 17:18:17 -0700
Committer:  Thomas Gleixner <tglx@...utronix.de>
CommitDate: Thu, 28 Mar 2019 14:13:51 +0100

x86/mm: Don't exceed the valid physical address space

valid_phys_addr_range() is used to sanity check the physical address range
of an operation, e.g., access to /dev/mem. It uses __pa(high_memory)
internally.

If memory is populated at the end of the physical address space, then
__pa(high_memory) is outside of the physical address space because:

   high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;

For the comparison in valid_phys_addr_range() this is not an issue, but if
CONFIG_DEBUG_VIRTUAL is enabled, __pa() maps to __phys_addr(), which
verifies that the resulting physical address is within the valid physical
address space of the CPU. So in the case that memory is populated at the
end of the physical address space, this is not true and triggers a
VIRTUAL_BUG_ON().

Use __pa(high_memory - 1) to prevent the conversion from going beyond
the end of valid physical addresses.

Fixes: be62a3204406 ("x86/mm: Limit mmap() of /dev/mem to valid physical addresses")
Signed-off-by: Ralph Campbell <rcampbell@...dia.com>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Craig Bergstrom <craigb@...gle.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Boris Ostrovsky <boris.ostrovsky@...cle.com>
Cc: Fengguang Wu <fengguang.wu@...el.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Hans Verkuil <hans.verkuil@...co.com>
Cc: Mauro Carvalho Chehab <mchehab@...pensource.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Sander Eikelenboom <linux@...elenboom.it>
Cc: Sean Young <sean@...s.org>

Link: https://lkml.kernel.org/r/20190326001817.15413-2-rcampbell@nvidia.com

---
 arch/x86/mm/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index db3165714521..dc726e07d8ba 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -230,7 +230,7 @@ bool mmap_address_hint_valid(unsigned long addr, unsigned long len)
 /* Can we access it for direct reading/writing? Must be RAM: */
 int valid_phys_addr_range(phys_addr_t addr, size_t count)
 {
-	return addr + count <= __pa(high_memory);
+	return addr + count - 1 <= __pa(high_memory - 1);
 }
 
 /* Can we access it through mmap? Must be a valid physical address: */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ