aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/xen-netback/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/xen-netback/hash.c')
-rw-r--r--drivers/net/xen-netback/hash.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c
index 3c4c58b9fe76..3b6fb5b3bdb2 100644
--- a/drivers/net/xen-netback/hash.c
+++ b/drivers/net/xen-netback/hash.c
@@ -332,20 +332,22 @@ u32 xenvif_set_hash_mapping_size(struct xenvif *vif, u32 size)
332u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len, 332u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
333 u32 off) 333 u32 off)
334{ 334{
335 u32 *mapping = &vif->hash.mapping[off]; 335 u32 *mapping = vif->hash.mapping;
336 struct gnttab_copy copy_op = { 336 struct gnttab_copy copy_op = {
337 .source.u.ref = gref, 337 .source.u.ref = gref,
338 .source.domid = vif->domid, 338 .source.domid = vif->domid,
339 .dest.u.gmfn = virt_to_gfn(mapping),
340 .dest.domid = DOMID_SELF, 339 .dest.domid = DOMID_SELF,
341 .dest.offset = xen_offset_in_page(mapping), 340 .len = len * sizeof(*mapping),
342 .len = len * sizeof(u32),
343 .flags = GNTCOPY_source_gref 341 .flags = GNTCOPY_source_gref
344 }; 342 };
345 343
346 if ((off + len > vif->hash.size) || copy_op.len > XEN_PAGE_SIZE) 344 if ((off + len < off) || (off + len > vif->hash.size) ||
345 len > XEN_PAGE_SIZE / sizeof(*mapping))
347 return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; 346 return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
348 347
348 copy_op.dest.u.gmfn = virt_to_gfn(mapping + off);
349 copy_op.dest.offset = xen_offset_in_page(mapping + off);
350
349 while (len-- != 0) 351 while (len-- != 0)
350 if (mapping[off++] >= vif->num_queues) 352 if (mapping[off++] >= vif->num_queues)
351 return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; 353 return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;