Skip to content

Commit 9390850

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fix from Catalin Marinas: "Fix PTRACE_PEEKMTETAGS access to an mmapped region before the first write" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: mte: Allow PTRACE_PEEKMTETAGS access to the zero page
2 parents dcc0b49 + 68d54ce commit 9390850

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

arch/arm64/kernel/cpufeature.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,16 +1701,12 @@ static void bti_enable(const struct arm64_cpu_capabilities *__unused)
17011701
#ifdef CONFIG_ARM64_MTE
17021702
static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap)
17031703
{
1704-
static bool cleared_zero_page = false;
1705-
17061704
/*
17071705
* Clear the tags in the zero page. This needs to be done via the
17081706
* linear map which has the Tagged attribute.
17091707
*/
1710-
if (!cleared_zero_page) {
1711-
cleared_zero_page = true;
1708+
if (!test_and_set_bit(PG_mte_tagged, &ZERO_PAGE(0)->flags))
17121709
mte_clear_page_tags(lm_alias(empty_zero_page));
1713-
}
17141710

17151711
kasan_init_hw_tags_cpu();
17161712
}

arch/arm64/kernel/mte.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,12 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,
329329
* would cause the existing tags to be cleared if the page
330330
* was never mapped with PROT_MTE.
331331
*/
332-
if (!test_bit(PG_mte_tagged, &page->flags)) {
332+
if (!(vma->vm_flags & VM_MTE)) {
333333
ret = -EOPNOTSUPP;
334334
put_page(page);
335335
break;
336336
}
337+
WARN_ON_ONCE(!test_bit(PG_mte_tagged, &page->flags));
337338

338339
/* limit access to the end of the page */
339340
offset = offset_in_page(addr);

0 commit comments

Comments
 (0)