Skip to content

Commit

Permalink
Fix up mmap of /dev/kmem
Browse files Browse the repository at this point in the history
This leaves the issue of whether we should deprecate the whole thing (or
if we should check the whole mmap range, for that matter) open. Just do
the minimal fix for now.
  • Loading branch information
Linus Torvalds committed Aug 13, 2005
1 parent 2da5bf8 commit 4bb8255
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,22 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)

static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
{
unsigned long long val;
unsigned long pfn;

/* Turn a kernel-virtual address into a physical page frame */
pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT;

/*
* RED-PEN: on some architectures there is more mapped memory
* than available in mem_map which pfn_valid checks
* for. Perhaps should add a new macro here.
*
* RED-PEN: vmalloc is not supported right now.
*/
if (!pfn_valid(vma->vm_pgoff))
if (!pfn_valid(pfn))
return -EIO;
val = (u64)vma->vm_pgoff << PAGE_SHIFT;
vma->vm_pgoff = __pa(val) >> PAGE_SHIFT;

vma->vm_pgoff = pfn;
return mmap_mem(file, vma);
}

Expand Down

0 comments on commit 4bb8255

Please sign in to comment.