Skip to content

Commit 0fd3fd0

Browse files
committed
libceph: handle an empty authorize reply
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: 5c056fd ("libceph: verify authorize reply on connect") Link: https://tracker.ceph.com/issues/20164 Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Sage Weil <sage@redhat.com>
1 parent a3b22b9 commit 0fd3fd0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

net/ceph/messenger.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,8 @@ static int process_connect(struct ceph_connection *con)
20582058
dout("process_connect on %p tag %d\n", con, (int)con->in_tag);
20592059

20602060
if (con->auth) {
2061+
int len = le32_to_cpu(con->in_reply.authorizer_len);
2062+
20612063
/*
20622064
* Any connection that defines ->get_authorizer()
20632065
* should also define ->add_authorizer_challenge() and
@@ -2067,8 +2069,7 @@ static int process_connect(struct ceph_connection *con)
20672069
*/
20682070
if (con->in_reply.tag == CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER) {
20692071
ret = con->ops->add_authorizer_challenge(
2070-
con, con->auth->authorizer_reply_buf,
2071-
le32_to_cpu(con->in_reply.authorizer_len));
2072+
con, con->auth->authorizer_reply_buf, len);
20722073
if (ret < 0)
20732074
return ret;
20742075

@@ -2078,10 +2079,12 @@ static int process_connect(struct ceph_connection *con)
20782079
return 0;
20792080
}
20802081

2081-
ret = con->ops->verify_authorizer_reply(con);
2082-
if (ret < 0) {
2083-
con->error_msg = "bad authorize reply";
2084-
return ret;
2082+
if (len) {
2083+
ret = con->ops->verify_authorizer_reply(con);
2084+
if (ret < 0) {
2085+
con->error_msg = "bad authorize reply";
2086+
return ret;
2087+
}
20852088
}
20862089
}
20872090

0 commit comments

Comments
 (0)