xen/arm: p2m: Don't check the return of p2m_get_root_pointer() with BUG_ON()
authorJulien Grall <julien.grall@arm.com>
Thu, 31 Oct 2019 16:14:24 +0000 (17:14 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 31 Oct 2019 16:14:24 +0000 (17:14 +0100)
commit56767b7c4dc8d62da4d14fb9133b9057dc8d9d42
tree142ef3f2582ed309d3a4ba2b253e25bca499982d
parent952f362d4a685cbe7b528517e553106ec0735f73
xen/arm: p2m: Don't check the return of p2m_get_root_pointer() with BUG_ON()

It turns out that the BUG_ON() was actually reachable with well-crafted
hypercalls. The BUG_ON() is here to prevent catch logical error, so
crashing Xen is a bit over the top.

While all the holes should now be fixed, it would be better to downgrade
the BUG_ON() to something less fatal to prevent any more DoS.

The BUG_ON() in p2m_get_entry() is now replaced by ASSERT_UNREACHABLE()
to catch mistake in debug build and return INVALID_MFN for production
build. The interface also requires to set page_order to give an idea of
the size of "hole". So 'level' is now set so we report a hole of size of
the an entry of the root page-table. This stays inline with what happen
when the GFN is higher than p2m->max_mapped_gfn.

The BUG_ON() in p2m_resolve_translation_fault() is now replaced by
ASSERT_UNREACHABLE() to catch mistake in debug build and just report a
fault for producion build.

This is part of XSA-301.

Reported-by: Julien Grall <Julien.Grall@arm.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
master commit: 31b4f4ab6634f85163656b470dffc6d974917853
master date: 2019-10-31 16:19:14 +0100
xen/arch/arm/p2m.c