Skip to content

Commit 1d3f872

Browse files
jtlaytonidryomov
authored andcommitted
ceph: just skip unrecognized info in ceph_reply_info_extra
In the future, we're going to want to extend the ceph_reply_info_extra for create replies. Currently though, the kernel code doesn't accept an extra blob that is larger than the expected data. Change the code to skip over any unrecognized fields at the end of the extra blob, rather than returning -EIO. Cc: [email protected] Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 4f5cafb commit 1d3f872

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

fs/ceph/mds_client.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ static int parse_reply_info_readdir(void **p, void *end,
384384
}
385385

386386
done:
387-
if (*p != end)
388-
goto bad;
387+
/* Skip over any unrecognized fields */
388+
*p = end;
389389
return 0;
390390

391391
bad:
@@ -406,12 +406,10 @@ static int parse_reply_info_filelock(void **p, void *end,
406406
goto bad;
407407

408408
info->filelock_reply = *p;
409-
*p += sizeof(*info->filelock_reply);
410409

411-
if (unlikely(*p != end))
412-
goto bad;
410+
/* Skip over any unrecognized fields */
411+
*p = end;
413412
return 0;
414-
415413
bad:
416414
return -EIO;
417415
}
@@ -425,18 +423,21 @@ static int parse_reply_info_create(void **p, void *end,
425423
{
426424
if (features == (u64)-1 ||
427425
(features & CEPH_FEATURE_REPLY_CREATE_INODE)) {
426+
/* Malformed reply? */
428427
if (*p == end) {
429428
info->has_create_ino = false;
430429
} else {
431430
info->has_create_ino = true;
432-
info->ino = ceph_decode_64(p);
431+
ceph_decode_64_safe(p, end, info->ino, bad);
433432
}
433+
} else {
434+
if (*p != end)
435+
goto bad;
434436
}
435437

436-
if (unlikely(*p != end))
437-
goto bad;
438+
/* Skip over any unrecognized fields */
439+
*p = end;
438440
return 0;
439-
440441
bad:
441442
return -EIO;
442443
}

0 commit comments

Comments
 (0)