[openib-general] [PATCH 7/7] IB/ipath - performance improvements via mmap of queues
Roland Dreier
rdreier at cisco.com
Mon Aug 14 09:25:36 PDT 2006
> +/*
> + * ipath_vma_nopage - handle a VMA page fault.
> + */
> +static struct page *ipath_vma_nopage(struct vm_area_struct *vma,
> + unsigned long address, int *type)
> +{
> + struct ipath_mmap_info *ip = vma->vm_private_data;
> + unsigned long offset = address - vma->vm_start;
> + struct page *page = NOPAGE_SIGBUS;
> + void *pageptr;
> +
> + if (offset >= ip->size)
> + goto out; /* out of range */
> +
> + /*
> + * Convert the vmalloc address into a struct page.
> + */
> + pageptr = (void *)(offset + (vma->vm_pgoff << PAGE_SHIFT));
> + page = vmalloc_to_page(pageptr);
> + if (!page)
> + goto out;
> +
> + /* Increment the reference count. */
> + get_page(page);
> + if (type)
> + *type = VM_FAULT_MINOR;
> +out:
> + return page;
> +}
> +
> +static struct vm_operations_struct ipath_vm_ops = {
> + .open = ipath_vma_open,
> + .close = ipath_vma_close,
> + .nopage = ipath_vma_nopage,
> +};
It seems that all this would be much simpler with vmalloc_user() and
remap_vmalloc_range(). And it would fix the information leak you
introduce here: I don't see anywhere that you clear the memory you
vmalloc and remap to userspace, so you're potentially exposing the
cached contents of /etc/passwd or something like that.
- R.
More information about the general
mailing list