The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: "Oleg Nesterov" <oleg@redhat.com>,
	"Benoît Sevens" <bsevens@google.com>,
	"Frederic Weisbecker" <frederic@kernel.org>
Cc: Zander Work <zdw@google.com>,
	security@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del()
Date: Fri, 13 Jun 2025 21:25:43 +0200	[thread overview]
Message-ID: <87msabphoo.ffs@tglx> (raw)
In-Reply-To: <20250613172650.GA26022@redhat.com>

On Fri, Jun 13 2025 at 19:26, Oleg Nesterov wrote:
> If an exiting non-autoreaping task has already passed exit_notify() and
> calls handle_posix_cpu_timers() from IRQ, it can be reaped by its parent
> or debugger right after unlock_task_sighand().
>
> If a concurrent posix_cpu_timer_del() runs at that moment, it won't be
> able to detect timer->it.cpu.firing != 0: cpu_timer_task_rcu() and/or
> lock_task_sighand() will fail.
>
> Add the tsk->exit_state check into run_posix_cpu_timers() to fix this.
>
> This fix is not needed if CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y, because
> exit_task_work() is called before exit_notify(). But the check still
> makes sense, task_work_add(&tsk->posix_cputimers_work.work) will fail
> anyway in this case.
>
> Cc: stable@vger.kernel.org
> Reported-by: Benoît Sevens <bsevens@google.com>
> Fixes: 0bdd2ed4138e ("sched: run_posix_cpu_timers: Don't check ->exit_state, use lock_task_sighand()")
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

Linus, I assume you take it directly or do you want me to play the
intermediary?

Thanks,

        tglx

  parent reply	other threads:[~2025-06-13 19:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGCho0V0x_Y2+vg5G8-r45Xc6uftLbZK5K1=vpavd_4783fogQ@mail.gmail.com>
2025-06-13 17:26 ` [PATCH] posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del() Oleg Nesterov
2025-06-13 17:55   ` Linus Torvalds
2025-06-13 19:25   ` Thomas Gleixner [this message]
2025-06-13 19:33     ` Linus Torvalds

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=87msabphoo.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=bsevens@google.com \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=security@kernel.org \
    --cc=zdw@google.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