arm64: mm: Make hibernation aware of KFENCE
authorNikhil V <quic_nprakash@quicinc.com>
Thu, 13 Jul 2023 07:07:57 +0000 (12:37 +0530)
committerWill Deacon <will@kernel.org>
Thu, 20 Jul 2023 10:44:50 +0000 (11:44 +0100)
commita8bd38dbc57c2fe074df2c9e549b9c2ad3183c83
tree919b95d8a8e5f94a8a38297b78de5a4796a37c0f
parent55b87b74996383230586f4f9f801ae304c70e649
arm64: mm: Make hibernation aware of KFENCE

In the restore path, swsusp_arch_suspend_exit uses copy_page() to
over-write memory. However, with features like KFENCE enabled, there could
be situations where it may have marked some pages as not valid, due to
which it could be reported as invalid accesses.

Consider a situation where page 'P' was part of the hibernation image.
Now, when the resume kernel tries to restore the pages, the same page 'P'
is already in use in the resume kernel and is kfence protected, due to
which its mapping is removed from linear map. Since restoring pages happens
with the resume kernel page tables, we would end up accessing 'P' during
copy and results in kernel pagefault.

The proposed fix tries to solve this issue by marking PTE as valid for such
kfence protected pages.

Co-developed-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Nikhil V <quic_nprakash@quicinc.com>
Link: https://lore.kernel.org/r/20230713070757.4093-1-quic_nprakash@quicinc.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/mm/trans_pgd.c