From 35e7fd4808bc9be7046332db588437e6446859bf Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Tue, 16 Nov 2021 13:33:28 +0100 Subject: [PATCH] crush: Fix segfault in update_from_hook We create SubProcess to run script conf.crush_location_hook. We pass arguments via add_cmd_args(const char*, ...). One of the arguments, cct->_conf->name.get_type_str(), is string_view. x86-64-ABI states that when struct/class is passed by value, its fields are extracted to registers/pushed on stack. string_view is a class with fields: class basic_string_view { ... size_t _M_len; const _CharT* _M_str; }; As a result, a 7th parameter on stack (1st is `this` of SubProcess), is _M_len, but is it interpreted as char*, which leads to SIGSEGV. Fixes: https://tracker.ceph.com/issues/50659 Signed-off-by: Adam Kupczyk --- src/common/entity_name.cc | 2 +- src/common/entity_name.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/entity_name.cc b/src/common/entity_name.cc index 2eb24829a1c86..5357b34eacb7f 100644 --- a/src/common/entity_name.cc +++ b/src/common/entity_name.cc @@ -106,7 +106,7 @@ void EntityName::set_name(entity_name_t n) set(n.type(), s); } -std::string_view EntityName:: +const char* EntityName:: get_type_str() const { return ceph_entity_type_name(type); diff --git a/src/common/entity_name.h b/src/common/entity_name.h index 886c4b4946f8e..5e5ab111404a6 100644 --- a/src/common/entity_name.h +++ b/src/common/entity_name.h @@ -52,7 +52,7 @@ struct EntityName void set_id(std::string_view id_); void set_name(entity_name_t n); - std::string_view get_type_str() const; + const char* get_type_str() const; uint32_t get_type() const { return type; } bool is_osd() const { return get_type() == CEPH_ENTITY_TYPE_OSD; } -- 2.39.5