[PATCH] libcamera: dma_buf_allocator: Create memfd with CLOEXEC
Kieran Bingham
kieran.bingham at ideasonboard.com
Wed Jun 5 10:10:35 CEST 2024
Quoting Laurent Pinchart (2024-06-05 08:50:55)
> Ensure that the memfd file descriptor won't be leaked to child processes
> by creating it with MFD_CLOEXEC.
>
> Fixes: ea4baaacc325 ("libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf")
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Oh yeah, we hit this before...
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
> src/libcamera/dma_buf_allocator.cpp | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp
> index 5ae517210adf..5ec29949c66a 100644
> --- a/src/libcamera/dma_buf_allocator.cpp
> +++ b/src/libcamera/dma_buf_allocator.cpp
> @@ -132,7 +132,7 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size)
> std::size_t pageMask = sysconf(_SC_PAGESIZE) - 1;
> size = (size + pageMask) & ~pageMask;
>
> - int ret = memfd_create(name, MFD_ALLOW_SEALING);
> + int ret = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
> if (ret < 0) {
> ret = errno;
> LOG(DmaBufAllocator, Error)
>
> base-commit: 98071d3109c131820439f61d9380c0bd4cd2119a
> --
> Regards,
>
> Laurent Pinchart
>
More information about the libcamera-devel
mailing list