Skip to content

Commit

Permalink
net: vmw_vsock: vmci: Check memcpy_from_msg()
Browse files Browse the repository at this point in the history
[ Upstream commit 44aa5a6 ]

vmci_transport_dgram_enqueue() does not check the return value
of memcpy_from_msg().  If memcpy_from_msg() fails, it is possible that
uninitialized memory contents are sent unintentionally instead of user's
message in the datagram to the destination.  Return with an error if
memcpy_from_msg() fails.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 0f7db23 ("vmci_transport: switch ->enqeue_dgram, ->enqueue_stream and ->dequeue_stream to msghdr")
Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Vishnu Dasa <vdasa@vmware.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
dTenebrae authored and gregkh committed Dec 31, 2022
1 parent bd72ab5 commit 6af9442
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/vmw_vsock/vmci_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,11 @@ static int vmci_transport_dgram_enqueue(
if (!dg)
return -ENOMEM;

memcpy_from_msg(VMCI_DG_PAYLOAD(dg), msg, len);
err = memcpy_from_msg(VMCI_DG_PAYLOAD(dg), msg, len);
if (err) {
kfree(dg);
return err;
}

dg->dst = vmci_make_handle(remote_addr->svm_cid,
remote_addr->svm_port);
Expand Down

0 comments on commit 6af9442

Please sign in to comment.