[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201116183752.2716-1-dev@der-flo.net>
Date: Mon, 16 Nov 2020 19:37:52 +0100
From: Florian Lehner <dev@...-flo.net>
To: bpf@...r.kernel.org
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
john.fastabend@...il.com, peterz@...radead.org, mingo@...hat.com,
acme@...nel.org, Florian Lehner <dev@...-flo.net>
Subject: [FIX bpf,perf] bpf,perf: return EOPNOTSUPP for bpf handler on PERF_COUNT_SW_DUMMY
bpf handlers for perf events other than tracepoints, kprobes or uprobes
are attached to the overflow_handler of the perf event.
Perf events of type software/dummy are placeholder events. So when
attaching a bpf handle to an overflow_handler of such an event, the bpf
handler will not be triggered.
This fix returns the error EOPNOTSUPP to indicate that attaching a bpf
handler to a perf event of type software/dummy is not supported.
Signed-off-by: Florian Lehner <dev@...-flo.net>
---
kernel/events/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index da467e1dd49a..4e8846b7ceda 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9668,6 +9668,10 @@ static int perf_event_set_bpf_handler(struct perf_event *event, u32 prog_fd)
if (event->prog)
return -EEXIST;
+ if (event->attr.type == PERF_TYPE_SOFTWARE &&
+ event->attr.config == PERF_COUNT_SW_DUMMY)
+ return -EOPNOTSUPP;
+
prog = bpf_prog_get_type(prog_fd, BPF_PROG_TYPE_PERF_EVENT);
if (IS_ERR(prog))
return PTR_ERR(prog);
--
2.28.0
Powered by blists - more mailing lists