Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "crypto: testmgr - Add multibuffer acomp testing"

This reverts commit 99585c2192cb1ce212876e82ef01d1c98c7f4699.

Remove the acomp multibuffer tests so that the interface can be
redesigned.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+63 -82
+63 -82
crypto/testmgr.c
··· 58 58 MODULE_PARM_DESC(fuzz_iterations, "number of fuzz test iterations"); 59 59 #endif 60 60 61 - /* Multibuffer is unlimited. Set arbitrary limit for testing. */ 62 - #define MAX_MB_MSGS 16 63 - 64 61 #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS 65 62 66 63 /* a perfect nop */ ··· 3326 3329 int ctcount, int dtcount) 3327 3330 { 3328 3331 const char *algo = crypto_tfm_alg_driver_name(crypto_acomp_tfm(tfm)); 3329 - struct scatterlist *src = NULL, *dst = NULL; 3330 - struct acomp_req *reqs[MAX_MB_MSGS] = {}; 3331 - char *decomp_out[MAX_MB_MSGS] = {}; 3332 - char *output[MAX_MB_MSGS] = {}; 3333 - struct crypto_wait wait; 3334 - struct acomp_req *req; 3335 - int ret = -ENOMEM; 3336 3332 unsigned int i; 3333 + char *output, *decomp_out; 3334 + int ret; 3335 + struct scatterlist src, dst; 3336 + struct acomp_req *req; 3337 + struct crypto_wait wait; 3337 3338 3338 - src = kmalloc_array(MAX_MB_MSGS, sizeof(*src), GFP_KERNEL); 3339 - if (!src) 3340 - goto out; 3341 - dst = kmalloc_array(MAX_MB_MSGS, sizeof(*dst), GFP_KERNEL); 3342 - if (!dst) 3343 - goto out; 3339 + output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); 3340 + if (!output) 3341 + return -ENOMEM; 3344 3342 3345 - for (i = 0; i < MAX_MB_MSGS; i++) { 3346 - reqs[i] = acomp_request_alloc(tfm); 3347 - if (!reqs[i]) 3348 - goto out; 3349 - 3350 - acomp_request_set_callback(reqs[i], 3351 - CRYPTO_TFM_REQ_MAY_SLEEP | 3352 - CRYPTO_TFM_REQ_MAY_BACKLOG, 3353 - crypto_req_done, &wait); 3354 - if (i) 3355 - acomp_request_chain(reqs[i], reqs[0]); 3356 - 3357 - output[i] = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); 3358 - if (!output[i]) 3359 - goto out; 3360 - 3361 - decomp_out[i] = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); 3362 - if (!decomp_out[i]) 3363 - goto out; 3343 + decomp_out = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); 3344 + if (!decomp_out) { 3345 + kfree(output); 3346 + return -ENOMEM; 3364 3347 } 3365 3348 3366 3349 for (i = 0; i < ctcount; i++) { 3367 3350 unsigned int dlen = COMP_BUF_SIZE; 3368 3351 int ilen = ctemplate[i].inlen; 3369 3352 void *input_vec; 3370 - int j; 3371 3353 3372 3354 input_vec = kmemdup(ctemplate[i].input, ilen, GFP_KERNEL); 3373 3355 if (!input_vec) { ··· 3354 3378 goto out; 3355 3379 } 3356 3380 3381 + memset(output, 0, dlen); 3357 3382 crypto_init_wait(&wait); 3358 - sg_init_one(src, input_vec, ilen); 3383 + sg_init_one(&src, input_vec, ilen); 3384 + sg_init_one(&dst, output, dlen); 3359 3385 3360 - for (j = 0; j < MAX_MB_MSGS; j++) { 3361 - sg_init_one(dst + j, output[j], dlen); 3362 - acomp_request_set_params(reqs[j], src, dst + j, ilen, dlen); 3386 + req = acomp_request_alloc(tfm); 3387 + if (!req) { 3388 + pr_err("alg: acomp: request alloc failed for %s\n", 3389 + algo); 3390 + kfree(input_vec); 3391 + ret = -ENOMEM; 3392 + goto out; 3363 3393 } 3364 3394 3365 - req = reqs[0]; 3395 + acomp_request_set_params(req, &src, &dst, ilen, dlen); 3396 + acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, 3397 + crypto_req_done, &wait); 3398 + 3366 3399 ret = crypto_wait_req(crypto_acomp_compress(req), &wait); 3367 3400 if (ret) { 3368 3401 pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n", 3369 3402 i + 1, algo, -ret); 3370 3403 kfree(input_vec); 3404 + acomp_request_free(req); 3371 3405 goto out; 3372 3406 } 3373 3407 3374 3408 ilen = req->dlen; 3375 3409 dlen = COMP_BUF_SIZE; 3410 + sg_init_one(&src, output, ilen); 3411 + sg_init_one(&dst, decomp_out, dlen); 3376 3412 crypto_init_wait(&wait); 3377 - for (j = 0; j < MAX_MB_MSGS; j++) { 3378 - sg_init_one(src + j, output[j], ilen); 3379 - sg_init_one(dst + j, decomp_out[j], dlen); 3380 - acomp_request_set_params(reqs[j], src + j, dst + j, ilen, dlen); 3413 + acomp_request_set_params(req, &src, &dst, ilen, dlen); 3414 + 3415 + ret = crypto_wait_req(crypto_acomp_decompress(req), &wait); 3416 + if (ret) { 3417 + pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n", 3418 + i + 1, algo, -ret); 3419 + kfree(input_vec); 3420 + acomp_request_free(req); 3421 + goto out; 3381 3422 } 3382 3423 3383 - crypto_wait_req(crypto_acomp_decompress(req), &wait); 3384 - for (j = 0; j < MAX_MB_MSGS; j++) { 3385 - ret = reqs[j]->base.err; 3386 - if (ret) { 3387 - pr_err("alg: acomp: compression failed on test %d (%d) for %s: ret=%d\n", 3388 - i + 1, j, algo, -ret); 3389 - kfree(input_vec); 3390 - goto out; 3391 - } 3424 + if (req->dlen != ctemplate[i].inlen) { 3425 + pr_err("alg: acomp: Compression test %d failed for %s: output len = %d\n", 3426 + i + 1, algo, req->dlen); 3427 + ret = -EINVAL; 3428 + kfree(input_vec); 3429 + acomp_request_free(req); 3430 + goto out; 3431 + } 3392 3432 3393 - if (reqs[j]->dlen != ctemplate[i].inlen) { 3394 - pr_err("alg: acomp: Compression test %d (%d) failed for %s: output len = %d\n", 3395 - i + 1, j, algo, reqs[j]->dlen); 3396 - ret = -EINVAL; 3397 - kfree(input_vec); 3398 - goto out; 3399 - } 3400 - 3401 - if (memcmp(input_vec, decomp_out[j], reqs[j]->dlen)) { 3402 - pr_err("alg: acomp: Compression test %d (%d) failed for %s\n", 3403 - i + 1, j, algo); 3404 - hexdump(output[j], reqs[j]->dlen); 3405 - ret = -EINVAL; 3406 - kfree(input_vec); 3407 - goto out; 3408 - } 3433 + if (memcmp(input_vec, decomp_out, req->dlen)) { 3434 + pr_err("alg: acomp: Compression test %d failed for %s\n", 3435 + i + 1, algo); 3436 + hexdump(output, req->dlen); 3437 + ret = -EINVAL; 3438 + kfree(input_vec); 3439 + acomp_request_free(req); 3440 + goto out; 3409 3441 } 3410 3442 3411 3443 kfree(input_vec); 3444 + acomp_request_free(req); 3412 3445 } 3413 3446 3414 3447 for (i = 0; i < dtcount; i++) { ··· 3431 3446 goto out; 3432 3447 } 3433 3448 3449 + memset(output, 0, dlen); 3434 3450 crypto_init_wait(&wait); 3435 - sg_init_one(src, input_vec, ilen); 3436 - sg_init_one(dst, output[0], dlen); 3451 + sg_init_one(&src, input_vec, ilen); 3452 + sg_init_one(&dst, output, dlen); 3437 3453 3438 3454 req = acomp_request_alloc(tfm); 3439 3455 if (!req) { ··· 3445 3459 goto out; 3446 3460 } 3447 3461 3448 - acomp_request_set_params(req, src, dst, ilen, dlen); 3462 + acomp_request_set_params(req, &src, &dst, ilen, dlen); 3449 3463 acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, 3450 3464 crypto_req_done, &wait); 3451 3465 ··· 3467 3481 goto out; 3468 3482 } 3469 3483 3470 - if (memcmp(output[0], dtemplate[i].output, req->dlen)) { 3484 + if (memcmp(output, dtemplate[i].output, req->dlen)) { 3471 3485 pr_err("alg: acomp: Decompression test %d failed for %s\n", 3472 3486 i + 1, algo); 3473 - hexdump(output[0], req->dlen); 3487 + hexdump(output, req->dlen); 3474 3488 ret = -EINVAL; 3475 3489 kfree(input_vec); 3476 3490 acomp_request_free(req); ··· 3484 3498 ret = 0; 3485 3499 3486 3500 out: 3487 - acomp_request_free(reqs[0]); 3488 - for (i = 0; i < MAX_MB_MSGS; i++) { 3489 - kfree(output[i]); 3490 - kfree(decomp_out[i]); 3491 - } 3492 - kfree(dst); 3493 - kfree(src); 3501 + kfree(decomp_out); 3502 + kfree(output); 3494 3503 return ret; 3495 3504 } 3496 3505