lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211012084421.35136-1-zhe.he@windriver.com>
Date:   Tue, 12 Oct 2021 16:44:21 +0800
From:   He Zhe <zhe.he@...driver.com>
To:     catalin.marinas@....com, will@...nel.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        zhe.he@...driver.com, bigeasy@...utronix.de, tglx@...utronix.de,
        rostedt@...dmis.org, linux-rt-users@...r.kernel.org
Subject: [PATCH] arm64: signal: Delay calling signals in atomic

Debugging with breakpoints on arm64 and RT would trigger the following
call trace. When CONFIG_PREEMPT_RT is enabled, spin_locks become mutexes,
and one of these is the spin lock used in signal handling.

BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 357, name: multi-timer
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
Preemption disabled at:
[<ffffffc01002f11c>] do_debug_exception+0x58/0x14c
CPU: 0 PID: 357 Comm: multi-timer Not tainted 5.15.0-rc4-rt8-yocto-preempt-rt #1
Hardware name: linux,dummy-virt (DT)
Call trace:
 dump_backtrace+0x0/0x19c
 show_stack+0x24/0x30
 dump_stack_lvl+0x7c/0xa0
 dump_stack+0x18/0x34
 __might_resched+0x160/0x1c0
 rt_spin_lock+0x3c/0xb0
 force_sig_info_to_task+0x38/0x14c
 force_sig_fault+0x60/0x84
 arm64_force_sig_fault+0x4c/0x7c
 send_user_sigtrap+0x70/0x84
 single_step_handler+0x50/0xf0
 do_debug_exception+0xa4/0x14c
 el0_dbg+0x20/0x60
 el0t_64_sync_handler+0x110/0x1b0
 el0t_64_sync+0x1a0/0x1a4

Fix potential sleep while atomic in the similar way of
2dbbc3a07009 ("signal/x86: Delay calling signals in atomic")

Define ARCH_RT_DELAYS_SIGNAL_SEND to enable delaying action in
force_sig_info_to_task. Add actual sending action to arm64 specific path.

Signed-off-by: He Zhe <zhe.he@...driver.com>
---
 arch/arm64/include/asm/signal.h | 4 ++++
 arch/arm64/kernel/signal.c      | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/arch/arm64/include/asm/signal.h b/arch/arm64/include/asm/signal.h
index ef449f5f4ba8..5e535c3e4926 100644
--- a/arch/arm64/include/asm/signal.h
+++ b/arch/arm64/include/asm/signal.h
@@ -22,4 +22,8 @@ static inline void __user *arch_untagged_si_addr(void __user *addr,
 }
 #define arch_untagged_si_addr arch_untagged_si_addr
 
+#if defined(CONFIG_PREEMPT_RT)
+#define ARCH_RT_DELAYS_SIGNAL_SEND
+#endif
+
 #endif
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 8a9194ed981c..1d65f2801e13 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -928,6 +928,14 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
 		} else {
 			local_daif_restore(DAIF_PROCCTX);
 
+#ifdef ARCH_RT_DELAYS_SIGNAL_SEND
+			if (unlikely(current->forced_info.si_signo)) {
+				struct task_struct *t = current;
+				force_sig_info(&t->forced_info);
+				t->forced_info.si_signo = 0;
+			}
+#endif
+
 			if (thread_flags & _TIF_UPROBE)
 				uprobe_notify_resume(regs);
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ