On Sat, Apr 26, 2008 at 10:15:33AM -0700, Linus Torvalds wrote:OK. Below is the quick to disable /dev/mem mmap of RAM with PAT. This should go along with Ingo's patch that removes PAT dependency on NONPROMISC_DEVMEM. It makes things safer and eliminates aliasing. Still somewhat unclean as the range_is_allowed is duplicated. And also, just compile tested right now. Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> --- arch/x86/mm/pat.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) Index: linux-2.6/arch/x86/mm/pat.c =================================================================== --- linux-2.6.orig/arch/x86/mm/pat.c 2008-04-26 09:34:31.000000000 -0700 +++ linux-2.6/arch/x86/mm/pat.c 2008-04-26 11:25:57.000000000 -0700 @@ -16,6 +16,7 @@ #include <asm/msr.h> #include <asm/tlbflush.h> #include <asm/processor.h> +#include <asm/page.h> #include <asm/pgtable.h> #include <asm/pat.h> #include <asm/e820.h> @@ -477,6 +478,33 @@ pgprot_t phys_mem_access_prot(struct fil return vma_prot; } +#ifdef CONFIG_NONPROMISC_DEVMEM +/* This check is done in drivers/char/mem.c in case of NONPROMISC_DEVMEM*/ +static inline int range_is_allowed(unsigned long pfn, unsigned long size) +{ + return 1; +} +#else +static inline int range_is_allowed(unsigned long pfn, unsigned long size) +{ + u64 from = ((u64)pfn) << PAGE_SHIFT; + u64 to = from + size; + u64 cursor = from; + + while (cursor < to) { + if (!devmem_is_allowed(pfn)) { + printk(KERN_INFO + "Program %s tried to access /dev/mem between %Lx->%Lx.\n", + current->comm, from, to); + return 0; + } + cursor += PAGE_SIZE; + pfn++; + } + return 1; +} +#endif /* CONFIG_NONPROMISC_DEVMEM */ + int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, unsigned long size, pgprot_t *vma_prot) { @@ -485,6 +513,9 @@ int phys_mem_access_prot_allowed(struct unsigned long ret_flags; int retval; + if (!range_is_allowed(pfn, size)) + return 0; + if (file->f_flags & O_SYNC) { flags = _PAGE_CACHE_UC; } --
| jmerkey | [ANNOUNCE] mdb: Merkey's Linux Kernel Debugger 2.6.27-rc4 released |
| Valdis.Kletnieks | Re: [RFC/PATCH] Documentation of kernel messages |
| Greg Kroah-Hartman | [PATCH 004/196] Chinese: add translation of SubmittingPatches |
| Christoph Lameter | [04/14] vcompound: Core piece |
git: | |
| Ken Pratt | pack operation is thrashing my server |
| Peter Stahlir | Git as a filesystem |
| Kyle Moffett | Using GIT to store /etc (Or: How to make GIT store all file permission bits) |
| Francis Moreau | What about git cp ? |
| Richard Stallman | Real men don't attack straw men |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Girish Venkatachalam | Ethernet jumbo frames? |
| L. V. Lammert | Re: How to find all package files |
| Christoph Hellwig | Re: silent semantic changes with reiser4 |
| Al Boldi | Re: [RFD] Incremental fsck |
| Jens Axboe | Re: [PATCH][RFC] fast file mapping for loop |
| Ian Kent | Re: [PATCH 2/4] autofs4 - track uid and gid of last mount requester |
