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