diff --git a/support/ebpf/interpreter_dispatcher.ebpf.c b/support/ebpf/interpreter_dispatcher.ebpf.c index 22962a57..eae4b72e 100644 --- a/support/ebpf/interpreter_dispatcher.ebpf.c +++ b/support/ebpf/interpreter_dispatcher.ebpf.c @@ -324,6 +324,13 @@ bool get_go_custom_labels(struct pt_regs *ctx, UnwindState *state, void *offsets DEBUG_PRINT("failed to read custom label: value too long"); continue; } + +#ifdef TESTING_COREDUMP + if (val_len > CUSTOM_LABEL_MAX_VAL_LEN) + res = bpf_probe_read(lbl->val.val_bytes, val_len, map_value->values[i].str); + else + res = -1; +#else // The following assembly statement is equivalent to: // if (val_len > CUSTOM_LABEL_MAX_VAL_LEN) // res = bpf_probe_read(lbl->val, val_len, map_value->values[i].str); @@ -353,6 +360,7 @@ bool get_go_custom_labels(struct pt_regs *ctx, UnwindState *state, void *offsets // all r0-r5 are clobbered since we make a function call. : "r0", "r1", "r2", "r3", "r4", "r5", "memory" ); +#endif // clang-format on if (res) { DEBUG_PRINT("failed to read value for custom label: %ld", res); diff --git a/support/ebpf/opaquify.h b/support/ebpf/opaquify.h index 83e7d0e0..c4dff6c1 100644 --- a/support/ebpf/opaquify.h +++ b/support/ebpf/opaquify.h @@ -1,6 +1,7 @@ #ifndef OPTI_OPAQUIFY_H #define OPTI_OPAQUIFY_H +#ifndef TESTING_COREDUMP #include "bpfdefs.h" // Hack to thwart the verifier's detection of variable bounds. // @@ -54,6 +55,12 @@ u64 opaquify64(u64 val, u64 seed) { ); return val; } +#else +static inline __attribute__((__always_inline__)) +u64 opaquify64(u64 val, u64 seed) { + return val; +} +#endif #endif diff --git a/tools/coredump/ebpfcode.go b/tools/coredump/ebpfcode.go index 54d272e6..d59e5d54 100644 --- a/tools/coredump/ebpfcode.go +++ b/tools/coredump/ebpfcode.go @@ -22,6 +22,7 @@ package main #include #include #include "../../support/ebpf/types.h" +#include "../../support/ebpf/opaquify.h" struct cgo_ctx { jmp_buf jmpbuf;