Skip to content

Commit

Permalink
ceph: just skip unrecognized info in ceph_reply_info_extra
Browse files Browse the repository at this point in the history
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: stable@vger.kernel.org
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
  • Loading branch information
Jeff Layton authored and Ilya Dryomov committed Oct 15, 2019
1 parent 4f5cafb commit 1d3f872
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions fs/ceph/mds_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ static int parse_reply_info_readdir(void **p, void *end,
}

done:
if (*p != end)
goto bad;
/* Skip over any unrecognized fields */
*p = end;
return 0;

bad:
Expand All @@ -406,12 +406,10 @@ static int parse_reply_info_filelock(void **p, void *end,
goto bad;

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

if (unlikely(*p != end))
goto bad;
/* Skip over any unrecognized fields */
*p = end;
return 0;

bad:
return -EIO;
}
Expand All @@ -425,18 +423,21 @@ static int parse_reply_info_create(void **p, void *end,
{
if (features == (u64)-1 ||
(features & CEPH_FEATURE_REPLY_CREATE_INODE)) {
/* Malformed reply? */
if (*p == end) {
info->has_create_ino = false;
} else {
info->has_create_ino = true;
info->ino = ceph_decode_64(p);
ceph_decode_64_safe(p, end, info->ino, bad);
}
} else {
if (*p != end)
goto bad;
}

if (unlikely(*p != end))
goto bad;
/* Skip over any unrecognized fields */
*p = end;
return 0;

bad:
return -EIO;
}
Expand Down

0 comments on commit 1d3f872

Please sign in to comment.