From: Christoph Lameter <clameter@sgi.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
Cc: travis@sgi.com
Subject: [patch 6/6] x86: Add checks for virtual addresses in __phys_addr()
Date: Fri, 09 May 2008 19:09:53 -0700 [thread overview]
Message-ID: <20080510021021.472932504@sgi.com> (raw)
In-Reply-To: 20080510020947.803480649@sgi.com
[-- Attachment #1: vcp_check_virtual_addresses --]
[-- Type: text/plain, Size: 1831 bytes --]
Add checks to insure that virtual addresses are not used in invalid contexts.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
arch/x86/mm/ioremap.c | 15 +++++++--------
include/asm-x86/page_32.h | 7 ++++++-
2 files changed, 13 insertions(+), 9 deletions(-)
Index: linux-2.6/arch/x86/mm/ioremap.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/ioremap.c 2008-05-07 16:27:09.792659191 -0700
+++ linux-2.6/arch/x86/mm/ioremap.c 2008-05-07 19:46:34.733509101 -0700
@@ -21,29 +21,28 @@
#include <asm/pgalloc.h>
#include <asm/pat.h>
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_X86_64)
unsigned long __phys_addr(unsigned long x)
{
+ VM_BUG_ON(is_vmalloc_addr((void *)x));
+#ifdef CONFIG_X86_64
if (x >= __START_KERNEL_map)
return x - __START_KERNEL_map + phys_base;
+#endif
return x - PAGE_OFFSET;
}
EXPORT_SYMBOL(__phys_addr);
+#endif
static inline int phys_addr_valid(unsigned long addr)
{
+#ifdef CONFIG_X86_64
return addr < (1UL << boot_cpu_data.x86_phys_bits);
-}
-
#else
-
-static inline int phys_addr_valid(unsigned long addr)
-{
return 1;
-}
-
#endif
+}
int page_is_ram(unsigned long pagenr)
{
Index: linux-2.6/include/asm-x86/page_32.h
===================================================================
--- linux-2.6.orig/include/asm-x86/page_32.h 2008-05-07 16:27:12.191419001 -0700
+++ linux-2.6/include/asm-x86/page_32.h 2008-05-07 19:30:46.444980299 -0700
@@ -64,7 +64,12 @@ typedef struct page *pgtable_t;
#endif
#ifndef __ASSEMBLY__
-#define __phys_addr(x) ((x) - PAGE_OFFSET)
+#ifdef CONFIG_DEBUG_VM
+unsigned long __phys_addr(unsigned long x)
+#else
+#define __phys_addr(x) ((x) - PAGE_OFFSET)
+#endif
+
#define __phys_reloc_hide(x) RELOC_HIDE((x), 0)
#ifdef CONFIG_FLATMEM
--
next prev parent reply other threads:[~2008-05-10 2:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-10 2:09 [patch 0/6] x86: Unification patches etc Christoph Lameter
2008-05-10 2:09 ` [patch 1/6] x86: Unify current.h Christoph Lameter
2008-05-13 12:28 ` Ingo Molnar
2008-05-10 2:09 ` [patch 2/6] x86: e820.h unification Christoph Lameter
2008-05-10 2:09 ` [patch 3/6] x86: e820 unification: Extract shared comments Christoph Lameter
2008-05-10 2:09 ` [patch 4/6] x86: e820 unification: Common #ifdef __ASSEMBLY Christoph Lameter
2008-05-10 2:09 ` [patch 5/6] x86: e820 unification: Extract common functions Christoph Lameter
2008-05-10 2:09 ` Christoph Lameter [this message]
2008-05-10 2:23 ` [patch 6/6] x86: Add checks for virtual addresses in __phys_addr() Sam Ravnborg
2008-05-10 2:33 ` Christoph Lameter
2008-05-10 3:07 ` Christoph Lameter
2008-05-13 12:27 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080510021021.472932504@sgi.com \
--to=clameter@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.