Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: vmw_vsock: vmci: Check memcpy_from_msg()

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: 0f7db23a07af ("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>

authored by

Artem Chernyshev and committed by
David S. Miller
44aa5a6d 010b6761

+5 -1
+5 -1
net/vmw_vsock/vmci_transport.c
··· 1711 1711 if (!dg) 1712 1712 return -ENOMEM; 1713 1713 1714 - memcpy_from_msg(VMCI_DG_PAYLOAD(dg), msg, len); 1714 + err = memcpy_from_msg(VMCI_DG_PAYLOAD(dg), msg, len); 1715 + if (err) { 1716 + kfree(dg); 1717 + return err; 1718 + } 1715 1719 1716 1720 dg->dst = vmci_make_handle(remote_addr->svm_cid, 1717 1721 remote_addr->svm_port);