mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Oleg Nesterov" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Oleg Nesterov <oleg@redhat.com>,
	Thomas Gleixner <tglx@kernel.org>,
	Bradley Morgan <include@grrlz.net>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] posix-cpu-timers: Don't abuse lock_task_sighand() in handle_posix_cpu_timers()
Date: Sun, 05 Jul 2026 10:18:54 -0000	[thread overview]
Message-ID: <178324673422.744054.16955516111098598048.tip-bot2@tip-bot2> (raw)
In-Reply-To: <akjp8AGpY8eJG5I1@redhat.com>

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     a73d7f98e41a96d6e1bcb0e731ab185d9d67878e
Gitweb:        https://git.kernel.org/tip/a73d7f98e41a96d6e1bcb0e731ab185d9d67878e
Author:        Oleg Nesterov <oleg@redhat.com>
AuthorDate:    Sat, 04 Jul 2026 13:09:36 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Sun, 05 Jul 2026 12:15:22 +02:00

posix-cpu-timers: Don't abuse lock_task_sighand() in handle_posix_cpu_timers()

After commit f90fff1e152d ("posix-cpu-timers: fix race between
handle_posix_cpu_timers() and posix_cpu_timer_del()"), tsk->sighand is
stable in handle_posix_cpu_timers(), so it can use the plain
spin_lock_irqsave(&tsk->sighand->siglock).

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Bradley Morgan <include@grrlz.net>
Link: https://patch.msgid.link/akjp8AGpY8eJG5I1@redhat.com
---
 kernel/time/posix-cpu-timers.c |  9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 5e633d8..c8a9b52 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -1300,8 +1300,11 @@ static void handle_posix_cpu_timers(struct task_struct *tsk)
 	unsigned long flags, start;
 	LIST_HEAD(firing);
 
-	if (!lock_task_sighand(tsk, &flags))
-		return;
+	/*
+	 * tsk is current and ->sighand is stable, see the
+	 * tsk->exit_state check in run_posix_cpu_timers()
+	 */
+	spin_lock_irqsave(&tsk->sighand->siglock, flags);
 
 	do {
 		/*
@@ -1361,7 +1364,7 @@ static void handle_posix_cpu_timers(struct task_struct *tsk)
 	 * that gets the timer lock before we do will give it up and
 	 * spin until we've taken care of that timer below.
 	 */
-	unlock_task_sighand(tsk, &flags);
+	spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
 
 	/*
 	 * Now that all the timers on our list have the firing flag,

  parent reply	other threads:[~2026-07-05 10:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-04 11:09 [PATCH] posix-cpu-timers: don't " Oleg Nesterov
2026-07-04 14:42 ` Bradley Morgan
2026-07-04 16:42   ` Oleg Nesterov
2026-07-04 17:05   ` Oleg Nesterov
2026-07-04 17:06     ` Bradley Morgan
2026-07-04 17:09     ` Oleg Nesterov
2026-07-05 12:27     ` Bradley Morgan
2026-07-05 10:18 ` tip-bot2 for Oleg Nesterov [this message]
2026-07-08 20:35 ` Frederic Weisbecker

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=178324673422.744054.16955516111098598048.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=include@grrlz.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®