Skip to content

Commit

Permalink
Tests for dereferences of struct with external pointers as members
Browse files Browse the repository at this point in the history
  • Loading branch information
pchaigno committed May 6, 2018
1 parent c2b87ba commit b341d8f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/python/test_clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,32 @@ def test_probe_simple_assign(self):
return 0;
}""")

def test_probe_simple_member_assign(self):
b = BPF(text="""
#include <uapi/linux/ptrace.h>
#include <linux/netdevice.h>
struct leaf { void *ptr; };
int test(struct pt_regs *ctx, struct sk_buff *skb) {
struct leaf l = {};
struct leaf *lp = &l;
lp->ptr = skb;
return 0;
}""")
b.load_func("test", BPF.KPROBE)

def test_probe_member_expr(self):
b = BPF(text="""
#include <uapi/linux/ptrace.h>
#include <linux/netdevice.h>
struct leaf { struct sk_buff *ptr; };
int test(struct pt_regs *ctx, struct sk_buff *skb) {
struct leaf l = {};
struct leaf *lp = &l;
lp->ptr = skb;
return lp->ptr->priority;
}""")
b.load_func("test", BPF.KPROBE)

def test_unop_probe_read(self):
text = """
#include <linux/blkdev.h>
Expand Down

0 comments on commit b341d8f

Please sign in to comment.