linux/arch/arm64
Peter Collingbourne d1c9727ba8 arm64: Reset KASAN tag in copy_highpage with HW tags only
commit e74a684680 upstream.

During page migration, the copy_highpage function is used to copy the
page data to the target page. If the source page is a userspace page
with MTE tags, the KASAN tag of the target page must have the match-all
tag in order to avoid tag check faults during subsequent accesses to the
page by the kernel. However, the target page may have been allocated in
a number of ways, some of which will use the KASAN allocator and will
therefore end up setting the KASAN tag to a non-match-all tag. Therefore,
update the target page's KASAN tag to match the source page.

We ended up unintentionally fixing this issue as a result of a bad
merge conflict resolution between commit e059853d14 ("arm64: mte:
Fix/clarify the PG_mte_tagged semantics") and commit 20794545c1 ("arm64:
kasan: Revert "arm64: mte: reset the page tag in page->flags""), which
preserved a tag reset for PG_mte_tagged pages which was considered to be
unnecessary at the time. Because SW tags KASAN uses separate tag storage,
update the code to only reset the tags when HW tags KASAN is enabled.

Signed-off-by: Peter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/If303d8a709438d3ff5af5fd85706505830f52e0c
Reported-by: "Kuan-Ying Lee (李冠穎)" <Kuan-Ying.Lee@mediatek.com>
Cc: <stable@vger.kernel.org> # 6.1
Fixes: 20794545c1 ("arm64: kasan: Revert "arm64: mte: reset the page tag in page->flags"")
Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
Link: https://lore.kernel.org/r/20230215050911.1433132-1-pcc@google.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2023-03-10 09:29:47 +01:00
..
boot arm64: zynqmp: Enable hs termination flag for USB dwc3 controller 2023-03-10 09:29:06 +01:00
configs arm64: defconfig: Enable Qualcomm SM6115 / SM4250 GCC and Pinctrl 2022-11-30 17:49:05 +01:00
crypto crypto: arm64/sm4-gcm - Fix possible crash in GCM cryption 2023-03-03 11:56:16 +01:00
hyperv hyperv: simplify and rename generate_guest_id 2022-09-28 13:36:56 +00:00
include Some more EFI fixes for v6.2: 2023-01-23 11:46:19 -08:00
kernel arm64: acpi: Fix possible memory leak of ffh_ctxt 2023-03-10 09:29:46 +01:00
kvm KVM: arm64: Allow no running vcpu on saving vgic3 pending table 2023-01-29 18:46:11 +00:00
lib Merge branch 'for-next/sysregs' into for-next/core 2022-12-06 11:32:25 +00:00
mm arm64: Reset KASAN tag in copy_highpage with HW tags only 2023-03-10 09:29:47 +01:00
net bpf: Remove prog->active check for bpf_lsm and bpf_iter 2022-10-25 23:11:46 -07:00
tools arm64/sysreg: Fix errors in 32 bit enumeration values 2023-03-10 09:28:06 +01:00
xen xen: allow pv-only hypercalls only with CONFIG_XEN_PV 2021-11-02 08:11:01 -05:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig arm64: mm: hugetlb: Disable HUGETLB_PAGE_OPTIMIZE_VMEMMAP 2023-03-10 09:29:47 +01:00
Kconfig.debug arm64: remove TEXT_OFFSET randomization 2020-06-15 13:10:59 +01:00
Kconfig.platforms arm64: renesas: Drop selecting GPIOLIB and PINCTRL 2022-10-28 14:31:24 +02:00
Makefile Merge branch 'for-next/ftrace' into for-next/core 2022-12-06 11:07:39 +00:00