vppinfra: add CLOEXEC flag to memfd create calls 35/43835/3
authorPaul Ponchon <[email protected]>
Fri, 3 Oct 2025 14:23:10 +0000 (16:23 +0200)
committerDamjan Marion <[email protected]>
Wed, 8 Oct 2025 11:59:48 +0000 (11:59 +0000)
This commit adds a MFD_CLOEXEC flag to avoid memory leaks through child process
when VPP crashes.

Type: fix
Change-Id: Icd155102884f6e96bbe62149cc07f7cbfca77854
Signed-off-by: Paul Ponchon <[email protected]>
src/vppinfra/linux/mem.c

index 651ea10..bc7e047 100644 (file)
@@ -248,6 +248,10 @@ clib_mem_vm_create_fd (clib_mem_page_sz_t log2_page_size, char *fmt, ...)
       memfd_flags = MFD_HUGETLB | log2_page_size << MFD_HUGE_SHIFT;
     }
 
+  /* Set FD_CLOEXEC flag on memory file descriptor, such that mapped memory
+   * doesn't leak through child processes if VPP crashes. */
+  memfd_flags |= MFD_CLOEXEC;
+
   va_start (va, fmt);
   s = va_format (0, fmt, &va);
   va_end (va);