]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
libceph: Fix slab-out-of-bounds access in auth message processing
authorRaphael Zimmer <raphael.zimmer@tu-ilmenau.de>
Tue, 21 Apr 2026 08:27:01 +0000 (10:27 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 21 Apr 2026 23:40:23 +0000 (01:40 +0200)
If a (potentially corrupted) message of type CEPH_MSG_AUTH_REPLY
contains a positive value in its result field, it is treated as an
error code by ceph_handle_auth_reply() and returned to
handle_auth_reply(). Thereafter, an attempt is made to send the
preallocated message of type CEPH_MSG_AUTH, where the returned value is
interpreted as the size of the front segment to send. If the result
value in the message is greater than the size of the memory buffer
allocated for the front segment, an out-of-bounds access occurs, and
the content of the memory region beyond this buffer is sent out.

This patch fixes the issue by treating only negative values in the
result field as errors. Positive values are therefore treated as success
in the same way as a zero value. Additionally, a BUG_ON is added to
__send_prepared_auth_request() comparing the len parameter to
front_alloc_len to prevent sending the message if it exceeds the bounds
of the allocation and to make it easier to catch any logic flaws leading
to this.

Cc: stable@vger.kernel.org
Signed-off-by: Raphael Zimmer <raphael.zimmer@tu-ilmenau.de>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
net/ceph/auth.c
net/ceph/mon_client.c

index 3314705e591466d617e5074c3cef8a9b82f6df4c..17660bde896be827272baa55696f2ddf84800a8f 100644 (file)
@@ -257,7 +257,7 @@ int ceph_handle_auth_reply(struct ceph_auth_client *ac,
                ac->negotiating = false;
        }
 
-       if (result) {
+       if (result < 0) {
                pr_err("auth protocol '%s' mauth authentication failed: %d\n",
                       ceph_auth_proto_name(ac->protocol), result);
                ret = result;
index d5080530ce0ccb0af82d72453ddccad9673b80ff..d2cdc8ee31551eb99ad062f191ac3cf984970130 100644 (file)
@@ -174,6 +174,8 @@ int ceph_monmap_contains(struct ceph_monmap *m, struct ceph_entity_addr *addr)
  */
 static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
 {
+       BUG_ON(len > monc->m_auth->front_alloc_len);
+
        monc->pending_auth = 1;
        monc->m_auth->front.iov_len = len;
        monc->m_auth->hdr.front_len = cpu_to_le32(len);