Skip to content

Commit 2ae0afd

Browse files
Raphael Zimmergregkh
authored andcommitted
libceph: Fix slab-out-of-bounds access in auth message processing
commit 1c439de upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4708221 commit 2ae0afd

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

net/ceph/auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ int ceph_handle_auth_reply(struct ceph_auth_client *ac,
257257
ac->negotiating = false;
258258
}
259259

260-
if (result) {
260+
if (result < 0) {
261261
pr_err("auth protocol '%s' mauth authentication failed: %d\n",
262262
ceph_auth_proto_name(ac->protocol), result);
263263
ret = result;

net/ceph/mon_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ int ceph_monmap_contains(struct ceph_monmap *m, struct ceph_entity_addr *addr)
174174
*/
175175
static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
176176
{
177+
BUG_ON(len > monc->m_auth->front_alloc_len);
178+
177179
monc->pending_auth = 1;
178180
monc->m_auth->front.iov_len = len;
179181
monc->m_auth->hdr.front_len = cpu_to_le32(len);

0 commit comments

Comments
 (0)