libceph: don't set global_id until we get an auth ticket
authorIlya Dryomov <idryomov@gmail.com>
Mon, 26 Apr 2021 17:11:37 +0000 (19:11 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 27 Apr 2021 21:52:24 +0000 (23:52 +0200)
commit61ca49a9105faefa003b37542cebad8722f8ae22
treecb4409965f6efd3dbfcb19a590d11e7a2eeddd5a
parent7807dafda21a549403d922da98dde0ddfeb70d08
libceph: don't set global_id until we get an auth ticket

With the introduction of enforcing mode, setting global_id as soon
as we get it in the first MAuth reply will result in EACCES if the
connection is reset before we get the second MAuth reply containing
an auth ticket -- because on retry we would attempt to reclaim that
global_id with no auth ticket at hand.

Neither ceph_auth_client nor ceph_mon_client depend on global_id
being set ealy, so just delay the setting until we get and process
the second MAuth reply.  While at it, complain if the monitor sends
a zero global_id or changes our global_id as the session is likely
to fail after that.

Cc: stable@vger.kernel.org # needs backporting for < 5.11
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Sage Weil <sage@redhat.com>
net/ceph/auth.c