Skip to content

Commit

Permalink
vhost: fix FD leak with inflight messages
Browse files Browse the repository at this point in the history
[ upstream commit af74f7db384ed149fe42b21dbd7975f8a54ef227 ]

Even if unlikely, a buggy vhost-user master might attach fds to inflight
messages. Add checks like for other types of vhost-user messages.

Fixes: d87f1a1 ("vhost: support inflight info sharing")
Cc: stable@dpdk.org
  • Loading branch information
david-marchand authored and cpaelzer committed Mar 17, 2022
1 parent aef5478 commit b7979d3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/librte_vhost/vhost_user.c
Expand Up @@ -1441,6 +1441,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
int fd, i, j;
void *addr;

if (validate_msg_fds(msg, 0) != 0)
return RTE_VHOST_MSG_RESULT_ERR;

if (msg->size != sizeof(msg->payload.inflight)) {
RTE_LOG(ERR, VHOST_CONFIG,
"invalid get_inflight_fd message size is %d\n",
Expand Down Expand Up @@ -1534,6 +1537,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg,
void *addr;
int fd, i;

if (validate_msg_fds(msg, 1) != 0)
return RTE_VHOST_MSG_RESULT_ERR;

fd = msg->fds[0];
if (msg->size != sizeof(msg->payload.inflight) || fd < 0) {
RTE_LOG(ERR, VHOST_CONFIG,
Expand Down

0 comments on commit b7979d3

Please sign in to comment.