]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commit
crush: Fix segfault in update_from_hook
authorAdam Kupczyk <akupczyk@redhat.com>
Tue, 16 Nov 2021 12:33:28 +0000 (13:33 +0100)
committerAdam Kupczyk <akupczyk@redhat.com>
Tue, 16 Nov 2021 13:04:31 +0000 (14:04 +0100)
commit35e7fd4808bc9be7046332db588437e6446859bf
tree1f62c78ef1a67f6939aca3939f06eb341134887e
parent343708fb6e81809bc67c4123821474a28b23c2b7
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 <akupczyk@redhat.com>
src/common/entity_name.cc
src/common/entity_name.h