Skip to content

Commit c707a4b

Browse files
committed
WIP: selftests/bpf: Fix test task_pt_regs on arm 32-bit
Have error: test_task_pt_regs:PASS:uprobe_offset 0 nsec test_task_pt_regs:PASS:skel_open 0 nsec test_task_pt_regs:PASS:check_bss 0 nsec test_task_pt_regs:PASS:attach_uprobe 0 nsec test_task_pt_regs:FAIL:check_uprobe_res unexpected check_uprobe_res: actual 0 != expected 1 torvalds#424 task_pt_regs:FAIL due to progs/test_task_pt_regs.c using: #define PT_REGS_SIZE sizeof(struct pt_regs) which is non-CORE and evaluates to wrong size in 64-bit BPF VM. Workaround is using bpf_core_type_size() to limit the actual read but leave the potentially larger PT_REGS_SIZE for the allocation. Signed-off-by: Tony Ambardar <[email protected]>
1 parent 903dcff commit c707a4b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/testing/selftests/bpf/progs/test_task_pt_regs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22

33
#include "vmlinux.h"
4-
#include <bpf/bpf_helpers.h>
4+
#include <bpf/bpf_core_read.h>
55
#include <bpf/bpf_tracing.h>
66

77
#define PT_REGS_SIZE sizeof(struct pt_regs)
@@ -19,12 +19,14 @@ int handle_uprobe(struct pt_regs *ctx)
1919
{
2020
struct task_struct *current;
2121
struct pt_regs *regs;
22+
int regs_size;
2223

2324
current = bpf_get_current_task_btf();
2425
regs = (struct pt_regs *) bpf_task_pt_regs(current);
25-
if (bpf_probe_read_kernel(current_regs, PT_REGS_SIZE, regs))
26+
regs_size = bpf_core_type_size(struct pt_regs);
27+
if (bpf_probe_read_kernel(current_regs, regs_size, regs))
2628
return 0;
27-
if (bpf_probe_read_kernel(ctx_regs, PT_REGS_SIZE, ctx))
29+
if (bpf_probe_read_kernel(ctx_regs, regs_size, ctx))
2830
return 0;
2931

3032
/* Prove that uprobe was run */

0 commit comments

Comments
 (0)