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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220209221319.179648-2-stephen.s.brennan@oracle.com>
Date:   Wed,  9 Feb 2022 14:13:19 -0800
From:   Stephen Brennan <stephen.s.brennan@...cle.com>
To:     Juri Lelli <juri.lelli@...hat.com>, Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Vincent Guittot <vincent.guittot@...aro.org>
Cc:     linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
        Mel Gorman <mgorman@...e.de>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Ben Segall <bsegall@...gle.com>,
        Stephen Brennan <stephen.s.brennan@...cle.com>
Subject: [PATCH 1/1] sched: Use printk_deferred during __schedule()

When the rq lock is held and a printk occurs, some console drivers may
trigger a deadlock by calling into scheduler functions (e.g. scheduling
work). Though printk() is avoided in these contexts, there are some WARN
or WARN_ONCE statements which can trigger deadlocks during context
switch operations. These warnings should not trigger deadlocks. Use the
printk_deferred helper to ensure console drivers aren't called until
after the critical section is over.

Signed-off-by: Stephen Brennan <stephen.s.brennan@...cle.com>
---
 kernel/sched/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 848eaa0efe0e..bc8afc3020a4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4861,6 +4861,7 @@ static struct rq *finish_task_switch(struct task_struct *prev)
 	perf_event_task_sched_in(prev, current);
 	finish_task(prev);
 	tick_nohz_task_switch();
+	printk_deferred_exit();
 	finish_lock_switch(rq);
 	finish_arch_post_lock_switch();
 	kcov_finish_switch(current);
@@ -6208,6 +6209,7 @@ static void __sched notrace __schedule(unsigned int sched_mode)
 	 */
 	rq_lock(rq, &rf);
 	smp_mb__after_spinlock();
+	printk_deferred_enter();
 
 	/* Promote REQ to ACT */
 	rq->clock_update_flags <<= 1;
@@ -6298,6 +6300,7 @@ static void __sched notrace __schedule(unsigned int sched_mode)
 
 		rq_unpin_lock(rq, &rf);
 		__balance_callbacks(rq);
+		printk_deferred_exit();
 		raw_spin_rq_unlock_irq(rq);
 	}
 }
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ