Skip to content

Commit 2acc5fd

Browse files
davem330Alexei Starovoitov
authored andcommitted
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>
1 parent c766570 commit 2acc5fd

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tools/testing/selftests/bpf/test_verifier.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,7 @@ static struct bpf_test tests[] = {
18231823
.errstr = "invalid bpf_context access",
18241824
.result = REJECT,
18251825
.prog_type = BPF_PROG_TYPE_SK_MSG,
1826+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
18261827
},
18271828
{
18281829
"direct packet read for SK_MSG",
@@ -2215,6 +2216,8 @@ static struct bpf_test tests[] = {
22152216
},
22162217
.errstr = "invalid bpf_context access",
22172218
.result = REJECT,
2219+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2220+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
22182221
},
22192222
{
22202223
"check cb access: half, wrong type",
@@ -3281,6 +3284,7 @@ static struct bpf_test tests[] = {
32813284
.result = REJECT,
32823285
.errstr = "R0 invalid mem access 'inv'",
32833286
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
3287+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
32843288
},
32853289
{
32863290
"raw_stack: skb_load_bytes, spilled regs corruption 2",
@@ -3311,6 +3315,7 @@ static struct bpf_test tests[] = {
33113315
.result = REJECT,
33123316
.errstr = "R3 invalid mem access 'inv'",
33133317
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
3318+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
33143319
},
33153320
{
33163321
"raw_stack: skb_load_bytes, spilled regs + data",
@@ -3810,6 +3815,7 @@ static struct bpf_test tests[] = {
38103815
.errstr = "R2 invalid mem access 'inv'",
38113816
.result = REJECT,
38123817
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
3818+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
38133819
},
38143820
{
38153821
"direct packet access: test16 (arith on data_end)",
@@ -3993,6 +3999,7 @@ static struct bpf_test tests[] = {
39933999
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
39944000
.result = REJECT,
39954001
.errstr = "invalid access to packet, off=0 size=8, R5(id=1,off=0,r=0)",
4002+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
39964003
},
39974004
{
39984005
"direct packet access: test24 (x += pkt_ptr, 5)",
@@ -5149,6 +5156,7 @@ static struct bpf_test tests[] = {
51495156
.result = REJECT,
51505157
.errstr = "invalid access to map value, value_size=64 off=-2 size=4",
51515158
.prog_type = BPF_PROG_TYPE_CGROUP_SKB,
5159+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
51525160
},
51535161
{
51545162
"invalid cgroup storage access 5",
@@ -5265,6 +5273,7 @@ static struct bpf_test tests[] = {
52655273
.result = REJECT,
52665274
.errstr = "invalid access to map value, value_size=64 off=-2 size=4",
52675275
.prog_type = BPF_PROG_TYPE_CGROUP_SKB,
5276+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
52685277
},
52695278
{
52705279
"invalid per-cpu cgroup storage access 5",
@@ -7206,6 +7215,7 @@ static struct bpf_test tests[] = {
72067215
.errstr = "invalid mem access 'inv'",
72077216
.result = REJECT,
72087217
.result_unpriv = REJECT,
7218+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
72097219
},
72107220
{
72117221
"map element value illegal alu op, 5",
@@ -7228,6 +7238,7 @@ static struct bpf_test tests[] = {
72287238
.fixup_map_hash_48b = { 3 },
72297239
.errstr = "R0 invalid mem access 'inv'",
72307240
.result = REJECT,
7241+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
72317242
},
72327243
{
72337244
"map element value is preserved across register spilling",
@@ -9720,6 +9731,7 @@ static struct bpf_test tests[] = {
97209731
.errstr = "R1 offset is outside of the packet",
97219732
.result = REJECT,
97229733
.prog_type = BPF_PROG_TYPE_XDP,
9734+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
97239735
},
97249736
{
97259737
"XDP pkt read, pkt_end > pkt_data', good access",
@@ -9758,6 +9770,7 @@ static struct bpf_test tests[] = {
97589770
.errstr = "R1 offset is outside of the packet",
97599771
.result = REJECT,
97609772
.prog_type = BPF_PROG_TYPE_XDP,
9773+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
97619774
},
97629775
{
97639776
"XDP pkt read, pkt_end > pkt_data', bad access 2",
@@ -9776,6 +9789,7 @@ static struct bpf_test tests[] = {
97769789
.errstr = "R1 offset is outside of the packet",
97779790
.result = REJECT,
97789791
.prog_type = BPF_PROG_TYPE_XDP,
9792+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
97799793
},
97809794
{
97819795
"XDP pkt read, pkt_data' < pkt_end, good access",
@@ -9814,6 +9828,7 @@ static struct bpf_test tests[] = {
98149828
.errstr = "R1 offset is outside of the packet",
98159829
.result = REJECT,
98169830
.prog_type = BPF_PROG_TYPE_XDP,
9831+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
98179832
},
98189833
{
98199834
"XDP pkt read, pkt_data' < pkt_end, bad access 2",
@@ -9832,6 +9847,7 @@ static struct bpf_test tests[] = {
98329847
.errstr = "R1 offset is outside of the packet",
98339848
.result = REJECT,
98349849
.prog_type = BPF_PROG_TYPE_XDP,
9850+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
98359851
},
98369852
{
98379853
"XDP pkt read, pkt_end < pkt_data', good access",
@@ -9886,6 +9902,7 @@ static struct bpf_test tests[] = {
98869902
.errstr = "R1 offset is outside of the packet",
98879903
.result = REJECT,
98889904
.prog_type = BPF_PROG_TYPE_XDP,
9905+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
98899906
},
98909907
{
98919908
"XDP pkt read, pkt_data' >= pkt_end, good access",
@@ -9922,6 +9939,7 @@ static struct bpf_test tests[] = {
99229939
.errstr = "R1 offset is outside of the packet",
99239940
.result = REJECT,
99249941
.prog_type = BPF_PROG_TYPE_XDP,
9942+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
99259943
},
99269944
{
99279945
"XDP pkt read, pkt_data' >= pkt_end, bad access 2",
@@ -9997,6 +10015,7 @@ static struct bpf_test tests[] = {
999710015
.errstr = "R1 offset is outside of the packet",
999810016
.result = REJECT,
999910017
.prog_type = BPF_PROG_TYPE_XDP,
10018+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1000010019
},
1000110020
{
1000210021
"XDP pkt read, pkt_data' <= pkt_end, good access",
@@ -10053,6 +10072,7 @@ static struct bpf_test tests[] = {
1005310072
.errstr = "R1 offset is outside of the packet",
1005410073
.result = REJECT,
1005510074
.prog_type = BPF_PROG_TYPE_XDP,
10075+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1005610076
},
1005710077
{
1005810078
"XDP pkt read, pkt_end <= pkt_data', good access",
@@ -10089,6 +10109,7 @@ static struct bpf_test tests[] = {
1008910109
.errstr = "R1 offset is outside of the packet",
1009010110
.result = REJECT,
1009110111
.prog_type = BPF_PROG_TYPE_XDP,
10112+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1009210113
},
1009310114
{
1009410115
"XDP pkt read, pkt_end <= pkt_data', bad access 2",
@@ -10162,6 +10183,7 @@ static struct bpf_test tests[] = {
1016210183
.errstr = "R1 offset is outside of the packet",
1016310184
.result = REJECT,
1016410185
.prog_type = BPF_PROG_TYPE_XDP,
10186+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1016510187
},
1016610188
{
1016710189
"XDP pkt read, pkt_data > pkt_meta', good access",
@@ -10200,6 +10222,7 @@ static struct bpf_test tests[] = {
1020010222
.errstr = "R1 offset is outside of the packet",
1020110223
.result = REJECT,
1020210224
.prog_type = BPF_PROG_TYPE_XDP,
10225+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1020310226
},
1020410227
{
1020510228
"XDP pkt read, pkt_data > pkt_meta', bad access 2",
@@ -10218,6 +10241,7 @@ static struct bpf_test tests[] = {
1021810241
.errstr = "R1 offset is outside of the packet",
1021910242
.result = REJECT,
1022010243
.prog_type = BPF_PROG_TYPE_XDP,
10244+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1022110245
},
1022210246
{
1022310247
"XDP pkt read, pkt_meta' < pkt_data, good access",
@@ -10256,6 +10280,7 @@ static struct bpf_test tests[] = {
1025610280
.errstr = "R1 offset is outside of the packet",
1025710281
.result = REJECT,
1025810282
.prog_type = BPF_PROG_TYPE_XDP,
10283+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1025910284
},
1026010285
{
1026110286
"XDP pkt read, pkt_meta' < pkt_data, bad access 2",
@@ -10274,6 +10299,7 @@ static struct bpf_test tests[] = {
1027410299
.errstr = "R1 offset is outside of the packet",
1027510300
.result = REJECT,
1027610301
.prog_type = BPF_PROG_TYPE_XDP,
10302+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1027710303
},
1027810304
{
1027910305
"XDP pkt read, pkt_data < pkt_meta', good access",
@@ -10328,6 +10354,7 @@ static struct bpf_test tests[] = {
1032810354
.errstr = "R1 offset is outside of the packet",
1032910355
.result = REJECT,
1033010356
.prog_type = BPF_PROG_TYPE_XDP,
10357+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1033110358
},
1033210359
{
1033310360
"XDP pkt read, pkt_meta' >= pkt_data, good access",
@@ -10364,6 +10391,7 @@ static struct bpf_test tests[] = {
1036410391
.errstr = "R1 offset is outside of the packet",
1036510392
.result = REJECT,
1036610393
.prog_type = BPF_PROG_TYPE_XDP,
10394+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1036710395
},
1036810396
{
1036910397
"XDP pkt read, pkt_meta' >= pkt_data, bad access 2",
@@ -10439,6 +10467,7 @@ static struct bpf_test tests[] = {
1043910467
.errstr = "R1 offset is outside of the packet",
1044010468
.result = REJECT,
1044110469
.prog_type = BPF_PROG_TYPE_XDP,
10470+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1044210471
},
1044310472
{
1044410473
"XDP pkt read, pkt_meta' <= pkt_data, good access",
@@ -10495,6 +10524,7 @@ static struct bpf_test tests[] = {
1049510524
.errstr = "R1 offset is outside of the packet",
1049610525
.result = REJECT,
1049710526
.prog_type = BPF_PROG_TYPE_XDP,
10527+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1049810528
},
1049910529
{
1050010530
"XDP pkt read, pkt_data <= pkt_meta', good access",
@@ -10531,6 +10561,7 @@ static struct bpf_test tests[] = {
1053110561
.errstr = "R1 offset is outside of the packet",
1053210562
.result = REJECT,
1053310563
.prog_type = BPF_PROG_TYPE_XDP,
10564+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1053410565
},
1053510566
{
1053610567
"XDP pkt read, pkt_data <= pkt_meta', bad access 2",
@@ -10635,6 +10666,7 @@ static struct bpf_test tests[] = {
1063510666
},
1063610667
.result = REJECT,
1063710668
.errstr = "dereference of modified ctx ptr",
10669+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1063810670
},
1063910671
{
1064010672
"check deducing bounds from const, 8",
@@ -10648,6 +10680,7 @@ static struct bpf_test tests[] = {
1064810680
},
1064910681
.result = REJECT,
1065010682
.errstr = "dereference of modified ctx ptr",
10683+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1065110684
},
1065210685
{
1065310686
"check deducing bounds from const, 9",
@@ -11122,6 +11155,7 @@ static struct bpf_test tests[] = {
1112211155
.result = REJECT,
1112311156
.errstr = "R6 invalid mem access 'inv'",
1112411157
.prog_type = BPF_PROG_TYPE_XDP,
11158+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1112511159
},
1112611160
{
1112711161
"calls: two calls with args",
@@ -11987,6 +12021,7 @@ static struct bpf_test tests[] = {
1198712021
.fixup_map_hash_8b = { 12, 22 },
1198812022
.result = REJECT,
1198912023
.errstr = "invalid access to map value, value_size=8 off=2 size=8",
12024+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1199012025
},
1199112026
{
1199212027
"calls: two calls that receive map_value via arg=ptr_stack_of_caller. test2",
@@ -12130,6 +12165,7 @@ static struct bpf_test tests[] = {
1213012165
.fixup_map_hash_8b = { 12, 22 },
1213112166
.result = REJECT,
1213212167
.errstr = "invalid access to map value, value_size=8 off=2 size=8",
12168+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1213312169
},
1213412170
{
1213512171
"calls: two calls that receive map_value_ptr_or_null via arg. test1",
@@ -12301,6 +12337,7 @@ static struct bpf_test tests[] = {
1230112337
.result = ACCEPT,
1230212338
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
1230312339
.retval = POINTER_VALUE,
12340+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1230412341
},
1230512342
{
1230612343
"calls: pkt_ptr spill into caller stack 2",
@@ -12332,6 +12369,7 @@ static struct bpf_test tests[] = {
1233212369
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
1233312370
.errstr = "invalid access to packet",
1233412371
.result = REJECT,
12372+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1233512373
},
1233612374
{
1233712375
"calls: pkt_ptr spill into caller stack 3",
@@ -12434,6 +12472,7 @@ static struct bpf_test tests[] = {
1243412472
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
1243512473
.errstr = "same insn cannot be used with different",
1243612474
.result = REJECT,
12475+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1243712476
},
1243812477
{
1243912478
"calls: pkt_ptr spill into caller stack 6",
@@ -12469,6 +12508,7 @@ static struct bpf_test tests[] = {
1246912508
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
1247012509
.errstr = "R4 invalid mem access",
1247112510
.result = REJECT,
12511+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1247212512
},
1247312513
{
1247412514
"calls: pkt_ptr spill into caller stack 7",
@@ -12503,6 +12543,7 @@ static struct bpf_test tests[] = {
1250312543
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
1250412544
.errstr = "R4 invalid mem access",
1250512545
.result = REJECT,
12546+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1250612547
},
1250712548
{
1250812549
"calls: pkt_ptr spill into caller stack 8",
@@ -12584,6 +12625,7 @@ static struct bpf_test tests[] = {
1258412625
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
1258512626
.errstr = "invalid access to packet",
1258612627
.result = REJECT,
12628+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1258712629
},
1258812630
{
1258912631
"calls: caller stack init to zero or map_value_or_null",
@@ -12949,6 +12991,7 @@ static struct bpf_test tests[] = {
1294912991
.result = REJECT,
1295012992
.errstr = "BPF_XADD stores into R2 pkt is not allowed",
1295112993
.prog_type = BPF_PROG_TYPE_XDP,
12994+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1295212995
},
1295312996
{
1295412997
"xadd/w check whether src/dst got mangled, 1",
@@ -13435,6 +13478,7 @@ static struct bpf_test tests[] = {
1343513478
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
1343613479
.errstr = "Unreleased reference",
1343713480
.result = REJECT,
13481+
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
1343813482
},
1343913483
{
1344013484
"reference tracking: alloc, check, free in both subbranches",

0 commit comments

Comments
 (0)