[PATCH] mm/fault, arch: faulthandler_disabled() also check irqs_disabled()

Xin Zhao posted 1 patch 1 week, 4 days ago
include/linux/uaccess.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] mm/fault, arch: faulthandler_disabled() also check irqs_disabled()
Posted by Xin Zhao 1 week, 4 days ago
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@163.com>
---
 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
Re: [PATCH] mm/fault, arch: faulthandler_disabled() also check irqs_disabled()
Posted by kernel test robot 3 days, 11 hours ago

Hello,

kernel test robot noticed "Kernel_panic-not_syncing:No_working_init_found" on:

commit: 6046ff3895e712d6aa63b4e4923082413d549baa ("[PATCH] mm/fault, arch: faulthandler_disabled() also check irqs_disabled()")
url: https://github.com/intel-lab-lkp/linux/commits/Xin-Zhao/mm-fault-arch-faulthandler_disabled-also-check-irqs_disabled/20260325-222637
base: https://git.kernel.org/cgit/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/all/20260323100100.1031582-1-jackzxcui1989@163.com/
patch subject: [PATCH] mm/fault, arch: faulthandler_disabled() also check irqs_disabled()

in testcase: boot

config: i386-randconfig-141-20260328
compiler: clang-20
test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 32G

(please refer to attached dmesg/kmsg for entire log/backtrace)



If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202603311618.27b2972e-lkp@intel.com




[  975.526458][    T1]     nmi_watchdog=panic
[  975.540461][    T1]     load_ramdisk=2
[  975.553947][    T1]     prompt_ramdisk=0
[  975.567589][    T1]     vga=normal
[  975.589657][    T1] Starting init: /bin/sh exists but couldn't execute it (error -14)
[  975.616704][    T1] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[  975.664175][    T1] CPU: 0 UID: 0 PID: 1 Comm: sh Not tainted 7.0.0-rc5-00672-g6046ff3895e7 #1 PREEMPTLAZY  faae55da7b9858fe5c5fa04eb7f80af1bb165d67
[  975.706828][    T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[  975.739692][    T1] Call Trace:
[  975.750564][    T1]  ? __dump_stack (kbuild/src/consumer/lib/dump_stack.c:95)
[  975.765613][    T1]  ? dump_stack_lvl (kbuild/src/consumer/lib/dump_stack.c:122)
[  975.780501][    T1]  ? vpanic (kbuild/src/consumer/lib/dump_stack.c:129 kbuild/src/consumer/kernel/panic.c:650)
[  975.794103][    T1]  ? rest_init (kbuild/src/consumer/init/main.c:1574)
[  975.808830][    T1]  ? rest_init (kbuild/src/consumer/init/main.c:1574)

The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20260331/202603311618.27b2972e-lkp@intel.com



-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki