libcamera: dma_buf_allocator: Create memfd with CLOEXEC

Ensure that the memfd file descriptor won't be leaked to child processes
by creating it with MFD_CLOEXEC.

Fixes: ea4baaacc3 ("libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2024-06-05 10:30:55 +03:00
parent 98071d3109
commit 9c2ca46391

View file

@ -132,7 +132,7 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size)
std::size_t pageMask = sysconf(_SC_PAGESIZE) - 1; std::size_t pageMask = sysconf(_SC_PAGESIZE) - 1;
size = (size + pageMask) & ~pageMask; 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) { if (ret < 0) {
ret = errno; ret = errno;
LOG(DmaBufAllocator, Error) LOG(DmaBufAllocator, Error)