Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C1463A6F17 for ; Sun, 16 Aug 2026 16:12:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786896744; cv=none; b=Rp4nwpI/OpLEAIe3NUVeZ4sDjTE0R52BUXU8nJURRFIgt4jDuLEJ5rlkqLzEpdaP2QTQVbyjdiVAAghA3OVCagHJ6J9CFaCsGufWLDfAOdrkNr5FGtw+lfN9X32tI0ZZFHCNeYcGdWfxV78YMC8tgCvgGQSbS1nBsNIDlR2JKWI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786896744; c=relaxed/simple; bh=/WP+AvHfC0Pb7FDW5nuaCkpoSjTZa9kcJOCR0DXz1dU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=kZkg3FUaQhuqMMLPRo1tyDOpD/LXw0r594eVAn76UTZf42XDeWUE3xQSHWaGODm0gR8eG+Qw9IHCXE50C014ab2K1Cx+LmwMaCNmqHCJTkhWllMJOeZCdHtbSdAOKZpVfda/CMPaINgf9NxT4vP+/KEI3jhUbcYdjsvyA0LqoOo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--avagin.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=s1wQqWyf; arc=none smtp.client-ip=209.85.161.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--avagin.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="s1wQqWyf" Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-6acac05f082so902717eaf.3 for ; Sun, 16 Aug 2026 09:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786896742; x=1787501542; darn=lists.linux.dev; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TaYKViIByQqModasEXNrzI0T6qlVRXyx9KZe5Fm4+mg=; b=s1wQqWyfpvNjRanGdnLhNImfhn3SDmVZRsZb1FoyZf/cYb8zbbMSW4IKAhieBb5ITY Zx57G/wA/8KWn8SR8dbYT9CJ3xjHdQp4aAtoBXD1KQphvA1g8xh9KALsL5k+OywZ+BmI T3xDXt7s2IYOJc4g29m1tKn7npQSmxmZHVVWRWvIVPokYg+0CWZi68GAnqusocYrigcy glplCkOLxYyNSlNxRz48DLVpZ6Q7et379xzZknVOosZYNTowYksn8H0Gv2ZqTLAgBmCr 2sFkMhvdBLdDIZGDOYivpl8LJIZgx0jIB9lq8oDVK2uUtUw5xNoot4t2uSh4L1GRYmV/ 3nAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786896742; x=1787501542; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=TaYKViIByQqModasEXNrzI0T6qlVRXyx9KZe5Fm4+mg=; b=WBwbxJhqtv2pxdHUvbFY3g0mMhXTseUVPeWv3ye1kANFW64ENS2v0bCHhlm6eM+1vT TcLcXRqJFifMQnKJ22K1MeM4rhNFIcZCYIQPvaeehBAITQ0u9iOQK/GJ70f6lYzthcFJ X6vbgW5+nVuHLa+AB2dqWxW2YHXOdgpJVdHmJnAJS4nk+HoStAiZMPaecDrSp508Yhdk Cl38X7QaGafvg5g+iafVSRxooKPeAhnsT+dp0zVxMbt2e8FoT018FZK76NM6sDQSbFlk FGULar6LUUkUFAAJkD+N5pY/6M1YXb+Sy3yM+Rf3BmszNdM2cEKJ6BDmh6UUqXkdruVB HqiQ== X-Forwarded-Encrypted: i=1; AHgh+RpDSrKI13C3PFTjkKA8qYhBYgWtsDHaz0M/OW9GILr7D4MXWils2zks4s5A6HpTbIZyYfTg@lists.linux.dev X-Gm-Message-State: AOJu0Yw9fm4dqx1bfYclIAY6Cwmt0J5oL8Z8jNLh6szBT9NVcYc+SDVG 7NLqV5LL0WXBcUzPJHEWPaFLIiAPWQIP11QQsUMCytTmAyH/YJTzmqrrWB6uJqpjJmzvxRYbfF3 J3oPYYw== X-Received: from iobdj25.prod.google.com ([2002:a05:6602:2579:b0:9ab:7c1:c30a]) (user=avagin job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:6aea:b0:6ae:ab01:91a3 with SMTP id 006d021491bc7-6b0d68f9c98mr16927443eaf.35.1786896741883; Sun, 16 Aug 2026 09:12:21 -0700 (PDT) Date: Sun, 16 Aug 2026 16:12:15 +0000 Precedence: bulk X-Mailing-List: criu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.691.gc56d675ccc-goog Message-ID: <20260816161216.984580-1-avagin@google.com> Subject: [PATCH] proc: Report SIGEV_NONE in /proc/pid/timers if target task has died From: Andrei Vagin To: Thomas Gleixner , Andrew Morton Cc: linux-kernel@vger.kernel.org, criu@lists.linux.dev, Andrei Vagin , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" 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'). Cc: Thomas Gleixner Signed-off-by: Andrei Vagin --- fs/proc/base.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 780f81259052..e3a6ea4fffea 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2519,17 +2519,23 @@ static int show_timer(struct seq_file *m, void *v) struct k_itimer *timer = hlist_entry((struct hlist_node *)v, struct k_itimer, list); struct timers_private *tp = m->private; int notify = timer->it_sigev_notify; + pid_t nr = 0; guard(spinlock_irq)(&timer->it_lock); if (!posixtimer_valid(timer)) return 0; + if (timer->it_pid && pid_has_task(timer->it_pid, timer->it_pid_type)) + 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, timer->sigq.info.si_value.sival_ptr); 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.55.0.691.gc56d675ccc-goog