[PATCH] mm/fault, arch: faulthandler_disabled() also check irqs_disabled()
From: Xin Zhao
Date: Mon Mar 23 2026 - 06:08:28 EST
in_atomic() cannot determine whether it is in a context where interrupts
are disabled. In a context with interrupts disabled, sleeping is not
allowed. Page fault handling may lead to sleeping, which can cause issues.
faulthandler_disabled() checks irqs_disabled() to avoid this situation.
Signed-off-by: Xin Zhao <jackzxcui1989@xxxxxxx>
---
include/linux/uaccess.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 1f3804245..71fea4497 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -305,7 +305,7 @@ static inline bool pagefault_disabled(void)
* !CONFIG_PREEMPT_COUNT, this is like a NOP. So the handler won't be disabled.
* in_atomic() will report different values based on !CONFIG_PREEMPT_COUNT.
*/
-#define faulthandler_disabled() (pagefault_disabled() || in_atomic())
+#define faulthandler_disabled() (pagefault_disabled() || in_atomic() || irqs_disabled())
DEFINE_LOCK_GUARD_0(pagefault, pagefault_disable(), pagefault_enable())
--
2.34.1