xen/p2m/m2p/gnttab: do not add failed grant maps to m2p override

The caller will not undo a mapping which failed and therefore the
override will not be removed.

This is especially bad in the case of GNTMAP_contains_pte mapping type
mappings where m2p_add_override will destroy the kernel mapping of the
page.

This was observed via a failure of map_grant_pages in gntdev_mmap (due
to userspace using a bad grant reference), which left the page in
question unmapped (because it was a GNTMAP_contains_pte mapping) which
led to a crash later on.

Signed-off-by: Ian Campbell <[email protected]>
Cc: Daniel De Graaf <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Jeremy Fitzhardinge <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
This commit is contained in:
Ian Campbell
2011-03-09 19:59:10 -05:00
committed by Konrad Rzeszutek Wilk
parent f4ee4af447
commit dc4972a4e2
+4
View File
@@ -462,6 +462,10 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
return ret;
for (i = 0; i < count; i++) {
/* Do not add to override if the map failed. */
if (map_ops[i].status)
continue;
/* m2p override only supported for GNTMAP_contains_pte mappings */
if (!(map_ops[i].flags & GNTMAP_contains_pte))
continue;