From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387700; b=cbGGPEcEGfUTnKYYLbZSGxENWUmGHUYT6hVZzhqq8YAddDwiW3RcvYcvAdkQeD/wZ58Z Ss+huIiIhGLiBo01vdGBC2a0Z19Xa5h1Mc6Qc1xlHXjgXq4S5OEO8MIgjcBrZQTLJlMxL 9YCmyYeNT3A1fIs3+LAT6H4YGz+hOszGAqySk1NzxMPE1fQU2ph28XXuijD0LHs1xsQeQ KOnlPWfdXWx2iQAqd0EPmh/gRieMp1RQsabjW1KJISaXSIH7cRj7YVZ7FR9N1xLawqS01 yYKwEGiU4DWTWN712JyyqT52dVg3TMAaDRzf4MePAGOe67rSOZjKsrlpfo9QMPOlUNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387700; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=kQ40DLt3BQass0AV1KgHerp1nHW0pZMeclct7jGJe2M=; b=42BIbufjeP2eUplGJD+T+5iVoKqpque0AIYgJXQIwHihFBHo8K/QmgN9Wx355jpN2yK6 Ts5epPlqt5Q0ajeWj6xuSjvHGA9aMc8IdSm17l9SCd+DarqNYQ3RuGcf4j5rITto5DD1d LJJqn9EsUOVvsDdwNmYdMX6RSi3VLpHjFk61l9B3UKSgp9HLteNDbpQizt2aGGx+fMIBj vxa+pMWH78UU8M93G6akcqTFrkGi5WG9xo5OnmOGbd/ujqP2/0oDTYoyJQdbEorkdhy7Z 2WaCY0o55I1u7ICAKNw6O6FgFfmj1c5+8lLAl/Ux3XgBcdLIku6r9fiBG5HyxP00AQg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Ih28raTH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65293606A322; Fri, 4 Dec 2026 12:35:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Ih28raTH Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB07E1F000C2; Fri, 4 Dec 2026 12:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387700; bh=kQ40DLt3BQass0AV1KgHerp1nHW0pZMeclct7jGJe2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ih28raTHRf5DZBsCWJ8i6cvqZvCK6wWu3cESuDxlizuSyH2n0aElTlz0HCiK1hEXZ +M1UZ+5giOZReTYxYypIfioTT7ho/d8xkrE2K2BwkPWlkqXhBjTkGA+/i8JPpGJhkx 0yvsSHU5quk4UJR6RDvPDPFyOfglW07wH2W9h/tU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andrei Vagin , Andrew Morton , Pavel Tikhomirov , Thomas Gleixner , Sasha Levin Subject: [PATCH 6.1 0353/1059] proc: report SIGEV_NONE in /proc/pid/timers if target task has died Date: Fri, 4 Dec 2026 18:58:04 +0900 Message-ID: <20261204100653.412223256@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrei Vagin [ Upstream commit 0a27f795030ce6a2c71525b0544e3b13bba8828e ] When a posix timer is created targeting a specific thread (using SIGEV_SIGNAL | SIGEV_THREAD_ID), it takes a reference to the target struct pid in timer->it_pid. If the target thread subsequently terminates, its numeric tid is freed and can be recycled for an unrelated task. However, the timer holds its reference to the original struct pid. show_timer() in /proc/[pid]/timers previously called pid_nr_ns() directly on timer->it_pid without checking whether any task remained attached to that struct pid. As a result: 1. It reported the stale tid, which could mistakenly refer to a recycled pid. 2. In the kernel, expired signals for dead target threads are dropped by posixtimer_send_sigqueue() because posixtimer_get_target() returns NULL, so the timer functionally acts as SIGEV_NONE. 3. Checkpoint/restore tools (CRIU) parsing /proc/[pid]/timers would try to restore a timer with SIGEV_SIGNAL | SIGEV_THREAD_ID targeting a non-existent or unrelated thread. Check pid_has_task(timer->it_pid, timer->it_pid_type) in show_timer(). If the target task has died, override notify to SIGEV_NONE and report PID 0 (e.g., 'notify: none/pid.0'). Link: https://lore.kernel.org/20260816161216.984580-1-avagin@google.com Fixes: 57b8015e07a7 ("posix-timers: Show sigevent info in proc file") Signed-off-by: Andrei Vagin Signed-off-by: Andrew Morton Reviewed-by: Pavel Tikhomirov Cc: Thomas Gleixner [ sashal: Replaced timer->it_pid_type with a type computed from the notify flags (PIDTYPE_PID if SIGEV_THREAD_ID, else PIDTYPE_TGID), and dropped the it_lock guard and posixtimer_valid() check. ] Signed-off-by: Sasha Levin --- fs/proc/base.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 6f24023b64f31..a3f54e13e618f 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2529,6 +2529,7 @@ static int show_timer(struct seq_file *m, void *v) struct k_itimer *timer; struct timers_private *tp = m->private; int notify; + pid_t nr = 0; static const char * const nstr[] = { [SIGEV_SIGNAL] = "signal", [SIGEV_NONE] = "none", @@ -2538,6 +2539,13 @@ static int show_timer(struct seq_file *m, void *v) timer = list_entry((struct list_head *)v, struct k_itimer, list); notify = timer->it_sigev_notify; + if (timer->it_pid && + pid_has_task(timer->it_pid, + (notify & SIGEV_THREAD_ID) ? PIDTYPE_PID : PIDTYPE_TGID)) + nr = pid_nr_ns(timer->it_pid, tp->ns); + else + notify = SIGEV_NONE; + seq_printf(m, "ID: %d\n", timer->it_id); seq_printf(m, "signal: %d/%px\n", timer->sigq->info.si_signo, @@ -2545,7 +2553,7 @@ static int show_timer(struct seq_file *m, void *v) seq_printf(m, "notify: %s/%s.%d\n", nstr[notify & ~SIGEV_THREAD_ID], (notify & SIGEV_THREAD_ID) ? "tid" : "pid", - pid_nr_ns(timer->it_pid, tp->ns)); + nr); seq_printf(m, "ClockID: %d\n", timer->it_clock); return 0; -- 2.53.0