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=1796385094; b=sbx0FIrkxfiGvI4dejuBt3b5GhgJx1AeyBaozYrhURLz5Ag7InEElMQCdBIOlvkQKscO 9hrl0/YHRtKX21RtZUkqVuSpizLe4RU17C6b00FvLnty6WLoFDeHDN5C+GqetcN0iy+AJ nCPC8dyUfXhjkvMPqKxq8iCj3iBXAsKEO+c87oHbna3ra7Q4F8YNWtKBYx/eyH/NdISP8 N9On4zE24uDTH4SG978RDMfMLXVGZhpHXyFii6o4F9f+NVnrQwdttrIcyf7WoMRzXBLdh r3pm+AMFq8UGxCj1pSLmAAC8LMrBTbIzLNFZG5Xqnl9DdMnj809lQb4011RydWHWJww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385094; 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=M4JEZuR85i9BCbfmeoWdQOEEViH7cMFe1Fd0am6NvGY=; b=q7hONJCoa3/R+ZQIKVyNsX4ennCINB6Ft5sa6VDh2cnrNUu5z+TZA3viH8AfAGAo4H9f Ge/IE0dYMMKvtOjE6qUhnoLjeHoa10OrayUu4TAcpVjVqlaZhT1LJfTbqMBA3OX3HcG3Q baHoyOnqcISRfjKCHuaDWcbXJlvLj6gA7JCw1P0BbJ8JIU5pPw4qTqB8Ci3VluUN8xm9r H4/4wp0cGAbHndcxpkmYw+X3CnlHKBMHlCjewEfgFo8r7gA95hOgBkqukvI+ldB1YDDnQ G81BtmX+SiC6/kjz9V3TV9rgW+ZlLbEuku1q1wcksD/mdi1dnNU8JnVW1QT/nenz6Aw== 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=yPuCMCNF; 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 2B4AF606A32C; Fri, 4 Dec 2026 11:51:34 +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=yPuCMCNF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34B051F00933; Fri, 4 Dec 2026 11:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385093; bh=M4JEZuR85i9BCbfmeoWdQOEEViH7cMFe1Fd0am6NvGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yPuCMCNFI9dmNs2ynygckckb4VqEZ1aiiP/vaquc6zyFtkDNcPJ/awJKowRXs2+mK iJV6fm240z7zjEfo1CbxbWqO+DwSeqEM0Hgctse2MI5vQwdiyj5DGofS3pWJOi5MD2 EnJUnEXgd9qCwwsXCEfUntahvKmZgegrEBOWrwcE= 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.6 0375/1167] proc: report SIGEV_NONE in /proc/pid/timers if target task has died Date: Fri, 4 Dec 2026 18:56:42 +0900 Message-ID: <20261204100711.765304811@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 the missing it_pid_type with an inline (notify & SIGEV_THREAD_ID) ? PIDTYPE_PID : PIDTYPE_TGID, and kept this tree's older list_entry()/unlocked show_timer() instead of the hlist, guard() and posixtimer_valid() lines. ] Signed-off-by: Sasha Levin --- fs/proc/base.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 881c2d4846d7c..aa1cc9c5ee95c 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,12 @@ 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 +2552,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