From 6da96d4e14f9d11ce8ef9aaf9e039a3199fb6f50 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Sep 04 2020 18:27:29 +0000 Subject: import bcc-0.14.0-4.el8 --- diff --git a/SOURCES/bcc-0.14.0-Fix-KFUNC_PROBE-return-value.patch b/SOURCES/bcc-0.14.0-Fix-KFUNC_PROBE-return-value.patch new file mode 100644 index 0000000..622c0cd --- /dev/null +++ b/SOURCES/bcc-0.14.0-Fix-KFUNC_PROBE-return-value.patch @@ -0,0 +1,92 @@ +From cdfa74f35910421e807d7e1deb212a5bca138413 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mauricio=20V=C3=A1squez?= +Date: Thu, 21 May 2020 11:50:52 -0500 +Subject: [PATCH 1/3] Fix KFUNC_PROBE return value +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The KFUNC_PROBE macro is using "void" as return type, this is causing problems +in some tools that have a filtering enable that returns 0. + +Reproducer: (Notice that it requires BTF support) + +``` +$ python opensnoop.py --pid 5 +/virtual/main.c:33:21: error: void function '____kretfunc__do_sys_open' should not return a value [-Wreturn-type] + if (pid != 5) { return 0; } + ^ ~ +1 error generated. +... +``` + +Signed-off-by: Mauricio Vásquez +--- + src/cc/export/helpers.h | 4 ++-- + tools/klockstat.py | 6 +++--- + tools/opensnoop.py | 2 ++ + 3 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/src/cc/export/helpers.h b/src/cc/export/helpers.h +index b38b3f20..c6edc9cd 100644 +--- a/src/cc/export/helpers.h ++++ b/src/cc/export/helpers.h +@@ -998,7 +998,7 @@ int raw_tracepoint__##event(struct bpf_raw_tracepoint_args *ctx) + #define BPF_PROG(name, args...) \ + int name(unsigned long long *ctx); \ + __attribute__((always_inline)) \ +-static void ____##name(unsigned long long *ctx, ##args); \ ++static int ____##name(unsigned long long *ctx, ##args); \ + int name(unsigned long long *ctx) \ + { \ + _Pragma("GCC diagnostic push") \ +@@ -1007,7 +1007,7 @@ int name(unsigned long long *ctx) \ + _Pragma("GCC diagnostic pop") \ + return 0; \ + } \ +-static void ____##name(unsigned long long *ctx, ##args) ++static int ____##name(unsigned long long *ctx, ##args) + + #define KFUNC_PROBE(event, args...) \ + BPF_PROG(kfunc__ ## event, args) +diff --git a/tools/klockstat.py b/tools/klockstat.py +index 540dd4e7..7cb15ad3 100755 +--- a/tools/klockstat.py ++++ b/tools/klockstat.py +@@ -352,17 +352,17 @@ int mutex_lock_enter(struct pt_regs *ctx) + program_kfunc = """ + KFUNC_PROBE(mutex_unlock, void *lock) + { +- do_mutex_unlock_enter(); ++ return do_mutex_unlock_enter(); + } + + KRETFUNC_PROBE(mutex_lock, void *lock, int ret) + { +- do_mutex_lock_return(); ++ return do_mutex_lock_return(); + } + + KFUNC_PROBE(mutex_lock, void *lock) + { +- do_mutex_lock_enter(ctx, 3); ++ return do_mutex_lock_enter(ctx, 3); + } + + """ +diff --git a/tools/opensnoop.py b/tools/opensnoop.py +index b28d7d55..9a526625 100755 +--- a/tools/opensnoop.py ++++ b/tools/opensnoop.py +@@ -197,6 +197,8 @@ KRETFUNC_PROBE(do_sys_open, int dfd, const char *filename, int flags, int mode, + data.ret = ret; + + events.perf_submit(ctx, &data, sizeof(data)); ++ ++ return 0: + } + """ + +-- +2.25.4 + diff --git a/SOURCES/bcc-0.14.0-Forbid-trampolines-for-archs-other-than-x86_64.patch b/SOURCES/bcc-0.14.0-Forbid-trampolines-for-archs-other-than-x86_64.patch new file mode 100644 index 0000000..76742c1 --- /dev/null +++ b/SOURCES/bcc-0.14.0-Forbid-trampolines-for-archs-other-than-x86_64.patch @@ -0,0 +1,47 @@ +From 3a8276749b291404ec160c1eb0b51925037161aa Mon Sep 17 00:00:00 2001 +From: Jiri Olsa +Date: Wed, 19 Aug 2020 12:47:48 +0200 +Subject: [PATCH 3/3] Forbid trampolines for archs other than x86_64 + +The trampoline support check in bcc does not work properly, +so the feature is detected even on architectures that do not +support it - all archs other than x86_64. + +We are checking for bpf_trampoline_link_prog to exist in +kernel, which works fine on x86_64 to check if the feature +is supported, but it's global function, so it exists also +in other archs even when the feature is not supported +so it returns True also on other archs. + +Adding explicit x86_64 check to support_kfunc function. + +Signed-off-by: Jiri Olsa +--- + src/python/bcc/__init__.py | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py +index 5b3ff7b2..60ba6ec5 100644 +--- a/src/python/bcc/__init__.py ++++ b/src/python/bcc/__init__.py +@@ -22,6 +22,7 @@ import re + import struct + import errno + import sys ++import platform + + from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE + from .table import Table, PerfEventArray +@@ -884,6 +885,9 @@ DEBUG_BTF = 0x20 + + @staticmethod + def support_kfunc(): ++ # there's no trampoline support for other than x86_64 arch ++ if platform.machine() != 'x86_64': ++ return False; + if not lib.bpf_has_kernel_btf(): + return False; + # kernel symbol "bpf_trampoline_link_prog" indicates kfunc support +-- +2.25.4 + diff --git a/SOURCES/bcc-0.14.0-tools-opensnoop-Fix-compilation-problem.patch b/SOURCES/bcc-0.14.0-tools-opensnoop-Fix-compilation-problem.patch new file mode 100644 index 0000000..0dbeff5 --- /dev/null +++ b/SOURCES/bcc-0.14.0-tools-opensnoop-Fix-compilation-problem.patch @@ -0,0 +1,31 @@ +From 39a4af00c99327d9498c2e1232afdfa49fa1e564 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mauricio=20V=C3=A1squez?= +Date: Mon, 8 Jun 2020 08:12:08 -0500 +Subject: [PATCH 2/3] tools/opensnoop: Fix compilation problem +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fix stupid bug introduced by myself. + +Signed-off-by: Mauricio Vásquez +--- + tools/opensnoop.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/opensnoop.py b/tools/opensnoop.py +index 9a526625..b7408e7c 100755 +--- a/tools/opensnoop.py ++++ b/tools/opensnoop.py +@@ -198,7 +198,7 @@ KRETFUNC_PROBE(do_sys_open, int dfd, const char *filename, int flags, int mode, + + events.perf_submit(ctx, &data, sizeof(data)); + +- return 0: ++ return 0; + } + """ + +-- +2.25.4 + diff --git a/SPECS/bcc.spec b/SPECS/bcc.spec index 743d8c6..0591175 100644 --- a/SPECS/bcc.spec +++ b/SPECS/bcc.spec @@ -5,7 +5,7 @@ Name: bcc Version: 0.14.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: BPF Compiler Collection (BCC) License: ASL 2.0 URL: https://github.com/iovisor/bcc @@ -19,6 +19,9 @@ Patch3: %{name}-%{version}-loader-suggest-to-install-the-right-kernel-de Patch4: %{name}-%{version}-tools-fix-a-python-3-map-issue-in-dbstat-and-dbslowe.patch Patch5: %{name}-%{version}-Add-KBUILD_MODNAME-flag-to-default-cflags.patch Patch6: %{name}-%{version}-Delete-existing-kbuild_modname-definitions.patch +Patch7: %{name}-%{version}-Fix-KFUNC_PROBE-return-value.patch +Patch8: %{name}-%{version}-tools-opensnoop-Fix-compilation-problem.patch +Patch9: %{name}-%{version}-Forbid-trampolines-for-archs-other-than-x86_64.patch # Arches will be included as upstream support is added and dependencies are # satisfied in the respective arches @@ -208,6 +211,10 @@ done %changelog +* Wed Sep 02 2020 Jerome Marchand - 0.14.0-4 +- Fix KFUNC_PROBE return value +- Forbid trampolines on unsupported arches + * Tue Jul 21 2020 Jerome Marchand - 0.14.0-3 - Add KBUILD_MODNAME flag to default cflags