Re: [PATCH] Fix OOPS in mmap_region() when merging adjacentVM_LOCKED file segments

From: Lee Schermerhorn
Date: Thu Jan 29 2009 - 23:44:11 EST


On Thu, 2009-01-29 at 15:02 -0800, Linus Torvalds wrote:
>
> On Thu, 29 Jan 2009, Hugh Dickins wrote:
> >
> > The problem has always been that file->f_op->mmap(file, vma) on a
> > special file can do various strange things, changing surprising
> > fields of the struct vma passed to it, changing its mergeability.
>
> Ahh, you're right. That's somewhat bogus, but it does explain why we have
> those two separate merge_vma() calls.
>
> And as you also point out:
>
> > Now it may well be that every driver which does something strange
> > there already sets one of the VM_SPECIAL flags which prevent merging,
> > or can easily be fixed to do so, or otherwise clearly cannot pose a
> > problem.
>
> .. and I think this is the right answer. If a device driver really does
> something as odd as play games with the offset that would make merging
> wrong, it had better set some of the VM_SPECIAL bits (presumably VM_IO) in
> order to never merge at all.

Just want to note that install_special_mappings()--used for, e.g., the
vdso--sets VM_DONTEXPAND [one of the VM_SPECIAL flags] which, if we want
to prevent merging, makes a lot of sense to me. It appears that
get_user_pages() will balk at addresses in vmas with VM_IO [and
VM_PFNMAP] which might not be what one wants. For example, you can't
pre-populate the ptes via make_pages_present() with this flag.

Lee

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/