Skip to content

Commit

Permalink
Forbid trampolines for archs other than x86_64
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
olsajiri authored and yonghong-song committed Aug 20, 2020
1 parent 639e83f commit 49beed8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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, RingBuf, BPF_MAP_TYPE_QUEUE, BPF_MAP_TYPE_STACK
Expand Down Expand Up @@ -895,6 +896,9 @@ def add_prefix(prefix, name):

@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
Expand Down

0 comments on commit 49beed8

Please sign in to comment.