[Draft] Collect bpf helper arguments related to bpf map #453
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The idea is to identify bpf map-related helpers in userspace, then use kprobe cookie to notify bpf program whether this requires arguments collecting.
There are at least following steps:
bpf_map *
is always at PT_REGS_PARM1(ctx).void *key
is always at PT_REGS_PRAM2(ctx).a. if value is in the return (bpf_map_lookup): bpf_probe_read_kernel(ctx->rax) at kretprobe to collect it
b. if value is in the param (bpf_map_update): bpf_probe_read_kernel(PT_REGS_PARM3(ctx)) to collect it
print_bpf_map_id
to event.Some unexpected work may happen, such as bpf stack being used up. If that tragedy takes place, I'll use a per-cpu map to save bpf stack.
This doesn't require BTF at all, but if necessary we can extend it to support BTF parsing.
Fixes: #448