On Thu, 20 Apr 2023 14:43:27 -0700, Peter Collingbourne wrote:
The mte_sync_page_tags() function sets PG_mte_tagged if it initializes page tags. Then we return to mte_sync_tags(), which sets PG_mte_tagged again. At best, this is redundant. However, it is possible for mte_sync_page_tags() to return without having initialized tags for the page, i.e. in the case where check_swap is true (non-compound page), is_swap_pte(old_pte) is false and pte_is_tagged is false. So at worst, we set PG_mte_tagged on a page with uninitialized tags. This can happen if, for example, page migration causes a PTE for an untagged page to be replaced. If the userspace program subsequently uses mprotect() to enable PROT_MTE for that page, the uninitialized tags will be exposed to userspace.
[...]
Applied to arm64 (for-next/fixes), thanks!
[1/1] arm64: mte: Do not set PG_mte_tagged if tags were not initialized https://git.kernel.org/arm64/c/c4c597f1b367
Cheers,