Skip to content

Commit aece1cf

Browse files
committed
Revert "crypto: testmgr - Add multibuffer acomp testing"
This reverts commit 99585c2. Remove the acomp multibuffer tests as they are buggy. Reported-by: Dmitry Antipov <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent b2e689b commit aece1cf

File tree

1 file changed

+64
-83
lines changed

1 file changed

+64
-83
lines changed

crypto/testmgr.c

Lines changed: 64 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ module_param(fuzz_iterations, uint, 0644);
5858
MODULE_PARM_DESC(fuzz_iterations, "number of fuzz test iterations");
5959
#endif
6060

61-
/* Multibuffer is unlimited. Set arbitrary limit for testing. */
62-
#define MAX_MB_MSGS 16
63-
6461
#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
6562

6663
/* a perfect nop */
@@ -3329,110 +3326,98 @@ static int test_acomp(struct crypto_acomp *tfm,
33293326
int ctcount, int dtcount)
33303327
{
33313328
const char *algo = crypto_tfm_alg_driver_name(crypto_acomp_tfm(tfm));
3332-
struct scatterlist *src = NULL, *dst = NULL;
3333-
struct acomp_req *reqs[MAX_MB_MSGS] = {};
3334-
char *decomp_out[MAX_MB_MSGS] = {};
3335-
char *output[MAX_MB_MSGS] = {};
3336-
struct crypto_wait wait;
3337-
struct acomp_req *req;
3338-
int ret = -ENOMEM;
33393329
unsigned int i;
3330+
char *output, *decomp_out;
3331+
int ret;
3332+
struct scatterlist src, dst;
3333+
struct acomp_req *req;
3334+
struct crypto_wait wait;
33403335

3341-
src = kmalloc_array(MAX_MB_MSGS, sizeof(*src), GFP_KERNEL);
3342-
if (!src)
3343-
goto out;
3344-
dst = kmalloc_array(MAX_MB_MSGS, sizeof(*dst), GFP_KERNEL);
3345-
if (!dst)
3346-
goto out;
3347-
3348-
for (i = 0; i < MAX_MB_MSGS; i++) {
3349-
reqs[i] = acomp_request_alloc(tfm);
3350-
if (!reqs[i])
3351-
goto out;
3352-
3353-
acomp_request_set_callback(reqs[i],
3354-
CRYPTO_TFM_REQ_MAY_SLEEP |
3355-
CRYPTO_TFM_REQ_MAY_BACKLOG,
3356-
crypto_req_done, &wait);
3357-
if (i)
3358-
acomp_request_chain(reqs[i], reqs[0]);
3359-
3360-
output[i] = kmalloc(COMP_BUF_SIZE, GFP_KERNEL);
3361-
if (!output[i])
3362-
goto out;
3336+
output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL);
3337+
if (!output)
3338+
return -ENOMEM;
33633339

3364-
decomp_out[i] = kmalloc(COMP_BUF_SIZE, GFP_KERNEL);
3365-
if (!decomp_out[i])
3366-
goto out;
3340+
decomp_out = kmalloc(COMP_BUF_SIZE, GFP_KERNEL);
3341+
if (!decomp_out) {
3342+
kfree(output);
3343+
return -ENOMEM;
33673344
}
33683345

33693346
for (i = 0; i < ctcount; i++) {
33703347
unsigned int dlen = COMP_BUF_SIZE;
33713348
int ilen = ctemplate[i].inlen;
33723349
void *input_vec;
3373-
int j;
33743350

33753351
input_vec = kmemdup(ctemplate[i].input, ilen, GFP_KERNEL);
33763352
if (!input_vec) {
33773353
ret = -ENOMEM;
33783354
goto out;
33793355
}
33803356

3357+
memset(output, 0, dlen);
33813358
crypto_init_wait(&wait);
3382-
sg_init_one(src, input_vec, ilen);
3359+
sg_init_one(&src, input_vec, ilen);
3360+
sg_init_one(&dst, output, dlen);
33833361

3384-
for (j = 0; j < MAX_MB_MSGS; j++) {
3385-
sg_init_one(dst + j, output[j], dlen);
3386-
acomp_request_set_params(reqs[j], src, dst + j, ilen, dlen);
3362+
req = acomp_request_alloc(tfm);
3363+
if (!req) {
3364+
pr_err("alg: acomp: request alloc failed for %s\n",
3365+
algo);
3366+
kfree(input_vec);
3367+
ret = -ENOMEM;
3368+
goto out;
33873369
}
33883370

3389-
req = reqs[0];
3371+
acomp_request_set_params(req, &src, &dst, ilen, dlen);
3372+
acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
3373+
crypto_req_done, &wait);
3374+
33903375
ret = crypto_wait_req(crypto_acomp_compress(req), &wait);
33913376
if (ret) {
33923377
pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n",
33933378
i + 1, algo, -ret);
33943379
kfree(input_vec);
3380+
acomp_request_free(req);
33953381
goto out;
33963382
}
33973383

33983384
ilen = req->dlen;
33993385
dlen = COMP_BUF_SIZE;
3386+
sg_init_one(&src, output, ilen);
3387+
sg_init_one(&dst, decomp_out, dlen);
34003388
crypto_init_wait(&wait);
3401-
for (j = 0; j < MAX_MB_MSGS; j++) {
3402-
sg_init_one(src + j, output[j], ilen);
3403-
sg_init_one(dst + j, decomp_out[j], dlen);
3404-
acomp_request_set_params(reqs[j], src + j, dst + j, ilen, dlen);
3405-
}
3406-
3407-
crypto_wait_req(crypto_acomp_decompress(req), &wait);
3408-
for (j = 0; j < MAX_MB_MSGS; j++) {
3409-
ret = reqs[j]->base.err;
3410-
if (ret) {
3411-
pr_err("alg: acomp: compression failed on test %d (%d) for %s: ret=%d\n",
3412-
i + 1, j, algo, -ret);
3413-
kfree(input_vec);
3414-
goto out;
3415-
}
3389+
acomp_request_set_params(req, &src, &dst, ilen, dlen);
34163390

3417-
if (reqs[j]->dlen != ctemplate[i].inlen) {
3418-
pr_err("alg: acomp: Compression test %d (%d) failed for %s: output len = %d\n",
3419-
i + 1, j, algo, reqs[j]->dlen);
3420-
ret = -EINVAL;
3421-
kfree(input_vec);
3422-
goto out;
3423-
}
3391+
ret = crypto_wait_req(crypto_acomp_decompress(req), &wait);
3392+
if (ret) {
3393+
pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n",
3394+
i + 1, algo, -ret);
3395+
kfree(input_vec);
3396+
acomp_request_free(req);
3397+
goto out;
3398+
}
34243399

3425-
if (memcmp(input_vec, decomp_out[j], reqs[j]->dlen)) {
3426-
pr_err("alg: acomp: Compression test %d (%d) failed for %s\n",
3427-
i + 1, j, algo);
3428-
hexdump(output[j], reqs[j]->dlen);
3429-
ret = -EINVAL;
3430-
kfree(input_vec);
3431-
goto out;
3432-
}
3400+
if (req->dlen != ctemplate[i].inlen) {
3401+
pr_err("alg: acomp: Compression test %d failed for %s: output len = %d\n",
3402+
i + 1, algo, req->dlen);
3403+
ret = -EINVAL;
3404+
kfree(input_vec);
3405+
acomp_request_free(req);
3406+
goto out;
3407+
}
3408+
3409+
if (memcmp(input_vec, decomp_out, req->dlen)) {
3410+
pr_err("alg: acomp: Compression test %d failed for %s\n",
3411+
i + 1, algo);
3412+
hexdump(output, req->dlen);
3413+
ret = -EINVAL;
3414+
kfree(input_vec);
3415+
acomp_request_free(req);
3416+
goto out;
34333417
}
34343418

34353419
kfree(input_vec);
3420+
acomp_request_free(req);
34363421
}
34373422

34383423
for (i = 0; i < dtcount; i++) {
@@ -3446,9 +3431,10 @@ static int test_acomp(struct crypto_acomp *tfm,
34463431
goto out;
34473432
}
34483433

3434+
memset(output, 0, dlen);
34493435
crypto_init_wait(&wait);
3450-
sg_init_one(src, input_vec, ilen);
3451-
sg_init_one(dst, output[0], dlen);
3436+
sg_init_one(&src, input_vec, ilen);
3437+
sg_init_one(&dst, output, dlen);
34523438

34533439
req = acomp_request_alloc(tfm);
34543440
if (!req) {
@@ -3459,7 +3445,7 @@ static int test_acomp(struct crypto_acomp *tfm,
34593445
goto out;
34603446
}
34613447

3462-
acomp_request_set_params(req, src, dst, ilen, dlen);
3448+
acomp_request_set_params(req, &src, &dst, ilen, dlen);
34633449
acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
34643450
crypto_req_done, &wait);
34653451

@@ -3481,10 +3467,10 @@ static int test_acomp(struct crypto_acomp *tfm,
34813467
goto out;
34823468
}
34833469

3484-
if (memcmp(output[0], dtemplate[i].output, req->dlen)) {
3470+
if (memcmp(output, dtemplate[i].output, req->dlen)) {
34853471
pr_err("alg: acomp: Decompression test %d failed for %s\n",
34863472
i + 1, algo);
3487-
hexdump(output[0], req->dlen);
3473+
hexdump(output, req->dlen);
34883474
ret = -EINVAL;
34893475
kfree(input_vec);
34903476
acomp_request_free(req);
@@ -3498,13 +3484,8 @@ static int test_acomp(struct crypto_acomp *tfm,
34983484
ret = 0;
34993485

35003486
out:
3501-
acomp_request_free(reqs[0]);
3502-
for (i = 0; i < MAX_MB_MSGS; i++) {
3503-
kfree(output[i]);
3504-
kfree(decomp_out[i]);
3505-
}
3506-
kfree(dst);
3507-
kfree(src);
3487+
kfree(decomp_out);
3488+
kfree(output);
35083489
return ret;
35093490
}
35103491

0 commit comments

Comments
 (0)