Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf cap: Add __NR_capget to arch/x86 unistd

As there are duplicated kernel headers in tools/include libc can pick
up the wrong definitions. This was causing the wrong system call for
capget in perf.

Reported-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: e25ebda78e230283 ("perf cap: Tidy up and improve capability testing")
Closes: https://lore.kernel.org/lkml/cc7d6bdf-1aeb-4179-9029-4baf50b59342@intel.com/
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20241026055448.312247-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
a5384c42 55f1b540

+9 -7
+3
tools/arch/x86/include/uapi/asm/unistd_32.h
··· 11 11 #ifndef __NR_getpgid 12 12 #define __NR_getpgid 132 13 13 #endif 14 + #ifndef __NR_capget 15 + #define __NR_capget 184 16 + #endif 14 17 #ifndef __NR_gettid 15 18 #define __NR_gettid 224 16 19 #endif
+3
tools/arch/x86/include/uapi/asm/unistd_64.h
··· 11 11 #ifndef __NR_getpgid 12 12 #define __NR_getpgid 121 13 13 #endif 14 + #ifndef __NR_capget 15 + #define __NR_capget 125 16 + #endif 14 17 #ifndef __NR_gettid 15 18 #define __NR_gettid 186 16 19 #endif
+3 -7
tools/perf/util/cap.c
··· 7 7 #include "debug.h" 8 8 #include <errno.h> 9 9 #include <string.h> 10 - #include <unistd.h> 11 10 #include <linux/capability.h> 12 11 #include <sys/syscall.h> 13 - 14 - #ifndef SYS_capget 15 - #define SYS_capget 90 16 - #endif 12 + #include <unistd.h> 17 13 18 14 #define MAX_LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_3 19 15 ··· 17 21 { 18 22 struct __user_cap_header_struct header = { 19 23 .version = _LINUX_CAPABILITY_VERSION_3, 20 - .pid = getpid(), 24 + .pid = 0, 21 25 }; 22 - struct __user_cap_data_struct data[MAX_LINUX_CAPABILITY_U32S]; 26 + struct __user_cap_data_struct data[MAX_LINUX_CAPABILITY_U32S] = {}; 23 27 __u32 cap_val; 24 28 25 29 *used_root = false;