From 859e741322ac7c6023b5e8aac4e7eb6e763e54ab Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 29 Mar 2026 19:42:25 +0800 Subject: [PATCH] crimson/osd: use O_CLOEXEC with pipe2() in get_early_config Without O_CLOEXEC the pipe fds are inherited across any future exec() calls. While the child in get_early_config does not exec, using O_CLOEXEC is standard practice to prevent inadvertent fd leaks into subprocesses spawned later in the OSD lifetime. Signed-off-by: Kefu Chai --- src/crimson/osd/main_config_bootstrap_helpers.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/crimson/osd/main_config_bootstrap_helpers.cc b/src/crimson/osd/main_config_bootstrap_helpers.cc index b701247ae7ff..158e33d26130 100644 --- a/src/crimson/osd/main_config_bootstrap_helpers.cc +++ b/src/crimson/osd/main_config_bootstrap_helpers.cc @@ -22,7 +22,8 @@ #include "crimson/mon/MonClient.h" #include "crimson/net/Messenger.h" -#include // for waitpid() +#include +#include using namespace std::literals; using crimson::common::local_conf; @@ -286,7 +287,7 @@ get_early_config(int argc, const char *argv[]) exit(0); } int pipes[2]; - int r = pipe2(pipes, 0); + int r = pipe2(pipes, O_CLOEXEC); if (r < 0) { std::cerr << "get_early_config: failed to create pipes: " << -errno << std::endl; -- 2.47.3