[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tip-8bdqv1q0ndcjl1nqns5r5je2@git.kernel.org>
Date: Thu, 6 Sep 2018 06:15:04 -0700
From: tip-bot for Arnaldo Carvalho de Melo <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: tglx@...utronix.de, acme@...hat.com, adrian.hunter@...el.com,
namhyung@...nel.org, dsahern@...il.com, hpa@...or.com,
wangnan0@...wei.com, mingo@...nel.org, jolsa@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip:perf/core] perf trace augmented_syscalls: Add
augmented_sockaddr_syscall_enter()
Commit-ID: 24a6c2cd1dbd85bd5624a6d0b05de891d0f07696
Gitweb: https://git.kernel.org/tip/24a6c2cd1dbd85bd5624a6d0b05de891d0f07696
Author: Arnaldo Carvalho de Melo <acme@...hat.com>
AuthorDate: Tue, 28 Aug 2018 16:39:11 -0300
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Thu, 30 Aug 2018 15:52:20 -0300
perf trace augmented_syscalls: Add augmented_sockaddr_syscall_enter()
>From the one for 'connect', so that we can use it with sendto and others
that receive a 'struct sockaddr'.
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Wang Nan <wangnan0@...wei.com>
Link: https://lkml.kernel.org/n/tip-8bdqv1q0ndcjl1nqns5r5je2@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/examples/bpf/augmented_syscalls.c | 46 ++++++++++++++++------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/tools/perf/examples/bpf/augmented_syscalls.c b/tools/perf/examples/bpf/augmented_syscalls.c
index 6dfead0be74e..5f417e528419 100644
--- a/tools/perf/examples/bpf/augmented_syscalls.c
+++ b/tools/perf/examples/bpf/augmented_syscalls.c
@@ -95,6 +95,31 @@ struct syscall_enter_newstat_args {
augmented_filename_syscall_enter(newstat);
+#ifndef _K_SS_MAXSIZE
+#define _K_SS_MAXSIZE 128
+#endif
+
+#define augmented_sockaddr_syscall_enter(syscall) \
+struct augmented_enter_##syscall##_args { \
+ struct syscall_enter_##syscall##_args args; \
+ struct sockaddr_storage addr; \
+}; \
+int syscall_enter(syscall)(struct syscall_enter_##syscall##_args *args) \
+{ \
+ struct augmented_enter_##syscall##_args augmented_args; \
+ unsigned long addrlen = sizeof(augmented_args.addr); \
+ probe_read(&augmented_args.args, sizeof(augmented_args.args), args); \
+/* FIXME_CLANG_OPTIMIZATION_THAT_ACCESSES_USER_CONTROLLED_ADDRLEN_DESPITE_THIS_CHECK */ \
+/* if (addrlen > augmented_args.args.addrlen) */ \
+/* addrlen = augmented_args.args.addrlen; */ \
+/* */ \
+ probe_read(&augmented_args.addr, addrlen, args->addr_ptr); \
+ perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, \
+ &augmented_args, \
+ sizeof(augmented_args) - sizeof(augmented_args.addr) + addrlen); \
+ return 0; \
+}
+
struct sockaddr;
struct syscall_enter_connect_args {
@@ -105,25 +130,6 @@ struct syscall_enter_connect_args {
unsigned long addrlen;
};
-struct augmented_enter_connect_args {
- struct syscall_enter_connect_args args;
- struct sockaddr_storage addr;
-};
-
-int syscall_enter(connect)(struct syscall_enter_connect_args *args)
-{
- struct augmented_enter_connect_args augmented_args;
- unsigned long addrlen = sizeof(augmented_args.addr);
-
- probe_read(&augmented_args.args, sizeof(augmented_args.args), args);
-#ifdef FIXME_CLANG_OPTIMIZATION_THAT_ACCESSES_USER_CONTROLLED_ADDRLEN_DESPITE_THIS_CHECK
- if (addrlen > augmented_args.args.addrlen)
- addrlen = augmented_args.args.addrlen;
-#endif
- probe_read(&augmented_args.addr, addrlen, args->addr_ptr);
- perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, &augmented_args,
- sizeof(augmented_args) - sizeof(augmented_args.addr) + addrlen);
- return 0;
-}
+augmented_sockaddr_syscall_enter(connect);
license(GPL);
Powered by blists - more mailing lists