Translate multiple pointer dereference into bpr_probe_read
authorBrenden Blanco <bblanco@plumgrid.com>
Tue, 15 Sep 2015 22:46:26 +0000 (15:46 -0700)
committerBrenden Blanco <bblanco@plumgrid.com>
Tue, 15 Sep 2015 22:52:14 +0000 (15:52 -0700)
commit70fa0a1c0423c73b06948c7eb963cfc82a2f3ba7
tree49bab9521c89b89a02112c6ba90ded55f365a996
parent4afb3f87af57b3a1a160172efb63b82417143820
Translate multiple pointer dereference into bpr_probe_read

This commit adds support for multiple consecutive and nested pointer
dereference of function arguments that should be converted to
bpf_probe_read. The logic works by marking variables as needing a
probe_read if they come from the register argument, and then applying
this property transitively.

Supported syntax:
```
int trace_entry(struct pt_regs *ctx, struct file *file) {
    struct vfsmount *mnt = file->f_path.mnt;
    struct super_block *k = mnt->mnt_sb;
    const char *name = file->f_path.dentry->d_name.name;
```

Not supported: probe reads from map leaves, probe reads after explicit casts.

Fixes: #188
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/b_frontend_action.h
tests/cc/test_clang.py