* [PATCH v1] perf cap: Add __NR_capget to arch/x86 unistd
@ 2024-10-26 5:54 Ian Rogers
2024-10-26 6:00 ` Ian Rogers
0 siblings, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2024-10-26 5:54 UTC (permalink / raw)
To: Adrian Hunter
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Kan Liang, linux-kernel, linux-perf-users
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.
Closes: https://lore.kernel.org/lkml/cc7d6bdf-1aeb-4179-9029-4baf50b59342@intel.com/
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/arch/x86/include/uapi/asm/unistd_32.h | 3 +++
tools/arch/x86/include/uapi/asm/unistd_64.h | 3 +++
tools/perf/util/cap.c | 10 +++-------
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h
index 9de35df1afc3..63182a023e9d 100644
--- a/tools/arch/x86/include/uapi/asm/unistd_32.h
+++ b/tools/arch/x86/include/uapi/asm/unistd_32.h
@@ -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
diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h
index d0f2043d7132..77311e8d1b5d 100644
--- a/tools/arch/x86/include/uapi/asm/unistd_64.h
+++ b/tools/arch/x86/include/uapi/asm/unistd_64.h
@@ -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
diff --git a/tools/perf/util/cap.c b/tools/perf/util/cap.c
index 7574a67651bc..69d9a2bcd40b 100644
--- a/tools/perf/util/cap.c
+++ b/tools/perf/util/cap.c
@@ -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;
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf cap: Add __NR_capget to arch/x86 unistd
2024-10-26 5:54 [PATCH v1] perf cap: Add __NR_capget to arch/x86 unistd Ian Rogers
@ 2024-10-26 6:00 ` Ian Rogers
2024-10-28 7:25 ` Adrian Hunter
0 siblings, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2024-10-26 6:00 UTC (permalink / raw)
To: Adrian Hunter
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Kan Liang, linux-kernel, linux-perf-users
On Fri, Oct 25, 2024 at 10:54 PM Ian Rogers <irogers@google.com> wrote:
>
> 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.
>
> Closes: https://lore.kernel.org/lkml/cc7d6bdf-1aeb-4179-9029-4baf50b59342@intel.com/
> Signed-off-by: Ian Rogers <irogers@google.com>
Forgot:
Fixes: e25ebda78e23 ("perf cap: Tidy up and improve capability testing")
Thanks,
Ian
> ---
> tools/arch/x86/include/uapi/asm/unistd_32.h | 3 +++
> tools/arch/x86/include/uapi/asm/unistd_64.h | 3 +++
> tools/perf/util/cap.c | 10 +++-------
> 3 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h
> index 9de35df1afc3..63182a023e9d 100644
> --- a/tools/arch/x86/include/uapi/asm/unistd_32.h
> +++ b/tools/arch/x86/include/uapi/asm/unistd_32.h
> @@ -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
> diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h
> index d0f2043d7132..77311e8d1b5d 100644
> --- a/tools/arch/x86/include/uapi/asm/unistd_64.h
> +++ b/tools/arch/x86/include/uapi/asm/unistd_64.h
> @@ -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
> diff --git a/tools/perf/util/cap.c b/tools/perf/util/cap.c
> index 7574a67651bc..69d9a2bcd40b 100644
> --- a/tools/perf/util/cap.c
> +++ b/tools/perf/util/cap.c
> @@ -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;
> --
> 2.47.0.163.g1226f6d8fa-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf cap: Add __NR_capget to arch/x86 unistd
2024-10-26 6:00 ` Ian Rogers
@ 2024-10-28 7:25 ` Adrian Hunter
2024-10-28 16:08 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 4+ messages in thread
From: Adrian Hunter @ 2024-10-28 7:25 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Kan Liang, linux-kernel, linux-perf-users
On 26/10/24 09:00, Ian Rogers wrote:
> On Fri, Oct 25, 2024 at 10:54 PM Ian Rogers <irogers@google.com> wrote:
>>
>> 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.
>>
>> Closes: https://lore.kernel.org/lkml/cc7d6bdf-1aeb-4179-9029-4baf50b59342@intel.com/
>> Signed-off-by: Ian Rogers <irogers@google.com>
>
> Forgot:
> Fixes: e25ebda78e23 ("perf cap: Tidy up and improve capability testing")
Works for me, thank you!
Tested-by: Adrian Hunter <adrian.hunter@intel.com>
>
> Thanks,
> Ian
>
>> ---
>> tools/arch/x86/include/uapi/asm/unistd_32.h | 3 +++
>> tools/arch/x86/include/uapi/asm/unistd_64.h | 3 +++
>> tools/perf/util/cap.c | 10 +++-------
>> 3 files changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h
>> index 9de35df1afc3..63182a023e9d 100644
>> --- a/tools/arch/x86/include/uapi/asm/unistd_32.h
>> +++ b/tools/arch/x86/include/uapi/asm/unistd_32.h
>> @@ -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
>> diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h
>> index d0f2043d7132..77311e8d1b5d 100644
>> --- a/tools/arch/x86/include/uapi/asm/unistd_64.h
>> +++ b/tools/arch/x86/include/uapi/asm/unistd_64.h
>> @@ -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
>> diff --git a/tools/perf/util/cap.c b/tools/perf/util/cap.c
>> index 7574a67651bc..69d9a2bcd40b 100644
>> --- a/tools/perf/util/cap.c
>> +++ b/tools/perf/util/cap.c
>> @@ -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;
>> --
>> 2.47.0.163.g1226f6d8fa-goog
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] perf cap: Add __NR_capget to arch/x86 unistd
2024-10-28 7:25 ` Adrian Hunter
@ 2024-10-28 16:08 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-10-28 16:08 UTC (permalink / raw)
To: Adrian Hunter
Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Namhyung Kim,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Kan Liang,
linux-kernel, linux-perf-users
On Mon, Oct 28, 2024 at 09:25:36AM +0200, Adrian Hunter wrote:
> On 26/10/24 09:00, Ian Rogers wrote:
> > On Fri, Oct 25, 2024 at 10:54 PM Ian Rogers <irogers@google.com> wrote:
> >>
> >> 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.
> >>
> >> Closes: https://lore.kernel.org/lkml/cc7d6bdf-1aeb-4179-9029-4baf50b59342@intel.com/
> >> Signed-off-by: Ian Rogers <irogers@google.com>
> >
> > Forgot:
> > Fixes: e25ebda78e23 ("perf cap: Tidy up and improve capability testing")
>
> Works for me, thank you!
>
> Tested-by: Adrian Hunter <adrian.hunter@intel.com>
Thanks, I also added this:
Reported-by: Adrian Hunter <adrian.hunter@intel.com>
Applied to perf-tools, for v6.12-rc.
- Arnaldo
> >
> > Thanks,
> > Ian
> >
> >> ---
> >> tools/arch/x86/include/uapi/asm/unistd_32.h | 3 +++
> >> tools/arch/x86/include/uapi/asm/unistd_64.h | 3 +++
> >> tools/perf/util/cap.c | 10 +++-------
> >> 3 files changed, 9 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/tools/arch/x86/include/uapi/asm/unistd_32.h b/tools/arch/x86/include/uapi/asm/unistd_32.h
> >> index 9de35df1afc3..63182a023e9d 100644
> >> --- a/tools/arch/x86/include/uapi/asm/unistd_32.h
> >> +++ b/tools/arch/x86/include/uapi/asm/unistd_32.h
> >> @@ -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
> >> diff --git a/tools/arch/x86/include/uapi/asm/unistd_64.h b/tools/arch/x86/include/uapi/asm/unistd_64.h
> >> index d0f2043d7132..77311e8d1b5d 100644
> >> --- a/tools/arch/x86/include/uapi/asm/unistd_64.h
> >> +++ b/tools/arch/x86/include/uapi/asm/unistd_64.h
> >> @@ -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
> >> diff --git a/tools/perf/util/cap.c b/tools/perf/util/cap.c
> >> index 7574a67651bc..69d9a2bcd40b 100644
> >> --- a/tools/perf/util/cap.c
> >> +++ b/tools/perf/util/cap.c
> >> @@ -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;
> >> --
> >> 2.47.0.163.g1226f6d8fa-goog
> >>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-28 16:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-26 5:54 [PATCH v1] perf cap: Add __NR_capget to arch/x86 unistd Ian Rogers
2024-10-26 6:00 ` Ian Rogers
2024-10-28 7:25 ` Adrian Hunter
2024-10-28 16:08 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).