[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251103-work-creds-guards-prepare_creds-v1-12-b447b82f2c9b@kernel.org>
Date: Mon, 03 Nov 2025 15:57:38 +0100
From: Christian Brauner <brauner@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-aio@...ck.org, linux-unionfs@...r.kernel.org,
linux-erofs@...ts.ozlabs.org, linux-nfs@...r.kernel.org,
linux-cifs@...r.kernel.org, samba-technical@...ts.samba.org,
cgroups@...r.kernel.org, netdev@...r.kernel.org,
linux-crypto@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
Christian Brauner <brauner@...nel.org>
Subject: [PATCH 12/12] trace: use override credential guard
Use override credential guards for scoped credential override with
automatic restoration on scope exit.
Signed-off-by: Christian Brauner <brauner@...nel.org>
---
kernel/trace/trace_events_user.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 3461b1d29276..4528c058d7cd 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1449,8 +1449,6 @@ static struct trace_event_functions user_event_funcs = {
static int user_event_set_call_visible(struct user_event *user, bool visible)
{
- int ret;
- const struct cred *old_cred;
struct cred *cred;
CLASS(prepare_creds, cred)();
@@ -1470,14 +1468,11 @@ static int user_event_set_call_visible(struct user_event *user, bool visible)
old_cred = override_creds(cred);
+ with_creds(cred);
if (visible)
- ret = trace_add_event_call(&user->call);
- else
- ret = trace_remove_event_call(&user->call);
+ return trace_add_event_call(&user->call);
- revert_creds(old_cred);
-
- return ret;
+ return trace_remove_event_call(&user->call);
}
static int destroy_user_event(struct user_event *user)
--
2.47.3
Powered by blists - more mailing lists