libceph: check authorizer reply/challenge length before reading
authorIlya Dryomov <idryomov@gmail.com>
Fri, 27 Jul 2018 17:40:30 +0000 (19:40 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 2 Aug 2018 19:33:26 +0000 (21:33 +0200)
Avoid scribbling over memory if the received reply/challenge is larger
than the buffer supplied with the authorizer.

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

index e915c8bce11762f73c83c4a1ba753722b17ffbe7..0a187196aeede6375b817a102890f024b552bc3f 100644 (file)
@@ -1782,6 +1782,13 @@ static int read_partial_connect(struct ceph_connection *con)
 
        if (con->auth) {
                size = le32_to_cpu(con->in_reply.authorizer_len);
+               if (size > con->auth->authorizer_reply_buf_len) {
+                       pr_err("authorizer reply too big: %d > %zu\n", size,
+                              con->auth->authorizer_reply_buf_len);
+                       ret = -EINVAL;
+                       goto out;
+               }
+
                end += size;
                ret = read_partial(con, end, size,
                                   con->auth->authorizer_reply_buf);