From 86fd1ba48e52403cbd9fcf30f10e1e94e6afd43e Mon Sep 17 00:00:00 2001 From: Kenta Sato Date: Wed, 13 Apr 2022 20:14:57 +0900 Subject: [PATCH] Create an eventfd object with `EFD_CLOEXEC` flag The file descriptor `irq_notify_fd` does not have the close-on-exec (`FD_CLOEXEC`) flag so it possibly leaks to child processes. This adds an `EFD_CLOEXEC` flag to the second argument of the `exentfd(2)` call, which tells it to set an `FD_CLOEXEC` flag on the new file descriptor. Signed-off-by: Kenta Sato --- lib/system/linux/irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system/linux/irq.c b/lib/system/linux/irq.c index d687066..5d84ee0 100644 --- a/lib/system/linux/irq.c +++ b/lib/system/linux/irq.c @@ -219,7 +219,7 @@ int metal_linux_irq_init(void) memset(&irqs, 0, sizeof(irqs)); - irq_notify_fd = eventfd(0, 0); + irq_notify_fd = eventfd(0, EFD_CLOEXEC); if (irq_notify_fd < 0) { metal_log(METAL_LOG_ERROR, "Failed to create eventfd for IRQ handling.\n");