xen/arm: p2m: Always clear the P2M entry when the mapping is removed
authorJulien Grall <jgrall@amazon.com>
Tue, 14 Dec 2021 09:53:44 +0000 (09:53 +0000)
committerJan Beulich <jbeulich@suse.com>
Tue, 25 Jan 2022 12:25:01 +0000 (13:25 +0100)
commita428b913a002eb2b7425b48029c20a52eeee1b5a
treecb15cec206780daa7ce9b31e4708c84efbf37c68
parent329b7bed80032fd52904af6a0cac7dd3716d27cf
xen/arm: p2m: Always clear the P2M entry when the mapping is removed

Commit 2148a125b73b ("xen/arm: Track page accessed between batch of
Set/Way operations") allowed an entry to be invalid from the CPU PoV
(lpae_is_valid()) but valid for Xen (p2m_is_valid()). This is useful
to track which page is accessed and only perform an action on them
(e.g. clean & invalidate the cache after a set/way instruction).

Unfortunately, __p2m_set_entry() is only zeroing the P2M entry when
lpae_is_valid() returns true. This means the entry will not be zeroed
if the entry was valid from Xen PoV but invalid from the CPU PoV for
tracking purpose.

As a consequence, this will allow a domain to continue to access the
page after it was removed.

Resolve the issue by always zeroing the entry if it the LPAE bit is
set or the entry is about to be removed.

This is CVE-2022-23033 / XSA-393.

Reported-by: Dmytro Firsov <Dmytro_Firsov@epam.com>
Fixes: 2148a125b73b ("xen/arm: Track page accessed between batch of Set/Way operations")
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Julien Grall <jgrall@amazon.com>
xen/arch/arm/p2m.c