Changing vma->vm_file in dma_buf_mmap()
Christian König
christian.koenig at amd.com
Wed Sep 16 11:45:43 UTC 2020
[SNIP]
> But Jason pointed me to the right piece of code. See this comment in
> in mmap_region():
>
>> /* ->mmap() can change vma->vm_file, but must guarantee that
>> * vma_link() below can deny write-access if VM_DENYWRITE is set
>> * and map writably if VM_SHARED is set. This usually means the
>> * new file must not have been exposed to user-space, yet.
>> */
>> vma <https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/vma>->vm_file
>> <https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/vm_file> = get_file
>> <https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/get_file>(file
>> <https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/file>);
>> error = call_mmap
>> <https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/call_mmap>(file
>> <https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/file>, vma <https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/vma>);
>
> So changing vma->vm_file is allowed at least under certain circumstances.
>
> Only the "file must not have been exposed to user-space, yet" part
> still needs double checking. Currently working on that.
Ok, I think we can guarantee for all DMA-bufs what is required here.
While searching the code I've found that at least vgem_prime_mmap() and
i915_gem_dmabuf_mmap() are doing the same thing of modifying vma->vm_file.
So I'm leaning towards that this works as expected and we should just
document this properly.
Daniel and Jason what do you think?
Christian.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20200916/2da9ffee/attachment-0001.htm>
More information about the dri-devel
mailing list