Skip to content

Commit 0a041eb

Browse files
namhyungPeter Zijlstra
authored andcommitted
perf/core: Call LSM hook after copying perf_event_attr
It passes the attr struct to the security_perf_event_open() but it's not initialized yet. Fixes: da97e18 ("perf_event: Add support for LSM and SELinux checks") Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20221220223140.4020470-1-namhyung@kernel.org
1 parent a551844 commit 0a041eb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/events/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12321,12 +12321,12 @@ SYSCALL_DEFINE5(perf_event_open,
1232112321
if (flags & ~PERF_FLAG_ALL)
1232212322
return -EINVAL;
1232312323

12324-
/* Do we allow access to perf_event_open(2) ? */
12325-
err = security_perf_event_open(&attr, PERF_SECURITY_OPEN);
12324+
err = perf_copy_attr(attr_uptr, &attr);
1232612325
if (err)
1232712326
return err;
1232812327

12329-
err = perf_copy_attr(attr_uptr, &attr);
12328+
/* Do we allow access to perf_event_open(2) ? */
12329+
err = security_perf_event_open(&attr, PERF_SECURITY_OPEN);
1233012330
if (err)
1233112331
return err;
1233212332

0 commit comments

Comments
 (0)