tracing/user_events: Allow events to persist for perfmon_capable users
authorBeau Belgrave <beaub@linux.microsoft.com>
Tue, 12 Sep 2023 18:07:02 +0000 (18:07 +0000)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 4 Oct 2023 02:29:43 +0000 (22:29 -0400)
commit5dbd04eddb2c0841d1b3930e0a9944a2343c9cac
treeca51bcfc37909d6bca592f9cd3dd1f89f1a7df47
parentbdf4fb628093b4ab2f4eb312256233a2ae0594b7
tracing/user_events: Allow events to persist for perfmon_capable users

There are several scenarios that have come up where having a user_event
persist even if the process that registered it exits. The main one is
having a daemon create events on bootup that shouldn't get deleted if
the daemon has to exit or reload. Another is within OpenTelemetry
exporters, they wish to potentially check if a user_event exists on the
system to determine if exporting the data out should occur. The
user_event in this case must exist even in the absence of the owning
process running (such as the above daemon case).

Expose the previously internal flag USER_EVENT_REG_PERSIST to user
processes. Upon register or delete of events with this flag, ensure the
user is perfmon_capable to prevent random user processes with access to
tracefs from creating events that persist after exit.

Link: https://lkml.kernel.org/r/20230912180704.1284-2-beaub@linux.microsoft.com
Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
include/uapi/linux/user_events.h
kernel/trace/trace_events_user.c