Commit 948da95e authored by Ilya Dryomov's avatar Ilya Dryomov Committed by Kleber Sacilotto de Souza

libceph: handle an empty authorize reply

BugLink: https://bugs.launchpad.net/bugs/1822271

commit 0fd3fd0a upstream.

The authorize reply can be empty, for example when the ticket used to
build the authorizer is too old and TAG_BADAUTHORIZER is returned from
the service.  Calling ->verify_authorizer_reply() results in an attempt
to decrypt and validate (somewhat) random data in au->buf (most likely
the signature block from calc_signature()), which fails and ends up in
con_fault_finish() with !con->auth_retry.  The ticket isn't invalidated
and the connection is retried again and again until a new ticket is
obtained from the monitor:

  libceph: osd2 192.168.122.1:6809 bad authorize reply
  libceph: osd2 192.168.122.1:6809 bad authorize reply
  libceph: osd2 192.168.122.1:6809 bad authorize reply
  libceph: osd2 192.168.122.1:6809 bad authorize reply

Let TAG_BADAUTHORIZER handler kick in and increment con->auth_retry.

Cc: stable@vger.kernel.org
Fixes: 5c056fdc ("libceph: verify authorize reply on connect")
Link: https://tracker.ceph.com/issues/20164Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Reviewed-by: default avatarSage Weil <sage@redhat.com>
[idryomov@gmail.com: backport to 4.4: extra arg, no CEPHX_V2]
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarJuerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 79c4f1c6
...@@ -2049,17 +2049,21 @@ static int process_connect(struct ceph_connection *con) ...@@ -2049,17 +2049,21 @@ static int process_connect(struct ceph_connection *con)
dout("process_connect on %p tag %d\n", con, (int)con->in_tag); dout("process_connect on %p tag %d\n", con, (int)con->in_tag);
if (con->auth_reply_buf) { if (con->auth_reply_buf) {
int len = le32_to_cpu(con->in_reply.authorizer_len);
/* /*
* Any connection that defines ->get_authorizer() * Any connection that defines ->get_authorizer()
* should also define ->verify_authorizer_reply(). * should also define ->verify_authorizer_reply().
* See get_connect_authorizer(). * See get_connect_authorizer().
*/ */
if (len) {
ret = con->ops->verify_authorizer_reply(con, 0); ret = con->ops->verify_authorizer_reply(con, 0);
if (ret < 0) { if (ret < 0) {
con->error_msg = "bad authorize reply"; con->error_msg = "bad authorize reply";
return ret; return ret;
} }
} }
}
switch (con->in_reply.tag) { switch (con->in_reply.tag) {
case CEPH_MSGR_TAG_FEATURES: case CEPH_MSGR_TAG_FEATURES:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment