[tip: perf/urgent] perf: Fixup SIGTRAP and sample_flags interaction

From: tip-bot2 for Peter Zijlstra
Date: Thu Nov 24 2022 - 04:43:23 EST


The following commit has been merged into the perf/urgent branch of tip:

Commit-ID: af169b7759a9b9369b5106cd07a25c57ce60119e
Gitweb: https://git.kernel.org/tip/af169b7759a9b9369b5106cd07a25c57ce60119e
Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
AuthorDate: Mon, 21 Nov 2022 15:57:44 +01:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Thu, 24 Nov 2022 10:12:23 +01:00

perf: Fixup SIGTRAP and sample_flags interaction

The perf_event_attr::sigtrap functionality relies on data->addr being
set. However commit 7b0846301531 ("perf: Use sample_flags for addr")
changed this to only initialize data->addr when not 0.

Fixes: 7b0846301531 ("perf: Use sample_flags for addr")
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Link: https://lkml.kernel.org/r/Y3426b4OimE%2FI5po%40hirez.programming.kicks-ass.net
---
kernel/events/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 8848714..f2bb27e 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9328,7 +9328,10 @@ static int __perf_event_overflow(struct perf_event *event,
*/
WARN_ON_ONCE(event->pending_sigtrap != pending_id);
}
- event->pending_addr = data->addr;
+
+ event->pending_addr = 0;
+ if (data->sample_flags & PERF_SAMPLE_ADDR)
+ event->pending_addr = data->addr;
irq_work_queue(&event->pending_irq);
}