]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
crush: Fix segfault in update_from_hook 44897/head
authorAdam Kupczyk <akupczyk@redhat.com>
Tue, 16 Nov 2021 12:33:28 +0000 (13:33 +0100)
committerAdam Kupczyk <akupczyk@redhat.com>
Fri, 4 Feb 2022 14:03:32 +0000 (15:03 +0100)
commitdcb4107c0959320e82e67937cc9176bee52cecf1
treeec387bdfaed0e8cc3755aab8b36dfd04c24dbfed
parent81ec2d407c57513b5c6aee9a380c7b8472f260d1
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>
(cherry picked from commit 35e7fd4808bc9be7046332db588437e6446859bf)
src/common/entity_name.cc
src/common/entity_name.h