Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 08ef1af

Browse files
WOnder93Peter Zijlstra
authored andcommitted
perf/core: Fix unconditional security_locked_down() call
Currently, the lockdown state is queried unconditionally, even though its result is used only if the PERF_SAMPLE_REGS_INTR bit is set in attr.sample_type. While that doesn't matter in case of the Lockdown LSM, it causes trouble with the SELinux's lockdown hook implementation. SELinux implements the locked_down hook with a check whether the current task's type has the corresponding "lockdown" class permission ("integrity" or "confidentiality") allowed in the policy. This means that calling the hook when the access control decision would be ignored generates a bogus permission check and audit record. Fix this by checking sample_type first and only calling the hook when its result would be honored. Fixes: b0c8fdc ("lockdown: Lock down perf when in confidentiality mode") Signed-off-by: Ondrej Mosnacek <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Paul Moore <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent ff65338 commit 08ef1af

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/events/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11833,12 +11833,12 @@ SYSCALL_DEFINE5(perf_event_open,
1183311833
return err;
1183411834
}
1183511835

11836-
err = security_locked_down(LOCKDOWN_PERF);
11837-
if (err && (attr.sample_type & PERF_SAMPLE_REGS_INTR))
11838-
/* REGS_INTR can leak data, lockdown must prevent this */
11839-
return err;
11840-
11841-
err = 0;
11836+
/* REGS_INTR can leak data, lockdown must prevent this */
11837+
if (attr.sample_type & PERF_SAMPLE_REGS_INTR) {
11838+
err = security_locked_down(LOCKDOWN_PERF);
11839+
if (err)
11840+
return err;
11841+
}
1184211842

1184311843
/*
1184411844
* In cgroup mode, the pid argument is used to pass the fd

0 commit comments

Comments
 (0)