[PATCH 1/2] arm64: uaccess: disable preempt during uaccess through ttbr0

Pingfan Liu kernelfans at gmail.com
Tue Dec 21 05:42:41 PST 2021


If using software PAN, the ttbr0 should keep unchanged, otherwise,
considering the following scenario:
  task1
    __uaccess_ttbr0_enable()
    switch_mm(this,next,tsk), which resets ttbr0 to __pa_symbol(reserved_pg_dir)
    switch_mm(prev,this,tsk), which can not re-install the user page table automatically

Tackle this issue by disabling preemption.

Signed-off-by: Pingfan Liu <kernelfans at gmail.com>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Will Deacon <will at kernel.org>
Cc: Mark Rutland <mark.rutland at arm.com>
Cc: Vincenzo Frascino <vincenzo.frascino at arm.com>
Cc: Andrey Konovalov <andreyknvl at gmail.com>
Cc: Arnd Bergmann <arnd at arndb.de>
To: linux-arm-kernel at lists.infradead.org
---
 arch/arm64/include/asm/uaccess.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 3a5ff5e20586..406888877bbd 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -121,6 +121,7 @@ static inline bool uaccess_ttbr0_disable(void)
 	if (!system_uses_ttbr0_pan())
 		return false;
 	__uaccess_ttbr0_disable();
+	preempt_enable();
 	return true;
 }
 
@@ -128,6 +129,7 @@ static inline bool uaccess_ttbr0_enable(void)
 {
 	if (!system_uses_ttbr0_pan())
 		return false;
+	preempt_disable();
 	__uaccess_ttbr0_enable();
 	return true;
 }
-- 
2.31.1




More information about the linux-arm-kernel mailing list