aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/hyperv
diff options
context:
space:
mode:
authorHaiyang Zhang <haiyangz@microsoft.com>2012-10-02 01:30:21 -0400
committerDavid S. Miller <davem@davemloft.net>2012-10-02 14:39:30 -0400
commit99e3fcfa34e7ea6dbb44fe5df51b79ccb6f73d3d (patch)
treee0e136763a441634457ca136522606ce53c8c271 /drivers/net/hyperv
parentea4963745f712a746ccb45871a22e0814141a891 (diff)
hyperv: Fix page buffer handling in rndis_filter_send_request()
To prevent possible data corruption in RNDIS requests, add another page buffer if the request message crossed page boundary. Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/hyperv')
-rw-r--r--drivers/net/hyperv/rndis_filter.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 617eb2e4b06e..f25f41e1fdb7 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -45,7 +45,8 @@ struct rndis_request {
45 45
46 /* Simplify allocation by having a netvsc packet inline */ 46 /* Simplify allocation by having a netvsc packet inline */
47 struct hv_netvsc_packet pkt; 47 struct hv_netvsc_packet pkt;
48 struct hv_page_buffer buf; 48 /* Set 2 pages for rndis requests crossing page boundary */
49 struct hv_page_buffer buf[2];
49 50
50 struct rndis_message request_msg; 51 struct rndis_message request_msg;
51 /* 52 /*
@@ -227,6 +228,18 @@ static int rndis_filter_send_request(struct rndis_device *dev,
227 packet->page_buf[0].offset = 228 packet->page_buf[0].offset =
228 (unsigned long)&req->request_msg & (PAGE_SIZE - 1); 229 (unsigned long)&req->request_msg & (PAGE_SIZE - 1);
229 230
231 /* Add one page_buf when request_msg crossing page boundary */
232 if (packet->page_buf[0].offset + packet->page_buf[0].len > PAGE_SIZE) {
233 packet->page_buf_cnt++;
234 packet->page_buf[0].len = PAGE_SIZE -
235 packet->page_buf[0].offset;
236 packet->page_buf[1].pfn = virt_to_phys((void *)&req->request_msg
237 + packet->page_buf[0].len) >> PAGE_SHIFT;
238 packet->page_buf[1].offset = 0;
239 packet->page_buf[1].len = req->request_msg.msg_len -
240 packet->page_buf[0].len;
241 }
242
230 packet->completion.send.send_completion_ctx = req;/* packet; */ 243 packet->completion.send.send_completion_ctx = req;/* packet; */
231 packet->completion.send.send_completion = 244 packet->completion.send.send_completion =
232 rndis_filter_send_request_completion; 245 rndis_filter_send_request_completion;