Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

libceph: Fix slab-out-of-bounds access in auth message processing

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>

authored by

Raphael Zimmer and committed by
Ilya Dryomov
1c439de7 d1fef92e

+3 -1
+1 -1
net/ceph/auth.c
··· 257 257 ac->negotiating = false; 258 258 } 259 259 260 - if (result) { 260 + if (result < 0) { 261 261 pr_err("auth protocol '%s' mauth authentication failed: %d\n", 262 262 ceph_auth_proto_name(ac->protocol), result); 263 263 ret = result;
+2
net/ceph/mon_client.c
··· 174 174 */ 175 175 static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len) 176 176 { 177 + BUG_ON(len > monc->m_auth->front_alloc_len); 178 + 177 179 monc->pending_auth = 1; 178 180 monc->m_auth->front.iov_len = len; 179 181 monc->m_auth->hdr.front_len = cpu_to_le32(len);