lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <171291620346.10875.14979532789812701380.tip-bot2@tip-bot2>
Date: Fri, 12 Apr 2024 10:03:23 -0000
From: "tip-bot2 for Kyle Huey" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Kyle Huey <khuey@...ehuey.com>, Ingo Molnar <mingo@...nel.org>,
 Song Liu <song@...nel.org>, Jiri Olsa <jolsa@...nel.org>,
 Namhyung Kim <namhyung@...nel.org>, Andrii Nakryiko <andrii@...nel.org>,
 x86@...nel.org, linux-kernel@...r.kernel.org
Subject: [tip: perf/core] perf/bpf: Allow a BPF program to suppress all sample
 side effects

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

Commit-ID:     c4fcc7d1f41532e878087c7c43f4cf247604d68b
Gitweb:        https://git.kernel.org/tip/c4fcc7d1f41532e878087c7c43f4cf247604d68b
Author:        Kyle Huey <me@...ehuey.com>
AuthorDate:    Thu, 11 Apr 2024 18:50:18 -07:00
Committer:     Ingo Molnar <mingo@...nel.org>
CommitterDate: Fri, 12 Apr 2024 11:49:50 +02:00

perf/bpf: Allow a BPF program to suppress all sample side effects

Returning zero from a BPF program attached to a perf event already
suppresses any data output. Return early from __perf_event_overflow() in
this case so it will also suppress event_limit accounting, SIGTRAP
generation, and F_ASYNC signalling.

Signed-off-by: Kyle Huey <khuey@...ehuey.com>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Acked-by: Song Liu <song@...nel.org>
Acked-by: Jiri Olsa <jolsa@...nel.org>
Acked-by: Namhyung Kim <namhyung@...nel.org>
Acked-by: Andrii Nakryiko <andrii@...nel.org>
Link: https://lore.kernel.org/r/20240412015019.7060-7-khuey@kylehuey.com
---
 kernel/events/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index c6a6936..2212670 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9677,6 +9677,9 @@ static int __perf_event_overflow(struct perf_event *event,
 
 	ret = __perf_event_account_interrupt(event, throttle);
 
+	if (event->prog && !bpf_overflow_handler(event, data, regs))
+		return ret;
+
 	/*
 	 * XXX event_limit might not quite work as expected on inherited
 	 * events
@@ -9726,8 +9729,7 @@ static int __perf_event_overflow(struct perf_event *event,
 		irq_work_queue(&event->pending_irq);
 	}
 
-	if (!(event->prog && !bpf_overflow_handler(event, data, regs)))
-		READ_ONCE(event->overflow_handler)(event, data, regs);
+	READ_ONCE(event->overflow_handler)(event, data, regs);
 
 	if (*perf_event_fasync(event) && event->pending_kill) {
 		event->pending_wakeup = 1;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ