]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf cap: Add __NR_capget to arch/x86 unistd
authorIan Rogers <irogers@google.com>
Sat, 26 Oct 2024 05:54:48 +0000 (22:54 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 28 Oct 2024 16:04:52 +0000 (13:04 -0300)
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>
tools/arch/x86/include/uapi/asm/unistd_32.h
tools/arch/x86/include/uapi/asm/unistd_64.h
tools/perf/util/cap.c

index 9de35df1afc31f7e66fd014c9fce250900dd1ca5..63182a023e9df79e200a480d1994fb7d8e26297e 100644 (file)
@@ -11,6 +11,9 @@
 #ifndef __NR_getpgid
 #define __NR_getpgid 132
 #endif
+#ifndef __NR_capget
+#define __NR_capget 184
+#endif
 #ifndef __NR_gettid
 #define __NR_gettid 224
 #endif
index d0f2043d713205c6d70c5393c444deb2fb035fb4..77311e8d1b5d38cde163fe47dbddfd5d13629310 100644 (file)
@@ -11,6 +11,9 @@
 #ifndef __NR_getpgid
 #define __NR_getpgid 121
 #endif
+#ifndef __NR_capget
+#define __NR_capget 125
+#endif
 #ifndef __NR_gettid
 #define __NR_gettid 186
 #endif
index 7574a67651bc545a5e3358a6295457b82f7d5f95..69d9a2bcd40bfdd105c788644a4808460dcc16b7 100644 (file)
@@ -7,13 +7,9 @@
 #include "debug.h"
 #include <errno.h>
 #include <string.h>
-#include <unistd.h>
 #include <linux/capability.h>
 #include <sys/syscall.h>
-
-#ifndef SYS_capget
-#define SYS_capget 90
-#endif
+#include <unistd.h>
 
 #define MAX_LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_3
 
@@ -21,9 +17,9 @@ bool perf_cap__capable(int cap, bool *used_root)
 {
        struct __user_cap_header_struct header = {
                .version = _LINUX_CAPABILITY_VERSION_3,
-               .pid = getpid(),
+               .pid = 0,
        };
-       struct __user_cap_data_struct data[MAX_LINUX_CAPABILITY_U32S];
+       struct __user_cap_data_struct data[MAX_LINUX_CAPABILITY_U32S] = {};
        __u32 cap_val;
 
        *used_root = false;