FAILED: patch "[PATCH] arm64: Also reset KASAN tag if page is not PG_mte_tagged" failed to apply to 6.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 2efbafb91e12ff5a16cbafb0085e4c10c3fca493
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023052235-cut-gulp-ad69@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
2efbafb91e12 ("arm64: Also reset KASAN tag if page is not PG_mte_tagged") e74a68468062 ("arm64: Reset KASAN tag in copy_highpage with HW tags only") d77e59a8fccd ("arm64: mte: Lock a page for MTE tag initialisation") e059853d14ca ("arm64: mte: Fix/clarify the PG_mte_tagged semantics")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 2efbafb91e12ff5a16cbafb0085e4c10c3fca493 Mon Sep 17 00:00:00 2001
From: Peter Collingbourne <[email protected]>
Date: Thu, 20 Apr 2023 14:09:45 -0700
Subject: [PATCH] arm64: Also reset KASAN tag if page is not PG_mte_tagged
Consider the following sequence of events:
1) A page in a PROT_READ|PROT_WRITE VMA is faulted.
2) Page migration allocates a page with the KASAN allocator, causing it to receive a non-match-all tag, and uses it
to replace the page faulted in 1.
3) The program uses mprotect() to enable PROT_MTE on the page faulted in 1.
As a result of step 3, we are left with a non-match-all tag for a page with tags accessible to userspace, which can lead to the same kind of tag check faults that commit e74a68468062 ("arm64: Reset KASAN tag in copy_highpage with HW tags only") intended to fix.
The general invariant that we have for pages in a VMA with VM_MTE_ALLOWED is that they cannot have a non-match-all tag. As a result of step 2, the invariant is broken. This means that the fix in the referenced commit was incomplete and we also need to reset the tag for pages without PG_mte_tagged.
arch/arm64/mm/copypage.c +3 -2
@@ -21,9 +21,10 @@ void copy_highpage(struct page *to, struct page *from)copy_page (kto, kfrom); +if (kasan_hw_tags_enabled ()) +page_kasan_tag_reset (to); +if (system_supports_mte () &&page_mte_tagged (from)) { -if (kasan_hw_tags_enabled ()) -page_kasan_tag_reset (to);/* It's a new page, shouldn't have been tagged yet */ WARN_ON_ONCE (!try_page_mte_tagging (to));mte_copy_page_tags (kto, kfrom);
PATCH 1/1 arm64: Also reset KASAN tag if page is not PG_mte_tagged
Consider the following sequence of events:
1) A page in a PROT_READ|PROT_WRITE VMA is faulted.
2) Page migration allocates a page with the KASAN allocator, causing it to receive a non-match-all tag, and uses it
to replace the page faulted in 1.
3) The program uses mprotect() to enable PROT_MTE on the page faulted in 1.
As a result of step 3, we are left with a non-match-all tag for a page with tags accessible to userspace, which can lead to the same kind of tag check faults that commit e74a68468062 ("arm64: Reset KASAN tag in copy_highpage with HW tags only") intended to fix.
The general invariant that we have for pages in a VMA with VM_MTE_ALLOWED is that they cannot have a non-match-all tag. As a result of step 2, the invariant is broken. This means that the fix in the referenced commit was incomplete and we also need to reset the tag for pages without PG_mte_tagged.
--- arch/arm64/mm/copypage.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/mm/copypage.c +3 -2
@@ -21,9 +21,10 @@ void copy_highpage(struct page *to, struct page *from)copy_page (kto, kfrom); +if (kasan_hw_tags_enabled ()) +page_kasan_tag_reset (to); +if (system_supports_mte () &&page_mte_tagged (from)) { -if (kasan_hw_tags_enabled ()) -page_kasan_tag_reset (to);mte_copy_page_tags (kto, kfrom);set_page_mte_tagged (to); }
Signature · 1 line
2.40.1.698.g37aff9b760-goog
Greg KH
maintainerRe: [PATCH 6.1.y] arm64: Also reset KASAN tag if page is not PG_mte_tagged
Quoted 27 lines · Peter Collingbourne
Consider the following sequence of events:
1) A page in a PROT_READ|PROT_WRITE VMA is faulted.
2) Page migration allocates a page with the KASAN allocator, causing it to receive a non-match-all tag, and uses it
to replace the page faulted in 1.
3) The program usesmprotect()to enablePROT_MTEon the page faulted in 1.As a result of step 3, we are left with a non-match-all tag for a page with tags accessible to userspace, which can lead to the same kind of tag check faults that commit
e74a68468062("arm64: Reset KASAN tag incopy_highpagewith HW tags only") intended to fix.The general invariant that we have for pages in a VMA with
VM_MTE_ALLOWEDis that they cannot have a non-match-all tag. As a result of step 2, the invariant is broken. This means that the fix in the referenced commit was incomplete and we also need to reset the tag for pages withoutPG_mte_tagged.Fixes e5b8d9218951 ("arm64: mte: reset the page tag in page->flags")Cc <[email protected]> # 5.15Signed-off-by Peter Collingbourne <[email protected]>Reviewed-by Catalin Marinas <[email protected]>Signed-off-by Will Deacon <[email protected]>(cherry picked from commit 2efbafb91e12ff5a16cbafb0085e4c10c3fca493)
Quoted 3 lines
--- arch/arm64/mm/copypage.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Both backports now queued up, thanks.
greg k-h