PCI: hv: Add validation for untrusted Hyper-V values
authorAndrea Parri (Microsoft) <parri.andrea@gmail.com>
Wed, 11 May 2022 22:32:06 +0000 (00:32 +0200)
committerWei Liu <wei.liu@kernel.org>
Fri, 13 May 2022 16:57:32 +0000 (16:57 +0000)
commit9937fa6d1eb6fac95586970e17617a718919c858
treeb201384ef57a200585b0fe4c3a8d86020c041909
parenta2bad844a67b1c7740bda63e87453baf63c3a7f7
PCI: hv: Add validation for untrusted Hyper-V values

For additional robustness in the face of Hyper-V errors or malicious
behavior, validate all values that originate from packets that Hyper-V
has sent to the guest in the host-to-guest ring buffer.  Ensure that
invalid values cannot cause data being copied out of the bounds of the
source buffer in hv_pci_onchannelcallback().

While at it, remove a redundant validation in hv_pci_generic_compl():
hv_pci_onchannelcallback() already ensures that all processed incoming
packets are "at least as large as [in fact larger than] a response".

Signed-off-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Link: https://lore.kernel.org/r/20220511223207.3386-2-parri.andrea@gmail.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/pci/controller/pci-hyperv.c