Skip to content

Commit

Permalink
tests: runtime: fix kprobe_offset_module* on aarch64
Browse files Browse the repository at this point in the history
For kprobe_offset_module:
On aarch64, +0x5 is not a correct offset. Since +0x4 is reserved by
ftrace, the test should use +0x8, which is the same as ppc64.

For kprobe_offset_module_error:
nft_trans_alloc_gfp is not in vmlinux so usermode offset check is
skipped. The kernel will return -EINVAL instead of -EILSEQ during
arch_prepare_kprobe() on aarch64, so change the expected string.

Signed-off-by: Tianchen Ding <dtcccc@linux.alibaba.com>
  • Loading branch information
dtcccc authored and viktormalik committed Dec 13, 2023
1 parent 1d28b69 commit 54090e3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/runtime/probe
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,18 @@ NAME kprobe_offset_module
RUN {{BPFTRACE}} -e 'kprobe:nft_trans_alloc_gfp+0x5 { printf("hit\n"); exit(); }'
AFTER /usr/sbin/nft add table bpftrace
EXPECT hit
ARCH x86_64|aarch64
ARCH x86_64
TIMEOUT 5
REQUIRES lsmod | grep '^nf_tables'
REQUIRES /usr/sbin/nft --help
CLEANUP /usr/sbin/nft delete table bpftrace

# Local entry point to nft_trans_alloc_gfp is located at offset of 8 bytes in ppc64.
# Local entry point to nft_trans_alloc_gfp is located at offset of 8 bytes in ppc64 and aarch64.
NAME kprobe_offset_module
RUN {{BPFTRACE}} -e 'kprobe:nft_trans_alloc_gfp+0x8 { printf("hit\n"); exit(); }'
AFTER /usr/sbin/nft add table bpftrace
EXPECT hit
ARCH ppc64|ppc64le
ARCH ppc64|ppc64le|aarch64
TIMEOUT 5
REQUIRES lsmod | grep '^nf_tables'
REQUIRES /usr/sbin/nft --help
Expand All @@ -173,6 +173,15 @@ CLEANUP /usr/sbin/nft delete table bpftrace
NAME kprobe_offset_module_error
RUN {{BPFTRACE}} -e 'kprobe:nft_trans_alloc_gfp+0x1 { printf("hit\n"); exit(); }'
EXPECT Possible attachment attempt in the middle of an instruction, try a different offset.
ARCH x86_64
TIMEOUT 5
REQUIRES lsmod | grep '^nf_tables'
WILL_FAIL

NAME kprobe_offset_module_error
RUN {{BPFTRACE}} -e 'kprobe:nft_trans_alloc_gfp+0x1 { printf("hit\n"); exit(); }'
EXPECT Invalid argument
ARCH aarch64
TIMEOUT 5
REQUIRES lsmod | grep '^nf_tables'
WILL_FAIL
Expand Down

0 comments on commit 54090e3

Please sign in to comment.