aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/dma-buf-sharing.txt
diff options
context:
space:
mode:
authorRob Clark <rob@ti.com>2012-03-19 17:42:49 -0400
committerSumit Semwal <sumit.semwal@ti.com>2012-03-26 02:03:22 -0400
commitfbb231e1a98cb0360b681b6a6195a619e98d7077 (patch)
treec7a3bd8975fc2d6a7e2ab25df02402a489b350ac /Documentation/dma-buf-sharing.txt
parentb0b40f24848440aa65418532fe97d8d46acceb3d (diff)
dma-buf: document fd flags and O_CLOEXEC requirement
Otherwise subsystems will get this wrong and end up with a second export ioctl with the flag and O_CLOEXEC support added. Signed-off-by: Rob Clark <rob@ti.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Diffstat (limited to 'Documentation/dma-buf-sharing.txt')
-rw-r--r--Documentation/dma-buf-sharing.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/Documentation/dma-buf-sharing.txt b/Documentation/dma-buf-sharing.txt
index 9f3aeeffd608..3bbd5c51605a 100644
--- a/Documentation/dma-buf-sharing.txt
+++ b/Documentation/dma-buf-sharing.txt
@@ -319,6 +319,24 @@ Miscellaneous notes
319- Any exporters or users of the dma-buf buffer sharing framework must have 319- Any exporters or users of the dma-buf buffer sharing framework must have
320 a 'select DMA_SHARED_BUFFER' in their respective Kconfigs. 320 a 'select DMA_SHARED_BUFFER' in their respective Kconfigs.
321 321
322- In order to avoid fd leaks on exec, the FD_CLOEXEC flag must be set
323 on the file descriptor. This is not just a resource leak, but a
324 potential security hole. It could give the newly exec'd application
325 access to buffers, via the leaked fd, to which it should otherwise
326 not be permitted access.
327
328 The problem with doing this via a separate fcntl() call, versus doing it
329 atomically when the fd is created, is that this is inherently racy in a
330 multi-threaded app[3]. The issue is made worse when it is library code
331 opening/creating the file descriptor, as the application may not even be
332 aware of the fd's.
333
334 To avoid this problem, userspace must have a way to request O_CLOEXEC
335 flag be set when the dma-buf fd is created. So any API provided by
336 the exporting driver to create a dmabuf fd must provide a way to let
337 userspace control setting of O_CLOEXEC flag passed in to dma_buf_fd().
338
322References: 339References:
323[1] struct dma_buf_ops in include/linux/dma-buf.h 340[1] struct dma_buf_ops in include/linux/dma-buf.h
324[2] All interfaces mentioned above defined in include/linux/dma-buf.h 341[2] All interfaces mentioned above defined in include/linux/dma-buf.h
342[3] https://lwn.net/Articles/236486/