All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Danish Khateeb <danishkhateeb03@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	James Clark <james.clark@linaro.org>,
	Marco Elver <elver@google.com>,
	Frederic Weisbecker <frederic@kernel.org>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] perf/core: Don't send SIGTRAP after exec removed the event
Date: Wed, 30 Sep 2026 17:16:10 +0200	[thread overview]
Message-ID: <20260930151610.GN88198@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260930144248.59858-1-danishkhateeb03@gmail.com>

On Wed, Sep 30, 2026 at 09:42:48AM -0500, Danish Khateeb wrote:
> A sigtrap event must also set remove_on_exec, so that its SIGTRAP never
> reaches a program after exec. But the signal is sent from task work,
> which only runs on the way back to user space. If the event overflows
> shortly before execve(), the task work can still be pending when the
> task enters execve(), and then runs when execve() returns. By then
> perf_event_exec() has removed the event and the new program has default
> signal handlers, so the SIGTRAP kills it.
> 
> The exec_stress test in the remove_on_exec selftest catches this and
> fails about half the time in a VM. A process that opens a sigtrap event
> on itself and then calls execve() is killed by SIGTRAP in 15% to 50% of
> runs, both on an AMD machine running v7.2 and in a VM, with or without
> close-on-exec on the event fd.
> 
> perf_event_exit_event() sets PERF_EVENT_STATE_EXIT when exec removes the
> event. If the event fd is close-on-exec and was the last reference to
> the file, exec also queues the file release as task work. Task work runs
> newest first, so perf_release() runs before the SIGTRAP work and moves
> the event on to PERF_EVENT_STATE_DEAD. Exit is already caught by the
> PF_EXITING check in perf_sigtrap(). So don't send the signal when the
> event state is PERF_EVENT_STATE_EXIT or lower, which means the event has
> been removed. That also covers PERF_EVENT_STATE_REVOKED, where the PMU
> is gone.
> 
> Fixes: 97ba62b27867 ("perf: Add support for SIGTRAP on perf events")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>

Is this the same problem as this one?

  https://patch.msgid.link/20260920075026.990582-1-luogengkun2@huawei.com

  parent reply	other threads:[~2026-09-30 15:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 14:42 [PATCH v2] perf/core: Don't send SIGTRAP after exec removed the event Danish Khateeb
2026-09-30 14:57 ` sashiko-bot
2026-09-30 15:16 ` Peter Zijlstra [this message]
2026-09-30 15:59   ` Danishk2445

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=20260930151610.GN88198@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=danishkhateeb03@gmail.com \
    --cc=elver@google.com \
    --cc=frederic@kernel.org \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=stable@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.