]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: do not unload plugins during destruction. 40795/head
authorWillem Jan Withagen <wjw@digiware.nl>
Sun, 11 Apr 2021 13:01:22 +0000 (15:01 +0200)
committerWillem Jan Withagen <wjw@digiware.nl>
Mon, 12 Apr 2021 08:27:02 +0000 (10:27 +0200)
FreeBSD ceph-dencoder crashes in the exit() calls, due to
invalid pointer references during the release process of
the loaded libraries.

Often this is signaled by libc reporting:
  __cxa_thread_call_dtors: dtr 0x47efc0 from unloaded dso, skipping

The cause for this is different behaviour between FreeBSD and Linux:
https://groups.google.com/g/bsdmailinglist/c/22ncTZAbDp4/m/Dii_pII5AwAJ
_The FreeBSD implementation here looks racy. If one thread dlcloses an
object while another thread is exiting, we can end up calling a
function at an invalid memory address. It also looks as if it may
be possible to unload one library, load another at the same address,
and end up executing entirely the wrong code, which would have some
serious security implications.

The GNU/Linux equivalent of this function locks the DSO in memory
until all references to it have gone away. A call to dlclose() on
GNU/Linux will not actually unload the library until all threads
with destructors in that library have been unloaded. I believe
that this reuses the same reference counting mechanism that
allows the same library to be dlopened and dlclosed multiple times.

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
src/tools/ceph-dencoder/ceph_dencoder.cc

index ccf51575c738cf4f14266bb0f8fbc43a4c265db8..effcfa41ee95eabaf5e2e70060a1fae18a82a2e1 100644 (file)
@@ -75,9 +75,11 @@ public:
     }
   }
   ~DencoderPlugin() {
+#if !defined(__FreeBSD__)
     if (mod) {
       dlclose(mod);
     }
+#endif
   }
   int register_dencoders() {
     assert(mod);