Skip to content

Commit

Permalink
Create an eventfd object with EFD_CLOEXEC flag, to avoid leaking fi…
Browse files Browse the repository at this point in the history
…le descriptor to child processes

The file descriptor `irq_notify_fd` does not have the close-on-exec (`FD_CLOEXEC`) flag so it possibly leaks to child processes.
This pull request 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.
  • Loading branch information
Tosainu committed Apr 13, 2022
1 parent d2555ab commit 55aa849
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/system/linux/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 55aa849

Please sign in to comment.