Commit 575b3e5a authored by Brenden Blanco's avatar Brenden Blanco Committed by GitHub

Merge pull request #1005 from pchaigno/rewrite-only-deref

Restrict rewrite of unary operators to dereference operator
parents d05e66de 4c6ecb46
......@@ -200,7 +200,7 @@ bool ProbeVisitor::VisitBinaryOperator(BinaryOperator *E) {
return true;
}
bool ProbeVisitor::VisitUnaryOperator(UnaryOperator *E) {
if (E->getOpcode() == UO_AddrOf)
if (E->getOpcode() != UO_Deref)
return true;
if (memb_visited_.find(E) != memb_visited_.end())
return true;
......
......@@ -408,6 +408,17 @@ int dns_test(struct __sk_buff *skb) {
"""
b = BPF(text=text)
def test_unary_operator(self):
text = """
#include <linux/fs.h>
#include <uapi/linux/ptrace.h>
int trace_read_entry(struct pt_regs *ctx, struct file *file) {
return !file->f_op->read_iter;
}
"""
b = BPF(text=text)
b.attach_kprobe(event="__vfs_read", fn_name="trace_read_entry")
if __name__ == "__main__":
main()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment