Skip to content

Commit

Permalink
vhost: check message header size read
Browse files Browse the repository at this point in the history
[ upstream commit 966f89d ]

This patch adds a check to ensure the read size of
the Vhost-user message header is not smaller than
the expected size.

In case of unexpected read size, report an error
and close file descriptors passed with the message,
if any.

Fixes: 8f97231 ("vhost: support vhost-user")

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
  • Loading branch information
mcoquelin authored and kevintraynor committed Feb 19, 2020
1 parent 3d79e4f commit 9f9f2da
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/librte_vhost/vhost_user.c
Expand Up @@ -1997,8 +1997,14 @@ read_vhost_message(int sockfd, struct VhostUserMsg *msg)

ret = read_fd_message(sockfd, (char *)msg, VHOST_USER_HDR_SIZE,
msg->fds, VHOST_MEMORY_MAX_NREGIONS, &msg->fd_num);
if (ret <= 0)
if (ret <= 0) {
return ret;
} else if (ret != VHOST_USER_HDR_SIZE) {
RTE_LOG(ERR, VHOST_CONFIG,
"Unexpected header size read\n");
close_msg_fds(msg);
return -1;
}

if (msg->size) {
if (msg->size > sizeof(msg->payload)) {
Expand Down

0 comments on commit 9f9f2da

Please sign in to comment.