提交 1d3f8723 编写于 作者: J Jeff Layton 提交者: Ilya Dryomov

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: stable@vger.kernel.org
Signed-off-by: NJeff Layton <jlayton@kernel.org>
Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
上级 4f5cafb5
...@@ -384,8 +384,8 @@ static int parse_reply_info_readdir(void **p, void *end, ...@@ -384,8 +384,8 @@ static int parse_reply_info_readdir(void **p, void *end,
} }
done: done:
if (*p != end) /* Skip over any unrecognized fields */
goto bad; *p = end;
return 0; return 0;
bad: bad:
...@@ -406,12 +406,10 @@ static int parse_reply_info_filelock(void **p, void *end, ...@@ -406,12 +406,10 @@ static int parse_reply_info_filelock(void **p, void *end,
goto bad; goto bad;
info->filelock_reply = *p; info->filelock_reply = *p;
*p += sizeof(*info->filelock_reply);
if (unlikely(*p != end)) /* Skip over any unrecognized fields */
goto bad; *p = end;
return 0; return 0;
bad: bad:
return -EIO; return -EIO;
} }
...@@ -425,18 +423,21 @@ static int parse_reply_info_create(void **p, void *end, ...@@ -425,18 +423,21 @@ static int parse_reply_info_create(void **p, void *end,
{ {
if (features == (u64)-1 || if (features == (u64)-1 ||
(features & CEPH_FEATURE_REPLY_CREATE_INODE)) { (features & CEPH_FEATURE_REPLY_CREATE_INODE)) {
/* Malformed reply? */
if (*p == end) { if (*p == end) {
info->has_create_ino = false; info->has_create_ino = false;
} else { } else {
info->has_create_ino = true; 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)) /* Skip over any unrecognized fields */
goto bad; *p = end;
return 0; return 0;
bad: bad:
return -EIO; return -EIO;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册