mirror of https://github.com/torvalds/linux.git
trace: use override credential guard
Use override credential guards for scoped credential override with automatic restoration on scope exit. Link: https://patch.msgid.link/20251103-work-creds-guards-prepare_creds-v1-12-b447b82f2c9b@kernel.org Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
2ed6a34de9
commit
06765b6efc
|
|
@ -1449,9 +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;
|
||||
|
||||
CLASS(prepare_creds, cred)();
|
||||
if (!cred)
|
||||
return -ENOMEM;
|
||||
|
|
@ -1467,16 +1464,12 @@ static int user_event_set_call_visible(struct user_event *user, bool visible)
|
|||
*/
|
||||
cred->fsuid = GLOBAL_ROOT_UID;
|
||||
|
||||
old_cred = override_creds(cred);
|
||||
scoped_with_creds(cred) {
|
||||
if (visible)
|
||||
return trace_add_event_call(&user->call);
|
||||
|
||||
if (visible)
|
||||
ret = trace_add_event_call(&user->call);
|
||||
else
|
||||
ret = trace_remove_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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue