@@ -84,6 +84,7 @@ struct bpf_test {
84
84
} test [MAX_SUBTESTS ];
85
85
int (* fill_helper )(struct bpf_test * self );
86
86
__u8 frag_data [MAX_DATA ];
87
+ int stack_depth ; /* for eBPF only, since tests don't call verifier */
87
88
};
88
89
89
90
/* Large test cases need separate allocation and fill handler. */
@@ -455,6 +456,7 @@ static int __bpf_fill_stxdw(struct bpf_test *self, int size)
455
456
456
457
self -> u .ptr .insns = insn ;
457
458
self -> u .ptr .len = len ;
459
+ self -> stack_depth = 40 ;
458
460
459
461
return 0 ;
460
462
}
@@ -2317,7 +2319,8 @@ static struct bpf_test tests[] = {
2317
2319
{ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0x08 , 0x06 , 0 , 0 ,
2318
2320
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
2319
2321
0x10 , 0xbf , 0x48 , 0xd6 , 0x43 , 0xd6 },
2320
- { { 38 , 256 } }
2322
+ { { 38 , 256 } },
2323
+ .stack_depth = 64 ,
2321
2324
},
2322
2325
/* BPF_ALU | BPF_MOV | BPF_X */
2323
2326
{
@@ -4169,6 +4172,7 @@ static struct bpf_test tests[] = {
4169
4172
INTERNAL ,
4170
4173
{ },
4171
4174
{ { 0 , 0xff } },
4175
+ .stack_depth = 40 ,
4172
4176
},
4173
4177
{
4174
4178
"ST_MEM_B: Store/Load byte: max positive" ,
@@ -4181,6 +4185,7 @@ static struct bpf_test tests[] = {
4181
4185
INTERNAL ,
4182
4186
{ },
4183
4187
{ { 0 , 0x7f } },
4188
+ .stack_depth = 40 ,
4184
4189
},
4185
4190
{
4186
4191
"STX_MEM_B: Store/Load byte: max negative" ,
@@ -4194,6 +4199,7 @@ static struct bpf_test tests[] = {
4194
4199
INTERNAL ,
4195
4200
{ },
4196
4201
{ { 0 , 0xff } },
4202
+ .stack_depth = 40 ,
4197
4203
},
4198
4204
{
4199
4205
"ST_MEM_H: Store/Load half word: max negative" ,
@@ -4206,6 +4212,7 @@ static struct bpf_test tests[] = {
4206
4212
INTERNAL ,
4207
4213
{ },
4208
4214
{ { 0 , 0xffff } },
4215
+ .stack_depth = 40 ,
4209
4216
},
4210
4217
{
4211
4218
"ST_MEM_H: Store/Load half word: max positive" ,
@@ -4218,6 +4225,7 @@ static struct bpf_test tests[] = {
4218
4225
INTERNAL ,
4219
4226
{ },
4220
4227
{ { 0 , 0x7fff } },
4228
+ .stack_depth = 40 ,
4221
4229
},
4222
4230
{
4223
4231
"STX_MEM_H: Store/Load half word: max negative" ,
@@ -4231,6 +4239,7 @@ static struct bpf_test tests[] = {
4231
4239
INTERNAL ,
4232
4240
{ },
4233
4241
{ { 0 , 0xffff } },
4242
+ .stack_depth = 40 ,
4234
4243
},
4235
4244
{
4236
4245
"ST_MEM_W: Store/Load word: max negative" ,
@@ -4243,6 +4252,7 @@ static struct bpf_test tests[] = {
4243
4252
INTERNAL ,
4244
4253
{ },
4245
4254
{ { 0 , 0xffffffff } },
4255
+ .stack_depth = 40 ,
4246
4256
},
4247
4257
{
4248
4258
"ST_MEM_W: Store/Load word: max positive" ,
@@ -4255,6 +4265,7 @@ static struct bpf_test tests[] = {
4255
4265
INTERNAL ,
4256
4266
{ },
4257
4267
{ { 0 , 0x7fffffff } },
4268
+ .stack_depth = 40 ,
4258
4269
},
4259
4270
{
4260
4271
"STX_MEM_W: Store/Load word: max negative" ,
@@ -4268,6 +4279,7 @@ static struct bpf_test tests[] = {
4268
4279
INTERNAL ,
4269
4280
{ },
4270
4281
{ { 0 , 0xffffffff } },
4282
+ .stack_depth = 40 ,
4271
4283
},
4272
4284
{
4273
4285
"ST_MEM_DW: Store/Load double word: max negative" ,
@@ -4280,6 +4292,7 @@ static struct bpf_test tests[] = {
4280
4292
INTERNAL ,
4281
4293
{ },
4282
4294
{ { 0 , 0xffffffff } },
4295
+ .stack_depth = 40 ,
4283
4296
},
4284
4297
{
4285
4298
"ST_MEM_DW: Store/Load double word: max negative 2" ,
@@ -4297,6 +4310,7 @@ static struct bpf_test tests[] = {
4297
4310
INTERNAL ,
4298
4311
{ },
4299
4312
{ { 0 , 0x1 } },
4313
+ .stack_depth = 40 ,
4300
4314
},
4301
4315
{
4302
4316
"ST_MEM_DW: Store/Load double word: max positive" ,
@@ -4309,6 +4323,7 @@ static struct bpf_test tests[] = {
4309
4323
INTERNAL ,
4310
4324
{ },
4311
4325
{ { 0 , 0x7fffffff } },
4326
+ .stack_depth = 40 ,
4312
4327
},
4313
4328
{
4314
4329
"STX_MEM_DW: Store/Load double word: max negative" ,
@@ -4322,6 +4337,7 @@ static struct bpf_test tests[] = {
4322
4337
INTERNAL ,
4323
4338
{ },
4324
4339
{ { 0 , 0xffffffff } },
4340
+ .stack_depth = 40 ,
4325
4341
},
4326
4342
/* BPF_STX | BPF_XADD | BPF_W/DW */
4327
4343
{
@@ -4336,6 +4352,7 @@ static struct bpf_test tests[] = {
4336
4352
INTERNAL ,
4337
4353
{ },
4338
4354
{ { 0 , 0x22 } },
4355
+ .stack_depth = 40 ,
4339
4356
},
4340
4357
{
4341
4358
"STX_XADD_W: Test side-effects, r10: 0x12 + 0x10 = 0x22" ,
@@ -4351,6 +4368,7 @@ static struct bpf_test tests[] = {
4351
4368
INTERNAL ,
4352
4369
{ },
4353
4370
{ { 0 , 0 } },
4371
+ .stack_depth = 40 ,
4354
4372
},
4355
4373
{
4356
4374
"STX_XADD_W: Test side-effects, r0: 0x12 + 0x10 = 0x22" ,
@@ -4363,6 +4381,7 @@ static struct bpf_test tests[] = {
4363
4381
INTERNAL ,
4364
4382
{ },
4365
4383
{ { 0 , 0x12 } },
4384
+ .stack_depth = 40 ,
4366
4385
},
4367
4386
{
4368
4387
"STX_XADD_W: X + 1 + 1 + 1 + ..." ,
@@ -4384,6 +4403,7 @@ static struct bpf_test tests[] = {
4384
4403
INTERNAL ,
4385
4404
{ },
4386
4405
{ { 0 , 0x22 } },
4406
+ .stack_depth = 40 ,
4387
4407
},
4388
4408
{
4389
4409
"STX_XADD_DW: Test side-effects, r10: 0x12 + 0x10 = 0x22" ,
@@ -4399,6 +4419,7 @@ static struct bpf_test tests[] = {
4399
4419
INTERNAL ,
4400
4420
{ },
4401
4421
{ { 0 , 0 } },
4422
+ .stack_depth = 40 ,
4402
4423
},
4403
4424
{
4404
4425
"STX_XADD_DW: Test side-effects, r0: 0x12 + 0x10 = 0x22" ,
@@ -4411,6 +4432,7 @@ static struct bpf_test tests[] = {
4411
4432
INTERNAL ,
4412
4433
{ },
4413
4434
{ { 0 , 0x12 } },
4435
+ .stack_depth = 40 ,
4414
4436
},
4415
4437
{
4416
4438
"STX_XADD_DW: X + 1 + 1 + 1 + ..." ,
@@ -5809,6 +5831,7 @@ static struct bpf_prog *generate_filter(int which, int *err)
5809
5831
/* Type doesn't really matter here as long as it's not unspec. */
5810
5832
fp -> type = BPF_PROG_TYPE_SOCKET_FILTER ;
5811
5833
memcpy (fp -> insnsi , fptr , fp -> len * sizeof (struct bpf_insn ));
5834
+ fp -> aux -> stack_depth = tests [which ].stack_depth ;
5812
5835
5813
5836
/* We cannot error here as we don't need type compatibility
5814
5837
* checks.
0 commit comments