Commit 6d63b6a2 authored by Vincenzo Frascino's avatar Vincenzo Frascino
Browse files

arm64: mte: Reset the page tag in page->flags

The hardware tag-based KASAN for compatibility with the other modes
stores the tag associated to a page in page->flags.
Due to this the kernel faults on access when it allocates a page with an
initial tag and the user changes the tags.

Reset the tag associated by the kernel to a page in all the meaningful
places to prevent kernel faults on access.

Note: An alternative to this approach could be to modify page_to_virt().
This though could end up being racy, in fact if a CPU checks the
PG_mte_tagged bit and decides that the page is not tagged but another
CPU maps the same with PROT_MTE and becomes tagged the subsequent kernel
access would fail.

Signed-off-by: Vincenzo Frascino's avatarVincenzo Frascino <>
parent 1b0f05a9
......@@ -34,6 +34,7 @@ static void mte_sync_page_tags(struct page *page, pte_t *ptep, bool check_swap)
......@@ -22,6 +22,7 @@ void copy_highpage(struct page *to, struct page *from)
copy_page(kto, kfrom);
if (system_supports_mte() && test_bit(PG_mte_tagged, &from->flags)) {
set_bit(PG_mte_tagged, &to->flags);
mte_copy_page_tags(kto, kfrom);
......@@ -53,6 +53,7 @@ bool mte_restore_tags(swp_entry_t entry, struct page *page)
if (!tags)
return false;
mte_restore_page_tags(page_address(page), tags);
return true;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment