]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
libceph: verify authorize reply on connect
authorIlya Dryomov <idryomov@gmail.com>
Fri, 2 Dec 2016 15:35:09 +0000 (16:35 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 12 Dec 2016 22:09:21 +0000 (23:09 +0100)
After sending an authorizer (ceph_x_authorize_a + ceph_x_authorize_b),
the client gets back a ceph_x_authorize_reply, which it is supposed to
verify to ensure the authenticity and protect against replay attacks.
The code for doing this is there (ceph_x_verify_authorizer_reply(),
ceph_auth_verify_authorizer_reply() + plumbing), but it is never
invoked by the the messenger.

AFAICT this goes back to 2009, when ceph authentication protocols
support was added to the kernel client in 4e7a5dcd1bba ("ceph:
negotiate authentication protocol; implement AUTH_NONE protocol").

The second param of ceph_connection_operations::verify_authorizer_reply
is unused all the way down.  Pass 0 to facilitate backporting, and kill
it in the next commit.

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

index a5502898ea33b0e4d74cfa8f12947c1d9466013c..2efb335deada6048be8c8f3b2c6fe30131fb330d 100644 (file)
@@ -2027,6 +2027,19 @@ static int process_connect(struct ceph_connection *con)
 
        dout("process_connect on %p tag %d\n", con, (int)con->in_tag);
 
+       if (con->auth_reply_buf) {
+               /*
+                * Any connection that defines ->get_authorizer()
+                * should also define ->verify_authorizer_reply().
+                * See get_connect_authorizer().
+                */
+               ret = con->ops->verify_authorizer_reply(con, 0);
+               if (ret < 0) {
+                       con->error_msg = "bad authorize reply";
+                       return ret;
+               }
+       }
+
        switch (con->in_reply.tag) {
        case CEPH_MSGR_TAG_FEATURES:
                pr_err("%s%lld %s feature set mismatch,"