Message ID | 20221206065834.1093081-1-artem.chernyshev@red-soft.ru (mailing list archive) |
---|---|
State | Accepted |
Commit | 44aa5a6dba8283bfda28b1517af4de711c5652a4 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v4] net: vmw_vsock: vmci: Check memcpy_from_msg() | expand |
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Tue, 6 Dec 2022 09:58:34 +0300 you wrote: > 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. > > [...] Here is the summary with links: - [v4] net: vmw_vsock: vmci: Check memcpy_from_msg() https://git.kernel.org/netdev/net/c/44aa5a6dba82 You are awesome, thank you!
diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c index 842c94286d31..36eb16a40745 100644 --- a/net/vmw_vsock/vmci_transport.c +++ b/net/vmw_vsock/vmci_transport.c @@ -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);