Skip to content

Commit 945a47d

Browse files
jrfastabborkmann
authored andcommitted
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>
1 parent 584e468 commit 945a47d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tools/testing/selftests/bpf/test_verifier.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,10 +1843,20 @@ static struct bpf_test tests[] = {
18431843
.prog_type = BPF_PROG_TYPE_SK_SKB,
18441844
},
18451845
{
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",
18471857
.insns = {
18481858
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)),
18501860
BPF_EXIT_INSN(),
18511861
},
18521862
.errstr = "invalid bpf_context access",
@@ -1857,7 +1867,7 @@ static struct bpf_test tests[] = {
18571867
"invalid read past end of SK_MSG",
18581868
.insns = {
18591869
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),
18611871
BPF_EXIT_INSN(),
18621872
},
18631873
.errstr = "R0 !read_ok",

0 commit comments

Comments
 (0)