pipe: only read AuthSessionHandler under pipe_lock

session_security, the AuthSessionHandler for a Pipe, is deleted and
recreated while the pipe_lock is held. read_message() is called
without pipe_lock held, and examines session_security. To make this
safe, make session_security a shared_ptr and take a reference to it
while the pipe_lock is still held, and use that shared_ptr in
read_message().

This may have caused crashes like:

*** Error in `qemu-system-x86_64': invalid fastbin entry (free): 0x00007f42a4002de0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x80a46)[0x7f452f1f3a46]
/usr/lib/x86_64-linux-gnu/libnss3.so(PK11_FreeSymKey+0xa8)[0x7f452e72ff98]
/usr/lib/librados.so.2(+0x2a18cd)[0x7f453451a8cd]
/usr/lib/librados.so.2(_ZNK9CryptoKey7encryptEP11CephContextRKN4ceph6buffer4listERS4_RSs+0x71)[0x7f4534519421]
/usr/lib/librados.so.2(_Z21encode_encrypt_enc_blIN4ceph6buffer4listEEvP11CephContextRKT_RK9CryptoKeyRS2_RSs+0xfe)[0x7f453451859e]
/usr/lib/librados.so.2(_Z14encode_encryptIN4ceph6buffer4listEEiP11CephContextRKT_RK9CryptoKeyRS2_RSs+0xa2)[0x7f45345186d2]
/usr/lib/librados.so.2(_ZN19CephxSessionHandler23check_message_signatureEP7Message+0x246)[0x7f4534516866]
/usr/lib/librados.so.2(_ZN4Pipe12read_messageEPP7Message+0xdcc)[0x7f453462ecbc]
/usr/lib/librados.so.2(_ZN4Pipe6readerEv+0xa5c)[0x7f453464059c]
/usr/lib/librados.so.2(_ZN4Pipe6Reader5entryEv+0xd)[0x7f4534643ecd]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7f8e)[0x7f452f543f8e]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f452f26da0d]

Partially-fixes: #6480
Backport: dumpling, emperor
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
doc: Notes and minor modifications to gateway installation doc.

Signed-off-by: John Wilkins <john.wilkins@inktank.com>
doc: Made minor changes to quick start preflight for RHEL.

Signed-off-by: John Wilkins <john.wilkins@inktank.com>
osd: do not block when updating osdmap superblock features

We are holding osd_lock in check_osdmap_features, which means we cannot
block while waiting for filestore operations to flush/apply without
risking deadlock.

The important constraint is that we commit that the feature is enabled
before also commiting anything that utilizes sharded objects.  The normal
commit sequencing does that already; there is no reason to block here.

Fixes: #8045
Signed-off-by: Sage Weil <sage@inktank.com>
librbd: fix zero length request handling

Zero-length writes would hang because the completion was never
called. Reads would hit an assert about zero length in
Striper::file_to_exents().

Fix all of these cases by skipping zero-length extents. The completion
is created and finished when finish_adding_requests() is called. This
is slightly different from usual completions since it comes from the
same thread as the one scheduling the request, but zero-length aio
requests should never happen from things that might care about this,
like QEMU.

Writes and discards have had this bug since the beginning of
librbd. Reads might have avoided it until stripingv2 was added.

Fixes: #5469
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
librados: Fix typo for read functions documentation

Signed-off-by: David Zafman <david.zafman@inktank.com>
librados: Allow rados_pool_list() to get NULL buffer if len == 0

Coverity wants a NULL check for buf, but caller should be able to
pass a NULL buf and 0 len in order to get byte count of pool list.

Signed-off-by: David Zafman <david.zafman@inktank.com>
rbd: Prevent Seg fault by checking read result in snap_read_header()

Signed-off-by: David Zafman <david.zafman@inktank.com>
client: wake up umount waiter if receiving session open message

Wake up umount waiter if receiving session open message while
umounting. The umount waiter will re-close the session.

Fixes: #8004
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Merge pull request #1633 from ceph/wip-8004

client: wake up umount waiter if receiving session open message

Reviewed-by: Sage Weil <sage@inktank.com>
mailmap: Nikola Kotur affiliation

Reviewed-by: Nikola Kotur <kotnick@gmail.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
mailmap: Yan, Zheng name normalization

Signed-off-by: Loic Dachary <loic@dachary.org>
Merge pull request #1606 from ceph/wip-shrink-icache

client: try shrinking kernel inode cache when trimming session caps

Reviewed-by: Sage Weil <sage@inktank.com>
ceph.spec.in: require redhat-lsb-core

We need this for /lib/lsb/init-functions.

Fixes: #8028
Signed-off-by: Sage Weil <sage@inktank.com>
Merge pull request #1634 from ceph/wip-8028

rpm: add redhat-lsb dependency

Reviewed-by: Alfredo Deza <alfredo.deza@inktank.com>
Merge pull request #1632 from ceph/wip-5469

librbd: fix zero length request handling

Reviewed-by: Sage Weil <sage@inktank.com>
Merge pull request #1631 from ceph/wip-8045

osd: fix check_osdmap_features deadlock

Reviewed-by: Samuel Just <sam.just@inktank.com>
Merge pull request #1627 from ceph/wip-8001

osd/PG: set CREATING pg state bit until we peer for the first time

Reviewed-by: Samuel Just <sam.just@inktank.com>
Merge pull request #1626 from ceph/wip-8031

osd: improve misdirected op checks

Reviewed-by: Samuel Just <sam.just@inktank.com>
mon/Elector: ignore ACK from peers without required features

If an old peer gets a PROPOSE from us, we need to be sure to ignore their
ACK.  Ignoring their PROPOSEs isn't sufficient to keep them out of a
quorum.

Fixes: #8042
Signed-off-by: Sage Weil <sage@inktank.com>