ia64/linux-2.6.18-xen.hg

changeset 523:b9ec29696130

xen: Don't allow mapping foreign pages through /dev/kmem
since the mapping will fail and crash dom0.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
CC: Christian Limpach <christian.limpach@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 15 15:18:26 2008 +0100 (2008-04-15)
parents bb12908b737a
children 7f8b544237bf
files drivers/char/mem.c
line diff
     1.1 --- a/drivers/char/mem.c	Tue Apr 15 15:17:41 2008 +0100
     1.2 +++ b/drivers/char/mem.c	Tue Apr 15 15:18:26 2008 +0100
     1.3 @@ -264,6 +264,9 @@ static int mmap_mem(struct file * file, 
     1.4  static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
     1.5  {
     1.6  	unsigned long pfn;
     1.7 +#ifdef CONFIG_XEN
     1.8 +	unsigned long i, count;
     1.9 +#endif
    1.10  
    1.11  	/* Turn a kernel-virtual address into a physical page frame */
    1.12  	pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT;
    1.13 @@ -278,6 +281,13 @@ static int mmap_kmem(struct file * file,
    1.14  	if (!pfn_valid(pfn))
    1.15  		return -EIO;
    1.16  
    1.17 +#ifdef CONFIG_XEN
    1.18 +	count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
    1.19 +	for (i = 0; i < count; i++)
    1.20 +		if ((pfn + i) != mfn_to_local_pfn(pfn_to_mfn(pfn + i)))
    1.21 +			return -EIO;
    1.22 +#endif
    1.23 +
    1.24  	vma->vm_pgoff = pfn;
    1.25  	return mmap_mem(file, vma);
    1.26  }