hv_netvsc: Fix offset usage in netvsc_send_table()
authorHaiyang Zhang <haiyangz@microsoft.com>
Thu, 21 Nov 2019 21:33:40 +0000 (13:33 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:51:20 +0000 (14:51 +0100)
commit4544f000c83323f3183eec44691a64e251eaefc6
tree115e11ef07ffa939c76c43dc515628acbd041284
parentb6994e3eeb9906690559d70560e8b1c9b8dcccdd
hv_netvsc: Fix offset usage in netvsc_send_table()

[ Upstream commit 71f21959dd5516031db4f011e15e9a9508b93a7d ]

To reach the data region, the existing code adds offset in struct
nvsp_5_send_indirect_table on the beginning of this struct. But the
offset should be based on the beginning of its container,
struct nvsp_message. This bug causes the first table entry missing,
and adds an extra zero from the zero pad after the data region.
This can put extra burden on the channel 0.

So, correct the offset usage. Also add a boundary check to ensure
not reading beyond data region.

Fixes: 5b54dac856cb ("hyperv: Add support for virtual Receive Side Scaling (vRSS)")
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/hyperv/hyperv_net.h
drivers/net/hyperv/netvsc.c