<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    [SNIP]<br>
    <blockquote type="cite" cite="mid:fc8f2af7-9fc2-cb55-3065-75a4060b7c82@amd.com"> But Jason
      pointed me to the right piece of code. See this comment in in
      mmap_region():<br>
      <br>
      <blockquote type="cite">
        <pre>             <span class="cm">/* ->mmap() can change vma->vm_file, but must guarantee that</span>
<span class="cm">                * vma_link() below can deny write-access if VM_DENYWRITE is set</span>
<span class="cm">                * and map writably if VM_SHARED is set. This usually means the</span>
<span class="cm">                * new file must not have been exposed to user-space, yet.</span>
<span class="cm">                */</span>
                <span class="n"><a href="https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/vma" moz-do-not-send="true">vma</a></span><span class="o">-></span><span class="n"><a href="https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/vm_file" moz-do-not-send="true">vm_file</a></span> <span class="o">=</span> <span class="n"><a href="https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/get_file" moz-do-not-send="true">get_file</a></span><span class="p">(</span><span class="n"><a href="https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/file" moz-do-not-send="true">file</a></span><span class="p">);</span>
                <span class="n">error</span> <span class="o">=</span> <span class="n"><a href="https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/call_mmap" moz-do-not-send="true">call_mmap</a></span><span class="p">(</span><span class="n"><a href="https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/file" moz-do-not-send="true">file</a></span><span class="p">,</span> <span class="n"><a href="https://elixir.bootlin.com/linux/v5.9-rc5/C/ident/vma" moz-do-not-send="true">vma</a></span><span class="p">);</span></pre>
      </blockquote>
      <br>
      So changing vma->vm_file is allowed at least under certain
      circumstances.<br>
      <br>
      Only the "file must not have been exposed to user-space, yet" part
      still needs double checking. Currently working on that.<br>
    </blockquote>
    <br>
    Ok, I think we can guarantee for all DMA-bufs what is required here.<br>
    <br>
    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.<br>
    <br>
    So I'm leaning towards that this works as expected and we should
    just document this properly.<br>
    <br>
    Daniel and Jason what do you think?<br>
    <br>
    Christian.<br>
  </body>
</html>