mirror of https://gitee.com/openkylin/linux.git
bpf: Make more use of 'any' alignment in test_verifier.c
Use F_NEEDS_EFFICIENT_UNALIGNED_ACCESS in more tests where the expected result is REJECT. Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
c7665702d3
commit
2acc5fd5b8
|
@ -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)",
|
||||
|
@ -3993,6 +3999,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)",
|
||||
|
@ -5149,6 +5156,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 +5273,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 +7215,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 +7238,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",
|
||||
|
@ -9720,6 +9731,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 +9770,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 +9789,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 +9828,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 +9847,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",
|
||||
|
@ -9886,6 +9902,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 +9939,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",
|
||||
|
@ -9997,6 +10015,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",
|
||||
|
@ -10053,6 +10072,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 +10109,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",
|
||||
|
@ -10162,6 +10183,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 +10222,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 +10241,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 +10280,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 +10299,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",
|
||||
|
@ -10328,6 +10354,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 +10391,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",
|
||||
|
@ -10439,6 +10467,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",
|
||||
|
@ -10495,6 +10524,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 +10561,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 +10666,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 +10680,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 +11155,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 +12021,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 +12165,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 +12337,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 +12369,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",
|
||||
|
@ -12434,6 +12472,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 +12508,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 +12543,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",
|
||||
|
@ -12584,6 +12625,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 +12991,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 +13478,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",
|
||||
|
|
Loading…
Reference in New Issue