]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: use O_CLOEXEC with pipe2() in get_early_config 68223/head
authorKefu Chai <k.chai@proxmox.com>
Sun, 29 Mar 2026 11:42:25 +0000 (19:42 +0800)
committerKefu Chai <k.chai@proxmox.com>
Mon, 6 Apr 2026 12:33:36 +0000 (20:33 +0800)
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 <k.chai@proxmox.com>
src/crimson/osd/main_config_bootstrap_helpers.cc

index b701247ae7ffc2deed83c683c0baf78ff2179b54..158e33d261303b6c5a00601884dcbedcfc397ee3 100644 (file)
@@ -22,7 +22,8 @@
 #include "crimson/mon/MonClient.h"
 #include "crimson/net/Messenger.h"
 
-#include <sys/wait.h> // for waitpid()
+#include <fcntl.h>
+#include <sys/wait.h>
 
 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;