exit: Detect and fix irq disabled state in oops
PATCH 1/1 exit: Detect and fix irq disabled state in oops
If a task oopses with irqs disabled, this can cause various cascading problems in the oops path such as sleep-from-invalid warnings, and potentially worse.
Since commit 0258b5fd7c712 ("coredump: Limit coredumps to a single thread group"), the unconditional irq enable in coredump_task_exit() will "fix" the irq state to be enabled early in do_exit(), so currently this may not be triggerable, but that is coincidental and fragile.
Detect and fix the irqs_disabled() condition in the oops path before calling do_exit(), similarly to the way in_atomic() is handled.
--- kernel/exit.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/exit.c +6 -0
@@ -738,6 +738,7 @@ void __noreturn do_exit(long code)struct task_struct *tsk = current;int group_dead; +WARN_ON (irqs_disabled ());WARN_ON (tsk->plug);kcov_task_exit (tsk);
@@ -865,6 +866,11 @@ void __noreturn make_task_dead(int signr)if (unlikely (!tsk->pid))panic ("Attempted to kill the idle task!" ); +if (unlikely (irqs_disabled ())) { +pr_info ("note: %s[%d] exited with irqs disabled\n" , + current->comm,task_pid_nr (current)); +local_irq_enable (); + }if (unlikely (in_atomic ())) { pr_info("note: %s[%d] exited with preempt_count %d\n", current->comm, task_pid_nr(current),
Signature · 1 line
2.37.2
Quoted 9 lines · Nicholas Piggin
If a task oopses with irqs disabled, this can cause various cascading problems in the oops path such as sleep-from-invalid warnings, and potentially worse.
Since commit
0258b5fd7c712("coredump: Limit coredumps to a single thread group"), the unconditional irq enable incoredump_task_exit()will "fix" the irq state to be enabled early indo_exit(), so currently this may not be triggerable, but that is coincidental and fragile.
Quoted 5 lines
Detect and fix the
irqs_disabled()condition in the oops path before callingdo_exit(), similarly to the wayin_atomic()is handled.Reported-by Michael Ellerman <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>
Hey Eric, did you have any thoughts on this?
Thanks,
Nick
Quoted 30 lines
--- kernel/exit.c | 6 ++++++ 1 file changed, 6 insertions(+)kernel/exit.c +6
-0@@ -738,6 +738,7 @@ void __noreturn do_exit(long code)struct task_struct *tsk = current;int group_dead; +WARN_ON (irqs_disabled ());WARN_ON (tsk->plug);kcov_task_exit (tsk);@@ -865,6 +866,11 @@ void __noreturn make_task_dead(int signr)if (unlikely (!tsk->pid))panic ("Attempted to kill the idle task!" ); +if (unlikely (irqs_disabled ())) { +pr_info ("note: %s[%d] exited with irqs disabled\n" , + current->comm,task_pid_nr (current)); +local_irq_enable (); + }if (unlikely (in_atomic ())) { pr_info("note: %s[%d] exited with preempt_count %d\n", current->comm, task_pid_nr(current),Signature · 1 line
2.37.2
Eric W. Biederman
Acked-byQuoted 10 lines · Nicholas Piggin
Quoted 9 lines · Nicholas Piggin
If a task oopses with irqs disabled, this can cause various cascading problems in the oops path such as sleep-from-invalid warnings, and potentially worse.
Since commit
0258b5fd7c712("coredump: Limit coredumps to a single thread group"), the unconditional irq enable incoredump_task_exit()will "fix" the irq state to be enabled early indo_exit(), so currently this may not be triggerable, but that is coincidental and fragile.
Quoted 7 lines
Quoted 5 lines
Detect and fix the
irqs_disabled()condition in the oops path before callingdo_exit(), similarly to the wayin_atomic()is handled.Reported-by Michael Ellerman <[email protected]>Signed-off-by Nicholas Piggin <[email protected]>Hey Eric, did you have any thoughts on this?
No strong thoughts.
I agree that the unconditionally disabling then enabling irqs in coredump_task_exit will mean there is likely to be little change in real behavior.
I also agree that is something fragile to depend upon so we making our assumptions explicit seems good.
Quoted 34 lines
Thanks,
NickQuoted 30 lines
--- kernel/exit.c | 6 ++++++ 1 file changed, 6 insertions(+)kernel/exit.c +6
-0@@ -738,6 +738,7 @@ void __noreturn do_exit(long code)struct task_struct *tsk = current;int group_dead; +WARN_ON (irqs_disabled ());WARN_ON (tsk->plug);kcov_task_exit (tsk);@@ -865,6 +866,11 @@ void __noreturn make_task_dead(int signr)if (unlikely (!tsk->pid))panic ("Attempted to kill the idle task!" ); +if (unlikely (irqs_disabled ())) { +pr_info ("note: %s[%d] exited with irqs disabled\n" , + current->comm,task_pid_nr (current)); +local_irq_enable (); + }if (unlikely (in_atomic ())) { pr_info("note: %s[%d] exited with preempt_count %d\n", current->comm, task_pid_nr(current),Signature · 1 line
2.37.2