]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: fix dangling addrvec in SocketMessenger::bind(). 43192/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 16 Sep 2021 17:04:28 +0000 (17:04 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 16 Sep 2021 17:21:51 +0000 (17:21 +0000)
`SocketMessenger::bind()` takes the address vector by `const&`.
while the callers in `OSD` are passing a temporary:

  ```cpp
  cluster_msgr->bind(pick_addresses(CEPH_PICK_ADDRESS_CLUSTER))
    // ...
  public_msgr->bind(pick_addresses(CEPH_PICK_ADDRESS_PUBLIC))
    // ...
  ```

  ```cpp
  entity_addrvec_t pick_addresses(int what) {
    // ...
    return addrs;
  }
  ```

The net result is a life-time mismatch and crashes like the following
one:

  ```
  WARN  2021-09-10 20:01:57,791 [shard 0] ms - [osd.0(client) v2:172.17.0.1:6800/3172806564@59988 >> mgr.? v2:172.17.0.7:6800/3846062660] waiting 3.2 seconds ...
  /opt/rh/gcc-toolset-9/root/usr/include/c++/9/bits/stl_iterator.h:820:17: runtime error: reference binding to misaligned address 0x000041b58ab3 for type 'const struct entity_addr_t', which requires 4 byte alignment
  0x000041b58ab3: note: pointer points here
  <memory cannot be printed>
  /opt/rh/gcc-toolset-9/root/usr/include/c++/9/bits/stl_vector.h:1132:16: runtime error: reference binding to misaligned address 0x000041b58ab3 for type 'const struct value_type', which requires 4 byte alignment
  0x000041b58ab3: note: pointer points here
  <memory cannot be printed>
  /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos8/DIST/centos8/MACHINE_SIZE/gigantic/release/17.0.0-7486-g27cb19ed/rpm/el8/BUILD/ceph-17.0.0-7486-g27cb19ed/src/msg/msg_types.h:561:22: runtime error: reference binding to misaligned address 0x000041b58ab3 for type 'const struct entity_addr_t', which requires 4 byte alignment
  0x000041b58ab3: note: pointer points here
  <memory cannot be printed>
  Segmentation fault on shard 0.
  ```

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/net/SocketMessenger.cc

index 6a339fb981dfd01a404a44914fe7521e47848924..13af0434a0f95a497083db78bc279246cd8ffe7c 100644 (file)
@@ -134,7 +134,7 @@ SocketMessenger::bind(const entity_addrvec_t& addrs)
 {
   using crimson::common::local_conf;
   return seastar::do_with(int64_t{local_conf()->ms_bind_retry_count},
-                          [this, &addrs] (auto& count) {
+                          [this, addrs] (auto& count) {
     return seastar::repeat_until_value([this, &addrs, &count] {
       assert(count >= 0);
       return try_bind(addrs,