]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
libceph: bound get_version reply decode to front len
authorDouya Le <ldy3087146292@gmail.com>
Sun, 7 Jun 2026 09:35:49 +0000 (17:35 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 23 Jul 2026 18:29:41 +0000 (20:29 +0200)
handle_get_version_reply() uses msg->front_alloc_len as the decode
boundary for MON_GET_VERSION_REPLY.  That is the size of the reused
reply buffer, not the number of bytes actually received.

A truncated reply can therefore pass ceph_decode_need() and decode the
second u64 from stale tail bytes left in the buffer by an earlier
message, causing an uninitialized memory read.

Use msg->front.iov_len as the receive-side decode boundary, matching
other libceph reply handlers and limiting decoding to the bytes that
were actually read from the wire.

Cc: stable@vger.kernel.org
Fixes: 513a8243d67f ("libceph: mon_get_version request infrastructure")
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Zhengchuan Liang <zcliangcn@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Assisted-by: Codex:GPT-5.4
Signed-off-by: Douya Le <ldy3087146292@gmail.com>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
net/ceph/mon_client.c

index 24acdd580e7966c7a4f65c8339e3f35c45f4324b..c56457378d00e5219af361c3c230f6736d14769b 100644 (file)
@@ -821,7 +821,7 @@ static void handle_get_version_reply(struct ceph_mon_client *monc,
        struct ceph_mon_generic_request *req;
        u64 tid = le64_to_cpu(msg->hdr.tid);
        void *p = msg->front.iov_base;
-       void *end = p + msg->front_alloc_len;
+       void *const end = p + msg->front.iov_len;
        u64 handle;
 
        dout("%s msg %p tid %llu\n", __func__, msg, tid);