]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Revert "common/options: fix heap-use-after-free by using never-destroyed static" 67020/head
authorMatan Breizman <mbreizma@redhat.com>
Tue, 20 Jan 2026 13:35:40 +0000 (13:35 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 21 Jan 2026 12:43:50 +0000 (14:43 +0200)
```
Jan 20 09:27:16 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]: AddressSanitizer:DEADLYSIGNAL
Jan 20 09:27:16 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]: =================================================================
Jan 20 09:27:16 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]: ==3==ERROR: AddressSanitizer: stack-overflow on address 0x7b512f6c8dd8 (pc 0x0000046e7a72 bp 0x7b512de7c900 sp 0x7b512f6c8dd8 T0)
Jan 20 09:27:17 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]:     #0 0x0000046e7a72 in get_global_options() (/usr/bin/ceph-osd-crimson+0x46e7a72) (BuildId: 2a86043f51c9be9cb19801e276fb3ee36239556a)
Jan 20 09:27:17 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]:     #1 0x0000046e540e in build_options() (/usr/bin/ceph-osd-crimson+0x46e540e) (BuildId: 2a86043f51c9be9cb19801e276fb3ee36239556a)
Jan 20 09:27:17 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]:     #2 0x0000033b7949 in get_ceph_options() (/usr/bin/ceph-osd-crimson+0x33b7949) (BuildId: 2a86043f51c9be9cb19801e276fb3ee36239556a)
Jan 20 09:27:17 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]:     #3 0x000003440540 in md_config_t::md_config_t(ConfigValues&, ConfigTracker const&, bool) (/usr/bin/ceph-osd-crimson+0x3440540) (BuildId: 2a860>
Jan 20 09:27:17 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]:     #4 0x0000046856a8 in crimson::common::ConfigProxy::ConfigProxy(EntityName const&, std::basic_string_view<char, std::char_traits<char> >) (/usr>
Jan 20 09:27:17 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]:     #5 0x000000eb6cb5 in seastar::shared_ptr_count_for<crimson::common::ConfigProxy>::shared_ptr_count_for<EntityName&, std::__cxx11::basic_string>
..
Jan 20 09:27:17 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]:     #40 0x000000ed6434 in seastar::future<int> seastar::futurize<int>::apply<crimson::osd::_get_early_config(int, char const**)::{lambda()#1}::ope>
Jan 20 09:27:17 ceph-node-0 ceph-e818662e-f5e1-11f0-b263-525400908ba7-osd-1[12300]:     #41 0x000000ed672b in seastar::async<crimson::osd::_get_early_config(int, char const**)::{lambda()#1}::operator()() const::{lambda()#1}>(seast>
```

This reverts commit 1ab0a8cb726cb730954294423acec887b92fa5b0.

Fixes: https://tracker.ceph.com/issues/74481
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/common/ceph_context.cc
src/common/config.cc
src/common/options.cc
src/common/options.h
src/crimson/admin/admin_socket.cc
src/mon/ConfigMonitor.cc

index 5bb0b4678b76353d35e1fa91b9071fe11d0844f2..afd22f865437e8226448f6c1f347ae50e5b9cea5 100644 (file)
@@ -658,7 +658,7 @@ int CephContext::_do_command(
       } else {
         // Output all
         f->open_array_section("options");
-        for (const auto &option : get_ceph_options()) {
+        for (const auto &option : ceph_options) {
           f->dump_object("option", option);
         }
         f->close_section();
index 52071dbbe1902f257259154aec64e8cb7dfdd88b..f320fbd1cbccbd064a8d7c3ad86e83c403c96dae 100644 (file)
@@ -137,7 +137,7 @@ md_config_t::md_config_t(ConfigValues& values,
 {
   // Load the compile-time list of Option into
   // a map so that we can resolve keys quickly.
-  for (const auto &i : get_ceph_options()) {
+  for (const auto &i : ceph_options) {
     if (schema.count(i.name)) {
       // We may be instantiated pre-logging so send 
       std::cerr << "Duplicate config key in schema: '" << i.name << "'"
index 28e4941af4ed867e42d97645bd958c3d214031aa..bbac26e261cd82fda562b3192f0ff3bbcc2eb3a1 100644 (file)
@@ -338,9 +338,4 @@ void Option::print(ostream *out) const
   }
 }
 
-const std::vector<Option>& get_ceph_options() {
-  // Use a static pointer that's never destroyed to avoid use-after-free
-  // when background threads access options during program exit
-  static const std::vector<Option>* options = new std::vector<Option>(build_options());
-  return *options;
-}
+const std::vector<Option> ceph_options = build_options();
index c29d2e029fb4a454cb94cf72c73aed0668b86372..f99433464bcdbc7541a19c8e87bb76ea90ea5445 100644 (file)
@@ -434,4 +434,4 @@ constexpr unsigned long long operator""_T (unsigned long long n) {
   return n << 40;
 }
 
-const std::vector<Option>& get_ceph_options();
+extern const std::vector<Option> ceph_options;
index 9db62af2bdf4da31755bdc37befb31240d15f0b2..5a676d9214c10088364831e8c768d2b780af0fa3 100644 (file)
@@ -574,7 +574,7 @@ public:
     unique_ptr<Formatter> f{Formatter::create(format, "json-pretty", "json-pretty")};
     // Output all
     f->open_array_section("options");
-    for (const auto &option : get_ceph_options()) {
+    for (const auto &option : ceph_options) {
       f->dump_object("option", option);
     }
     f->close_section();
index 9b1f6a8aab5afa906e6444688ca828af03c3978c..7abd0c6818e9a98ce59f6348de9e30c875986bac 100644 (file)
@@ -219,7 +219,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op)
     if (f) {
       f->open_array_section("options");
     }
-    for (auto& i : get_ceph_options()) {
+    for (auto& i : ceph_options) {
       if (f) {
        f->dump_string("option", i.name);
       } else {