From: "Eric W. Biederman" <ebiederm@xmission.com>
To: "Nicholas Piggin" <npiggin@gmail.com>
Cc: <linux-kernel@vger.kernel.org>, "Michael Ellerman" <mpe@ellerman.id.au>
Subject: Re: [PATCH] exit: Detect and fix irq disabled state in oops
Date: Fri, 23 Dec 2022 22:28:27 -0600 [thread overview]
Message-ID: <874jtlo26s.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <CP6GJNNB62LY.N38DBL6D2S79@bobo> (Nicholas Piggin's message of "Tue, 20 Dec 2022 17:14:05 +1000")
"Nicholas Piggin" <npiggin@gmail.com> writes:
> On Tue Oct 4, 2022 at 7:44 PM AEST, Nicholas Piggin wrote:
>> 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.
>>
>> Reported-by: Michael Ellerman <mpe@ellerman.id.au>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>
> 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.
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
>
> Thanks,
> Nick
>
>> ---
>> kernel/exit.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/kernel/exit.c b/kernel/exit.c
>> index 84021b24f79e..fa696765f694 100644
>> --- a/kernel/exit.c
>> +++ b/kernel/exit.c
>> @@ -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),
>> --
>> 2.37.2
next prev parent reply other threads:[~2022-12-24 4:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 9:44 [PATCH] exit: Detect and fix irq disabled state in oops Nicholas Piggin
2022-12-20 7:14 ` Nicholas Piggin
2022-12-24 4:28 ` Eric W. Biederman [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-01-20 1:18 Nicholas Piggin
2023-01-20 15:21 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874jtlo26s.fsf@email.froward.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox