From 1bce2afb84c88594d2ff50d7159095170564f3a0 Mon Sep 17 00:00:00 2001 From: Willow Cunningham Date: Thu, 10 Oct 2024 16:27:13 -0400 Subject: [PATCH] perf_event: Eliminate permission error for check_exclude_guest() with paranoid kernel On systems with perf_event_paranoid>=2, userspace calls to perf_event_open() must set attr.exclude_kernel=1. Set exclude_kernel=1 in check_exclude_guest() to allow the function to execute successfully on systems with perf_event_paranoid>=2; --- src/components/perf_event/perf_event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/perf_event/perf_event.c b/src/components/perf_event/perf_event.c index 7c16b6d0c..d2fbbfa7c 100644 --- a/src/components/perf_event/perf_event.c +++ b/src/components/perf_event/perf_event.c @@ -285,6 +285,7 @@ check_exclude_guest( void ) /* First check that we can open a plain instructions event */ memset(&attr, 0 , sizeof(attr)); attr.config = PERF_COUNT_HW_INSTRUCTIONS; + attr.exclude_kernel=1; ev_fd = sys_perf_event_open( &attr, 0, -1, -1, 0 ); if ( ev_fd == -1 ) { @@ -296,6 +297,7 @@ check_exclude_guest( void ) /* Now try again with excude_guest */ memset(&attr, 0 , sizeof(attr)); attr.config = PERF_COUNT_HW_INSTRUCTIONS; + attr.exclude_kernel=1; attr.exclude_guest=1; ev_fd = sys_perf_event_open( &attr, 0, -1, -1, 0 );