Detect external pointers from context pointers
The bcc rewriter is currently unable to detect external pointers
(i.e., to a memory address that requires calls to bpf_probe_read) if
they are not declared as arguments, e.g., if they are retrieved
through the context argument.
For example, although the two following examples translate to the
same C code in the end (the bcc rewriter translates the first into
the second), the sk pointer is recognized as an external pointer only
in the first example.
int test1(struct pt_regs *ctx, struct sock *sk) {
// sk is correctly recognized as an external pointer.
}
int test2(struct pt_regs *ctx) {
struct sock *sk = (struct sock *)ctx->di;
// sk is not recognized as an external pointer.
}
This commit fixes that by detecting member dereferences of the
context argument (i.e., the first argument of externally visible
functions). It also works for the TRACEPOINT_PROBE macro.
Loading
Please sign in to comment