Skip to content

Commit a5384c4

Browse files
captain5050acmel
authored andcommitted
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 <[email protected]> Fixes: e25ebda ("perf cap: Tidy up and improve capability testing") Closes: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Ian Rogers <[email protected]> Tested-by: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 55f1b54 commit a5384c4

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

tools/arch/x86/include/uapi/asm/unistd_32.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#ifndef __NR_getpgid
1212
#define __NR_getpgid 132
1313
#endif
14+
#ifndef __NR_capget
15+
#define __NR_capget 184
16+
#endif
1417
#ifndef __NR_gettid
1518
#define __NR_gettid 224
1619
#endif

tools/arch/x86/include/uapi/asm/unistd_64.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#ifndef __NR_getpgid
1212
#define __NR_getpgid 121
1313
#endif
14+
#ifndef __NR_capget
15+
#define __NR_capget 125
16+
#endif
1417
#ifndef __NR_gettid
1518
#define __NR_gettid 186
1619
#endif

tools/perf/util/cap.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,19 @@
77
#include "debug.h"
88
#include <errno.h>
99
#include <string.h>
10-
#include <unistd.h>
1110
#include <linux/capability.h>
1211
#include <sys/syscall.h>
13-
14-
#ifndef SYS_capget
15-
#define SYS_capget 90
16-
#endif
12+
#include <unistd.h>
1713

1814
#define MAX_LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_3
1915

2016
bool perf_cap__capable(int cap, bool *used_root)
2117
{
2218
struct __user_cap_header_struct header = {
2319
.version = _LINUX_CAPABILITY_VERSION_3,
24-
.pid = getpid(),
20+
.pid = 0,
2521
};
26-
struct __user_cap_data_struct data[MAX_LINUX_CAPABILITY_U32S];
22+
struct __user_cap_data_struct data[MAX_LINUX_CAPABILITY_U32S] = {};
2723
__u32 cap_val;
2824

2925
*used_root = false;

0 commit comments

Comments
 (0)