diff options
author | John Fastabend <john.fastabend@gmail.com> | 2018-12-16 18:47:06 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-12-18 18:27:23 -0500 |
commit | 945a47d87cee24a95e11fdc0cd868b872f9b9616 (patch) | |
tree | 70590ac2bacf2a40aec88e06aca9e924e48695ef /tools | |
parent | 584e46813e689ff1a348343b73122c43d81d0ef7 (diff) |
bpf: sk_msg, add tests for size field
This adds tests to read the size field to test_verifier.
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/test_verifier.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index cf242734e2eb..7865b94c02c4 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c | |||
@@ -1843,10 +1843,20 @@ static struct bpf_test tests[] = { | |||
1843 | .prog_type = BPF_PROG_TYPE_SK_SKB, | 1843 | .prog_type = BPF_PROG_TYPE_SK_SKB, |
1844 | }, | 1844 | }, |
1845 | { | 1845 | { |
1846 | "invalid 64B read of family in SK_MSG", | 1846 | "valid access size in SK_MSG", |
1847 | .insns = { | ||
1848 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, | ||
1849 | offsetof(struct sk_msg_md, size)), | ||
1850 | BPF_EXIT_INSN(), | ||
1851 | }, | ||
1852 | .result = ACCEPT, | ||
1853 | .prog_type = BPF_PROG_TYPE_SK_MSG, | ||
1854 | }, | ||
1855 | { | ||
1856 | "invalid 64B read of size in SK_MSG", | ||
1847 | .insns = { | 1857 | .insns = { |
1848 | BPF_LDX_MEM(BPF_DW, BPF_REG_2, BPF_REG_1, | 1858 | BPF_LDX_MEM(BPF_DW, BPF_REG_2, BPF_REG_1, |
1849 | offsetof(struct sk_msg_md, family)), | 1859 | offsetof(struct sk_msg_md, size)), |
1850 | BPF_EXIT_INSN(), | 1860 | BPF_EXIT_INSN(), |
1851 | }, | 1861 | }, |
1852 | .errstr = "invalid bpf_context access", | 1862 | .errstr = "invalid bpf_context access", |
@@ -1857,7 +1867,7 @@ static struct bpf_test tests[] = { | |||
1857 | "invalid read past end of SK_MSG", | 1867 | "invalid read past end of SK_MSG", |
1858 | .insns = { | 1868 | .insns = { |
1859 | BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, | 1869 | BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, |
1860 | offsetof(struct sk_msg_md, local_port) + 4), | 1870 | offsetof(struct sk_msg_md, size) + 4), |
1861 | BPF_EXIT_INSN(), | 1871 | BPF_EXIT_INSN(), |
1862 | }, | 1872 | }, |
1863 | .errstr = "R0 !read_ok", | 1873 | .errstr = "R0 !read_ok", |