From 436b38fd89fe4324d2342084ef477a7a8809a001 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 26 Mar 2023 12:49:32 +0300 Subject: libcamera: Open files with O_CLOEXEC Files opened internally in libcamera without the O_CLOEXEC file will remain open upon a call to one of the exec(3) functions. As exec() doesn't destroy local or global objects, this can lead to various side effects. Avoid this by opening file descriptors with O_CLOEXEC for all internal files. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/raspberrypi/dma_heaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libcamera/pipeline/raspberrypi') diff --git a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp index 6b644406..317b1fc1 100644 --- a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp +++ b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp @@ -37,7 +37,7 @@ namespace RPi { DmaHeap::DmaHeap() { for (const char *name : heapNames) { - int ret = ::open(name, O_RDWR, 0); + int ret = ::open(name, O_RDWR | O_CLOEXEC, 0); if (ret < 0) { ret = errno; LOG(RPI, Debug) << "Failed to open " << name << ": " -- cgit v1.2.1