Skip to content

Commit 0fcf6c0

Browse files
ukernelidryomov
authored andcommitted
ceph: don't drop message if it contains more data than expected
Later version mds may encode more data into messages. Signed-off-by: "Yan, Zheng" <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 342ce18 commit 0fcf6c0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fs/ceph/mds_client.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3406,10 +3406,10 @@ static void handle_lease(struct ceph_mds_client *mdsc,
34063406
vino.ino = le64_to_cpu(h->ino);
34073407
vino.snap = CEPH_NOSNAP;
34083408
seq = le32_to_cpu(h->seq);
3409-
dname.name = (void *)h + sizeof(*h) + sizeof(u32);
3410-
dname.len = msg->front.iov_len - sizeof(*h) - sizeof(u32);
3411-
if (dname.len != get_unaligned_le32(h+1))
3409+
dname.len = get_unaligned_le32(h + 1);
3410+
if (msg->front.iov_len < sizeof(*h) + sizeof(u32) + dname.len)
34123411
goto bad;
3412+
dname.name = (void *)(h + 1) + sizeof(u32);
34133413

34143414
/* lookup inode */
34153415
inode = ceph_find_inode(sb, vino);

fs/ceph/quota.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void ceph_handle_quota(struct ceph_mds_client *mdsc,
4848
struct inode *inode;
4949
struct ceph_inode_info *ci;
5050

51-
if (msg->front.iov_len != sizeof(*h)) {
51+
if (msg->front.iov_len < sizeof(*h)) {
5252
pr_err("%s corrupt message mds%d len %d\n", __func__,
5353
session->s_mds, (int)msg->front.iov_len);
5454
ceph_msg_dump(msg);

0 commit comments

Comments
 (0)