lkml.org 
[lkml]   [2020]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] exit: Move preemption fixup up, move blocking operations down
On Thu,  5 Mar 2020 23:06:57 +0100
Jann Horn <jannh@google.com> wrote:

> With CONFIG_DEBUG_ATOMIC_SLEEP=y and CONFIG_CGROUPS=y, kernel oopses in
> non-preemptible context look untidy; after the main oops, the kernel prints
> a "sleeping function called from invalid context" report because
> exit_signals() -> cgroup_threadgroup_change_begin() -> percpu_down_read()
> can sleep, and that happens before the preempt_count_set(PREEMPT_ENABLED)
> fixup.
>
> It looks like the same thing applies to profile_task_exit() and
> kcov_task_exit().
>
> Fix it by moving the preemption fixup up and the calls to
> profile_task_exit() and kcov_task_exit() down.
>
> Fixes: 1dc0fffc48af ("sched/core: Robustify preemption leak checks")
> Signed-off-by: Jann Horn <jannh@google.com>
> ---



> @@ -732,6 +736,16 @@ void __noreturn do_exit(long code)
> */
> set_fs(USER_DS);
>
> + if (unlikely(in_atomic())) {
> + pr_info("note: %s[%d] exited with preempt_count %d\n",
> + current->comm, task_pid_nr(current),
> + preempt_count());

This should be more than a pr_info. It should also probably state the
"Dazed and confused, best to reboot" message.

Because if something crashed in a non preempt section, it may likely be
holding a lock that it will never release, causing a soon to be deadlock!

-- Steve


> + preempt_count_set(PREEMPT_ENABLED);
> + }
> +
> + profile_task_exit(tsk);
> + kcov_task_exit(tsk);
> +
> ptrace_event(PTRACE_EVENT_EXIT, code);
>
> validate_creds_for_do_exit(tsk);
> @@ -749,13 +763,6 @@ void __noreturn do_exit(long code)
>
> exit_signals(tsk); /* sets PF_EXITING */
>
> - if (unlikely(in_atomic())) {
> - pr_info("note: %s[%d] exited with preempt_count %d\n",
> - current->comm, task_pid_nr(current),
> - preempt_count());
> - preempt_count_set(PREEMPT_ENABLED);
> - }
> -
> /* sync mm's RSS info before statistics gathering */
> if (tsk->mm)
> sync_mm_rss(tsk->mm);
>
> base-commit: 9f65ed5fe41ce08ed1cb1f6a950f9ec694c142ad

\
 
 \ /
  Last update: 2020-03-05 23:15    [W:0.079 / U:1.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site