forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trace all external pointers passed through a first map (iovisor#1737)
* Trace all external pointers going through a first map Currently, MapVisitor only detects maps with external pointers as values if the value was directly passed from a function's argument. For example, in the following, the rewriter is currently unable to detect currsock has an external pointer as value because an intermediate variable is used instead of passing directly sk as the map's value. int test(struct pt_regs *ctx, struct sock *sk) { u32 pid = bpf_get_current_pid_tgid(); struct sock **skp = &sk; currsock.update(&pid, skp); return 0; }; With this commit, MapVisitor is able to trace any external pointer derived from the function's argument and used as a map value. This commit breaks the ProbeVisitor traversal in two distinct traversals. The first rewrites dereferences of external pointers originating from function's arguments and helpers, while the second rewrites only dereferences of external pointers passed through maps. Maps with external pointers as values are identified between the two ProbeVisitor traversals. * New tests for external pointers passed through maps test_ext_ptr_maps_reverse ensures dereferences are correctly replaced even if the update happens after the lookup (in the order of MapVisitor traversal). test_ext_ptr_maps_indirect ensures the rewriter is able to trace external pointers used as map values even if using an intermediate variable.
- Loading branch information
1 parent
42da08a
commit ad2d0d9
Showing
3 changed files
with
128 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters