|
|
|
@ -1823,6 +1823,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "invalid bpf_context access",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SK_MSG,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"direct packet read for SK_MSG",
|
|
|
|
@ -2215,6 +2216,8 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.errstr = "invalid bpf_context access",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"check cb access: half, wrong type",
|
|
|
|
@ -3281,6 +3284,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "R0 invalid mem access 'inv'",
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"raw_stack: skb_load_bytes, spilled regs corruption 2",
|
|
|
|
@ -3311,6 +3315,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "R3 invalid mem access 'inv'",
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"raw_stack: skb_load_bytes, spilled regs + data",
|
|
|
|
@ -3810,6 +3815,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R2 invalid mem access 'inv'",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"direct packet access: test16 (arith on data_end)",
|
|
|
|
@ -3912,6 +3918,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"direct packet access: test21 (x += pkt_ptr, 2)",
|
|
|
|
@ -3937,6 +3944,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"direct packet access: test22 (x += pkt_ptr, 3)",
|
|
|
|
@ -3967,6 +3975,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"direct packet access: test23 (x += pkt_ptr, 4)",
|
|
|
|
@ -3993,6 +4002,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "invalid access to packet, off=0 size=8, R5(id=1,off=0,r=0)",
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"direct packet access: test24 (x += pkt_ptr, 5)",
|
|
|
|
@ -4018,6 +4028,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"direct packet access: test25 (marking on <, good access)",
|
|
|
|
@ -5149,6 +5160,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "invalid access to map value, value_size=64 off=-2 size=4",
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_CGROUP_SKB,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"invalid cgroup storage access 5",
|
|
|
|
@ -5265,6 +5277,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "invalid access to map value, value_size=64 off=-2 size=4",
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_CGROUP_SKB,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"invalid per-cpu cgroup storage access 5",
|
|
|
|
@ -7206,6 +7219,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "invalid mem access 'inv'",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.result_unpriv = REJECT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"map element value illegal alu op, 5",
|
|
|
|
@ -7228,6 +7242,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.fixup_map_hash_48b = { 3 },
|
|
|
|
|
.errstr = "R0 invalid mem access 'inv'",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"map element value is preserved across register spilling",
|
|
|
|
@ -7721,6 +7736,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.retval = 0 /* csum_diff of 64-byte packet */,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"helper access to variable memory: size = 0 not allowed on NULL (!ARG_PTR_TO_MEM_OR_NULL)",
|
|
|
|
@ -9683,6 +9699,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data' > pkt_end, bad access 1",
|
|
|
|
@ -9720,6 +9737,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_end > pkt_data', good access",
|
|
|
|
@ -9758,6 +9776,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_end > pkt_data', bad access 2",
|
|
|
|
@ -9776,6 +9795,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data' < pkt_end, good access",
|
|
|
|
@ -9814,6 +9834,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data' < pkt_end, bad access 2",
|
|
|
|
@ -9832,6 +9853,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_end < pkt_data', good access",
|
|
|
|
@ -9849,6 +9871,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_end < pkt_data', bad access 1",
|
|
|
|
@ -9886,6 +9909,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data' >= pkt_end, good access",
|
|
|
|
@ -9922,6 +9946,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data' >= pkt_end, bad access 2",
|
|
|
|
@ -9959,6 +9984,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_end >= pkt_data', bad access 1",
|
|
|
|
@ -9997,6 +10023,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data' <= pkt_end, good access",
|
|
|
|
@ -10015,6 +10042,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data' <= pkt_end, bad access 1",
|
|
|
|
@ -10053,6 +10081,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_end <= pkt_data', good access",
|
|
|
|
@ -10089,6 +10118,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_end <= pkt_data', bad access 2",
|
|
|
|
@ -10125,6 +10155,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_meta' > pkt_data, bad access 1",
|
|
|
|
@ -10162,6 +10193,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data > pkt_meta', good access",
|
|
|
|
@ -10200,6 +10232,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data > pkt_meta', bad access 2",
|
|
|
|
@ -10218,6 +10251,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_meta' < pkt_data, good access",
|
|
|
|
@ -10256,6 +10290,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_meta' < pkt_data, bad access 2",
|
|
|
|
@ -10274,6 +10309,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data < pkt_meta', good access",
|
|
|
|
@ -10291,6 +10327,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data < pkt_meta', bad access 1",
|
|
|
|
@ -10328,6 +10365,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_meta' >= pkt_data, good access",
|
|
|
|
@ -10364,6 +10402,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_meta' >= pkt_data, bad access 2",
|
|
|
|
@ -10401,6 +10440,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data >= pkt_meta', bad access 1",
|
|
|
|
@ -10439,6 +10479,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_meta' <= pkt_data, good access",
|
|
|
|
@ -10457,6 +10498,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_meta' <= pkt_data, bad access 1",
|
|
|
|
@ -10495,6 +10537,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data <= pkt_meta', good access",
|
|
|
|
@ -10531,6 +10574,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.errstr = "R1 offset is outside of the packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"XDP pkt read, pkt_data <= pkt_meta', bad access 2",
|
|
|
|
@ -10635,6 +10679,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "dereference of modified ctx ptr",
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"check deducing bounds from const, 8",
|
|
|
|
@ -10648,6 +10693,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "dereference of modified ctx ptr",
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"check deducing bounds from const, 9",
|
|
|
|
@ -11122,6 +11168,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "R6 invalid mem access 'inv'",
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: two calls with args",
|
|
|
|
@ -11987,6 +12034,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.fixup_map_hash_8b = { 12, 22 },
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "invalid access to map value, value_size=8 off=2 size=8",
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: two calls that receive map_value via arg=ptr_stack_of_caller. test2",
|
|
|
|
@ -12130,6 +12178,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.fixup_map_hash_8b = { 12, 22 },
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "invalid access to map value, value_size=8 off=2 size=8",
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: two calls that receive map_value_ptr_or_null via arg. test1",
|
|
|
|
@ -12301,6 +12350,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.retval = POINTER_VALUE,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: pkt_ptr spill into caller stack 2",
|
|
|
|
@ -12332,6 +12382,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.errstr = "invalid access to packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: pkt_ptr spill into caller stack 3",
|
|
|
|
@ -12367,6 +12418,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.retval = 1,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: pkt_ptr spill into caller stack 4",
|
|
|
|
@ -12401,6 +12453,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.retval = 1,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: pkt_ptr spill into caller stack 5",
|
|
|
|
@ -12434,6 +12487,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.errstr = "same insn cannot be used with different",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: pkt_ptr spill into caller stack 6",
|
|
|
|
@ -12469,6 +12523,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.errstr = "R4 invalid mem access",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: pkt_ptr spill into caller stack 7",
|
|
|
|
@ -12503,6 +12558,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.errstr = "R4 invalid mem access",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: pkt_ptr spill into caller stack 8",
|
|
|
|
@ -12543,6 +12599,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: pkt_ptr spill into caller stack 9",
|
|
|
|
@ -12584,6 +12641,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.errstr = "invalid access to packet",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"calls: caller stack init to zero or map_value_or_null",
|
|
|
|
@ -12949,6 +13007,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.errstr = "BPF_XADD stores into R2 pkt is not allowed",
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_XDP,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"xadd/w check whether src/dst got mangled, 1",
|
|
|
|
@ -13435,6 +13494,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.errstr = "Unreleased reference",
|
|
|
|
|
.result = REJECT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"reference tracking: alloc, check, free in both subbranches",
|
|
|
|
@ -13463,6 +13523,7 @@ static struct bpf_test tests[] = {
|
|
|
|
|
},
|
|
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
|
|
.result = ACCEPT,
|
|
|
|
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"reference tracking in call: free reference in subprog",
|
|
|
|
@ -14257,13 +14318,14 @@ out:
|
|
|
|
|
static void do_test_single(struct bpf_test *test, bool unpriv,
|
|
|
|
|
int *passes, int *errors)
|
|
|
|
|
{
|
|
|
|
|
int fd_prog, expected_ret, reject_from_alignment;
|
|
|
|
|
int fd_prog, expected_ret, alignment_prevented_execution;
|
|
|
|
|
int prog_len, prog_type = test->prog_type;
|
|
|
|
|
struct bpf_insn *prog = test->insns;
|
|
|
|
|
int map_fds[MAX_NR_MAPS];
|
|
|
|
|
const char *expected_err;
|
|
|
|
|
uint32_t expected_val;
|
|
|
|
|
uint32_t retval;
|
|
|
|
|
__u32 pflags;
|
|
|
|
|
int i, err;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_NR_MAPS; i++)
|
|
|
|
@ -14274,8 +14336,12 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
|
|
|
|
|
do_test_fixup(test, prog_type, prog, map_fds);
|
|
|
|
|
prog_len = probe_filter_length(prog);
|
|
|
|
|
|
|
|
|
|
fd_prog = bpf_verify_program(prog_type, prog, prog_len,
|
|
|
|
|
test->flags & F_LOAD_WITH_STRICT_ALIGNMENT,
|
|
|
|
|
pflags = 0;
|
|
|
|
|
if (test->flags & F_LOAD_WITH_STRICT_ALIGNMENT)
|
|
|
|
|
pflags |= BPF_F_STRICT_ALIGNMENT;
|
|
|
|
|
if (test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS)
|
|
|
|
|
pflags |= BPF_F_ANY_ALIGNMENT;
|
|
|
|
|
fd_prog = bpf_verify_program(prog_type, prog, prog_len, pflags,
|
|
|
|
|
"GPL", 0, bpf_vlog, sizeof(bpf_vlog), 1);
|
|
|
|
|
|
|
|
|
|
expected_ret = unpriv && test->result_unpriv != UNDEF ?
|
|
|
|
@ -14285,28 +14351,27 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
|
|
|
|
|
expected_val = unpriv && test->retval_unpriv ?
|
|
|
|
|
test->retval_unpriv : test->retval;
|
|
|
|
|
|
|
|
|
|
reject_from_alignment = fd_prog < 0 &&
|
|
|
|
|
(test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS) &&
|
|
|
|
|
strstr(bpf_vlog, "misaligned");
|
|
|
|
|
#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
|
|
|
|
|
if (reject_from_alignment) {
|
|
|
|
|
printf("FAIL\nFailed due to alignment despite having efficient unaligned access: '%s'!\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
goto fail_log;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
alignment_prevented_execution = 0;
|
|
|
|
|
|
|
|
|
|
if (expected_ret == ACCEPT) {
|
|
|
|
|
if (fd_prog < 0 && !reject_from_alignment) {
|
|
|
|
|
if (fd_prog < 0) {
|
|
|
|
|
printf("FAIL\nFailed to load prog '%s'!\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
goto fail_log;
|
|
|
|
|
}
|
|
|
|
|
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
|
|
|
|
|
if (fd_prog >= 0 &&
|
|
|
|
|
(test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS)) {
|
|
|
|
|
alignment_prevented_execution = 1;
|
|
|
|
|
goto test_ok;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
if (fd_prog >= 0) {
|
|
|
|
|
printf("FAIL\nUnexpected success to load!\n");
|
|
|
|
|
goto fail_log;
|
|
|
|
|
}
|
|
|
|
|
if (!strstr(bpf_vlog, expected_err) && !reject_from_alignment) {
|
|
|
|
|
if (!strstr(bpf_vlog, expected_err)) {
|
|
|
|
|
printf("FAIL\nUnexpected error message!\n\tEXP: %s\n\tRES: %s\n",
|
|
|
|
|
expected_err, bpf_vlog);
|
|
|
|
|
goto fail_log;
|
|
|
|
@ -14334,9 +14399,12 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
|
|
|
|
|
goto fail_log;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
|
|
|
|
|
test_ok:
|
|
|
|
|
#endif
|
|
|
|
|
(*passes)++;
|
|
|
|
|
printf("OK%s\n", reject_from_alignment ?
|
|
|
|
|
" (NOTE: reject due to unknown alignment)" : "");
|
|
|
|
|
printf("OK%s\n", alignment_prevented_execution ?
|
|
|
|
|
" (NOTE: not executed due to unknown alignment)" : "");
|
|
|
|
|
close_fds:
|
|
|
|
|
close(fd_prog);
|
|
|
|
|
for (i = 0; i < MAX_NR_MAPS; i++)
|
|
|
|
|