From patchwork Tue Jun 18 09:21:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 167118 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3964196ilk; Tue, 18 Jun 2019 02:22:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKiunuUan6BvbwLHocho5vzG1eWSAZCb0bwpZXd4CPLWwTK9ArZNBPOXDoMUFtqjCX9jwM X-Received: by 2002:a63:2a83:: with SMTP id q125mr1738960pgq.102.1560849760060; Tue, 18 Jun 2019 02:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560849760; cv=none; d=google.com; s=arc-20160816; b=KcKt7yjFEwnvvp5xDG46C+qLbUUR9gck9FZf+r02C64eoaejLDvQSeZ9NQtNvkc6nL d+/rnQu5QWWJzUkNbe7H6ashpdxkdBqoH31ixnMjkr/D2/R4aEvbFNWdvNFmI3j+QdIr yGCJirqafSJ0yLcq7X9l+arqEtjG5XXtewbzGKIOYe1yeXtST19GfJUdiYi3an47llqz A8BrR4pDgVdro560TCDuFyywEWAG5wbN4ZaQff+iZxTRnLH0lOhvHn2UCco65gW6r15m X8CFpGvR940IVe7BwkVJZ8Z3h7fUHlV+U/dRfT2meGINLVyB06jtskDEEzEouZV4vt8N vaqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=U8CcYIRplHj6L+hWQXoOEYFiyc4iNbGh4RnnX7EwDqM=; b=gsb0w1TsejzPsQBtDNBUiDubZwoJcS6NQzaSMTh1BfT9fYHyr9sIa0dhZ+lR+3GZWM DplJ/AbnAFfDWtuLKVk0Z5G0KPngfYPX274CQzLhfgCZqSWBiu2P8dZmaJV/25ieGefj WyEnMchUJPMwoeVazA4/L3thTFBe4G9AvBILSauDIKC+FzQ67fCxKRCQK2K4a42Jznsp LZPS6oKtzLpg1CSBFBzsJvyS9aZmRhn2khfd53mNyybZJfP7sgIq6JLkD/4ymRLFzgxE oU3PpMMc6GBHpGfHbhv7cC6EfRh5hBtNWNqNTHmJNuN2yJq23es7y0uCluwuF64KoHot Q4OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l36si12799485plb.58.2019.06.18.02.22.39; Tue, 18 Jun 2019 02:22:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729295AbfFRJWi (ORCPT + 3 others); Tue, 18 Jun 2019 05:22:38 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:49445 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728810AbfFRJWi (ORCPT ); Tue, 18 Jun 2019 05:22:38 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1MGi6k-1hqtpz3gm2-00Dpcp; Tue, 18 Jun 2019 11:22:25 +0200 From: Arnd Bergmann To: Herbert Xu , "David S. Miller" Cc: Arnd Bergmann , Eric Biggers , Ard Biesheuvel , Vitaly Chikunov , Gilad Ben-Yossef , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] crypto: testmgr - dynamically allocate testvec_config Date: Tue, 18 Jun 2019 11:21:52 +0200 Message-Id: <20190618092215.2790800-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:mxKuVA8iA1EbQfNShrkOV2y+cvXiII8ei0xEg5HLxKaIKUwQuVc 2G84oK0ClHsBzhAK53bwhfdYfWM/CVUu7TioI1P7yksRUKhTK8EaAGP1beY90+aE81sHqR7 txwyrqNaFpwoHsvHHnKqXu3XhBCjiS0jHqYzMy0DnsAG9IJ66HzuEatosUWj+LQfpRYvVmT n/AWdCJda+kuhrwtywS+A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:7KlQ5KnBSR0=:cS0VUCasrt2uRndfHhgRew r15mI8vLZfA0SJrqf6PAECM3suMt7b79rXiOAwgGqK4IxXsRq4Vb/6t7UWcqlZkTBG/tE/kMH C97mo46aeNt9AI88gV44BHyvhyCdpHyZQyyKVXdVjqiWudZy6wEuPNINXJ6vpCq97FKKXqtvd 8vLk9CQjdxAdRvrCaR0qHfuCuGMAOmXaGPVOxt59qJkdvdIkZ2zNUcAqBX+O9aFYmktpFBFSU AtLD2Xp409UHC2TPiYMuvbQW5WXlfQcq50FCDTZE7YOLbfBzFKGkdtzcQzIw3cK1PixT3c8GQ +Hh7kYogyzPuHcOyJTavbO0scIYLpCRLDT2E0GvzZ3VOl/qL5Pz33lkLQPfqRuBOAX4DqsfaO UsShMI/L1AQcadA6o99kJOy6u4Sn0zHbH9xcuybcLHHgao+UxMq6e+KHD5T0KKDXJYms40euR YaXF0bNLUlJmHHJLHxEhV57pnhusrj2y/sznyVsUN35QvjpwbdE/qjRvh7rle6QmIUWKY+CUa BDC3DawFXc69AJKYMQlj7hGgaL7ojzKrn4XhQclCM7EjPoO2xjo0MF6rnkbXXToOQ90sXoihL s5StOvj5dhSd0nyB6H1BVbrOkJ3iGFPYwwRqnnYj2+ZdKTxD5SvaN4uya99xRs0v1b0XkD8lh OBszwQ9mgG7PGD/cQGoLYl93rMqTuCJH4DU/tzcWlR/IFpeT6LSd6k3QaS55/Q1LliObD2TwP 5uLbiACg4jgwWgC4s7NQt6DntytFaBrgd211+Q== Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On arm32, we get warnings about high stack usage in some of the functions: crypto/testmgr.c:2269:12: error: stack frame size of 1032 bytes in function 'alg_test_aead' [-Werror,-Wframe-larger-than=] static int alg_test_aead(const struct alg_test_desc *desc, const char *driver, ^ crypto/testmgr.c:1693:12: error: stack frame size of 1312 bytes in function '__alg_test_hash' [-Werror,-Wframe-larger-than=] static int __alg_test_hash(const struct hash_testvec *vecs, ^ On of the larger objects on the stack here is struct testvec_config, so change that to dynamic allocation. Fixes: 40153b10d91c ("crypto: testmgr - fuzz AEADs against their generic implementation") Fixes: d435e10e67be ("crypto: testmgr - fuzz skciphers against their generic implementation") Fixes: 9a8a6b3f0950 ("crypto: testmgr - fuzz hashes against their generic implementation") Signed-off-by: Arnd Bergmann --- crypto/testmgr.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) -- 2.20.0 Reviewed-by: Eric Biggers diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 6c28055d41ca..0e07f61f1a31 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -1565,7 +1565,7 @@ static int test_hash_vs_generic_impl(const char *driver, unsigned int i; struct hash_testvec vec = { 0 }; char vec_name[64]; - struct testvec_config cfg; + struct testvec_config *cfg; char cfgname[TESTVEC_CONFIG_NAMELEN]; int err; @@ -1595,6 +1595,12 @@ static int test_hash_vs_generic_impl(const char *driver, return err; } + cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); + if (!cfg) { + err = -ENOMEM; + goto out; + } + /* Check the algorithm properties for consistency. */ if (digestsize != crypto_shash_digestsize(generic_tfm)) { @@ -1629,9 +1635,9 @@ static int test_hash_vs_generic_impl(const char *driver, generate_random_hash_testvec(generic_tfm, &vec, maxkeysize, maxdatasize, vec_name, sizeof(vec_name)); - generate_random_testvec_config(&cfg, cfgname, sizeof(cfgname)); + generate_random_testvec_config(cfg, cfgname, sizeof(cfgname)); - err = test_hash_vec_cfg(driver, &vec, vec_name, &cfg, + err = test_hash_vec_cfg(driver, &vec, vec_name, cfg, req, desc, tsgl, hashstate); if (err) goto out; @@ -1639,6 +1645,7 @@ static int test_hash_vs_generic_impl(const char *driver, } err = 0; out: + kfree(cfg); kfree(vec.key); kfree(vec.plaintext); kfree(vec.digest); @@ -2135,7 +2142,7 @@ static int test_aead_vs_generic_impl(const char *driver, unsigned int i; struct aead_testvec vec = { 0 }; char vec_name[64]; - struct testvec_config cfg; + struct testvec_config *cfg; char cfgname[TESTVEC_CONFIG_NAMELEN]; int err; @@ -2165,6 +2172,12 @@ static int test_aead_vs_generic_impl(const char *driver, return err; } + cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); + if (!cfg) { + err = -ENOMEM; + goto out; + } + generic_req = aead_request_alloc(generic_tfm, GFP_KERNEL); if (!generic_req) { err = -ENOMEM; @@ -2219,13 +2232,13 @@ static int test_aead_vs_generic_impl(const char *driver, generate_random_aead_testvec(generic_req, &vec, maxkeysize, maxdatasize, vec_name, sizeof(vec_name)); - generate_random_testvec_config(&cfg, cfgname, sizeof(cfgname)); + generate_random_testvec_config(cfg, cfgname, sizeof(cfgname)); - err = test_aead_vec_cfg(driver, ENCRYPT, &vec, vec_name, &cfg, + err = test_aead_vec_cfg(driver, ENCRYPT, &vec, vec_name, cfg, req, tsgls); if (err) goto out; - err = test_aead_vec_cfg(driver, DECRYPT, &vec, vec_name, &cfg, + err = test_aead_vec_cfg(driver, DECRYPT, &vec, vec_name, cfg, req, tsgls); if (err) goto out; @@ -2233,6 +2246,7 @@ static int test_aead_vs_generic_impl(const char *driver, } err = 0; out: + kfree(cfg); kfree(vec.key); kfree(vec.iv); kfree(vec.assoc); @@ -2682,7 +2696,7 @@ static int test_skcipher_vs_generic_impl(const char *driver, unsigned int i; struct cipher_testvec vec = { 0 }; char vec_name[64]; - struct testvec_config cfg; + struct testvec_config *cfg; char cfgname[TESTVEC_CONFIG_NAMELEN]; int err; @@ -2716,6 +2730,12 @@ static int test_skcipher_vs_generic_impl(const char *driver, return err; } + cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); + if (!cfg) { + err = -ENOMEM; + goto out; + } + generic_req = skcipher_request_alloc(generic_tfm, GFP_KERNEL); if (!generic_req) { err = -ENOMEM; @@ -2763,20 +2783,21 @@ static int test_skcipher_vs_generic_impl(const char *driver, for (i = 0; i < fuzz_iterations * 8; i++) { generate_random_cipher_testvec(generic_req, &vec, maxdatasize, vec_name, sizeof(vec_name)); - generate_random_testvec_config(&cfg, cfgname, sizeof(cfgname)); + generate_random_testvec_config(cfg, cfgname, sizeof(cfgname)); err = test_skcipher_vec_cfg(driver, ENCRYPT, &vec, vec_name, - &cfg, req, tsgls); + cfg, req, tsgls); if (err) goto out; err = test_skcipher_vec_cfg(driver, DECRYPT, &vec, vec_name, - &cfg, req, tsgls); + cfg, req, tsgls); if (err) goto out; cond_resched(); } err = 0; out: + kfree(cfg); kfree(vec.key); kfree(vec.iv); kfree(vec.ptext); From patchwork Tue Jun 18 09:21:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 167119 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3964520ilk; Tue, 18 Jun 2019 02:23:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiZUGLJUgwGdAqmRsDFzrysPoQ+MDhYv7m7pJRmR3Yo+3f+GL9fYgq7XCjJsdZsj8L0Z4/ X-Received: by 2002:a62:1515:: with SMTP id 21mr41356020pfv.100.1560849783866; Tue, 18 Jun 2019 02:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560849783; cv=none; d=google.com; s=arc-20160816; b=H26Gvv5nzdyP1P/Fcok8FuckU1A8GjnHlBPpbeevAjEquTpoMDgSJnGyKTLuW6wSAe s+E8HtiCIcc732WZQBgNc2pZxFGvEVAJoWVVflHNiQ3OSrOjIHLqGy3c/Ls488jRqOp0 PsRXSCMG0IErEbj1w/70zQC/+tpGp7jTBo7iEluvSCU1DVtNhPOwAQla7TJpmelf1zjH nuMbHJwPv6ZHkNwBkC+70cm2lgLVrC1j4KqkSYOllaBT5ksktZskft+k3iPPHd9hGUZB l/oqjcZnmNN21ZRZryUmHLHELxr8JmrnJG36Kska4tRQuTRvBFHRpgeWKOzljeFIxqVH cwIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wzWbHkOHfCJ/0VQ6qP/OQrMpK1siATnJ7YvKnRL61uM=; b=huDYF16qWADMxv8yHABd7uWHFVk2kLS1HMYZDwgmiVfa7WF8DUcfJmZmAwEN/teNPd ka6r9PcqXhf+WeESH0INMsFKMUQduvgjM0gjEBsjGc5jR5Kez52HjX+Gdgu/vgrjyOmE 0hn0DL4uJ3g5ZGtZ3Bomo+aBC7bGwrkofVCKgzMns+owJpKxDcZhAIt7jDj3mC4zXwj+ atnwDGsMJW2DZ7iWFnN3QNCqBdGfw+bidFoDHWP2Hzk91jPkHhDy6siMFMK5MxoxWy4s UcRu9fcXbn+IjWAiVNwOQJq7sisSviWXmWd17YPCEEcoTUm8yGmxRHgqSBmGh4nY3Wo1 o6nQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13si1802748pjn.89.2019.06.18.02.23.03; Tue, 18 Jun 2019 02:23:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729370AbfFRJXD (ORCPT + 3 others); Tue, 18 Jun 2019 05:23:03 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:55425 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728810AbfFRJXC (ORCPT ); Tue, 18 Jun 2019 05:23:02 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1N49Yn-1icvsZ0urh-0102X2; Tue, 18 Jun 2019 11:22:50 +0200 From: Arnd Bergmann To: Herbert Xu , "David S. Miller" Cc: Arnd Bergmann , Eric Biggers , Eric Biggers , Ard Biesheuvel , Vitaly Chikunov , Gilad Ben-Yossef , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] crypto: testmgr - dynamically allocate crypto_shash Date: Tue, 18 Jun 2019 11:21:53 +0200 Message-Id: <20190618092215.2790800-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190618092215.2790800-1-arnd@arndb.de> References: <20190618092215.2790800-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:bO58TLJx+C6E/baJmdAkbG6/15WeaVirgQ4dxIMpxNhBaUxJa5q 0LKHAxCuKLWNgpKkZ91FP0UvVB47wZdeUjjc61FoclVxBvJf2I1v5Lu5BcENrE0kniyr+0J +hODOn4LOGP3bVsy0N4Cx8wn4xmyhQuSss3GQlFZ4YBDSPdXtPXI/L26EZOdiZZThdlwHBp xfKLQe3DBIyGjTamWkFbQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:xnuTpmV9pJQ=:mv+KzxkuI/BpPdXtwon4WS 5shJO2YB6vQAJJemqacnK21USBZLkoBpP8/VKXFPIlFTobKD/fI3IA2kH0RnpKZvgmzUCrNb5 X6k5SxAHAU30zt60pQr7xmvjipGmDc4os34k9Aoi3Fa7Nf5fTrUo+P6AnO7+UrGZo4jS2FDhy YOWuDG4VgNHa7CufBQVtNMRAji4Rpu0Xd9/qmXaUtlpqIm0BcysNlhUF+OwW4Nd3lMJKghQTn NKxOaocvsQhgkafE5dMpxKOB0YOMqiW61BllNUrc5iTu55nV6t2iSvjBVRadzcxQGAYvctwwb paBlwyOzwThsTB+CJUovcjrjst4So/LMVKgbBj0V236qhhI3t77s4GP7woVyRXH2NsPC2PC75 SQgMggoN7eFBUqym4l9eRCuPnY6wusHgBGOSJVxpX0KVw7v0ZmAfAEFOM1oi+vOhHQ/Pjgf5q M89f1SlLqrNfh1p1xbcDorCWYz0lYADjp2UryTMuMWQM8dTxak1N4KUvqTP7EFvROmY7BarVw s5arN/KJcJJ/M37Nnp2COlUmdeegyj6x0Gs4UTc61itOgamC5k7i5xrgnNdGQCvQM6hLYKTZi PMDCQwRiWCsX2SFn/GQgimHYIOZSk9x12Tg3/E/1qnXUEUFz40/3rQ/XRM7tDcKCld5tMO129 JIDVtzDbqtKOmPfqnBj276akm1LbdCuQuypX7m72K/UPM7DL6RvX+Ri3RX6snuYNz/639V2Wf sZekFWHuWQ9XlzapnkMv4aDG94VP+ZFf6BDefA== Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The largest stack object in this file is now the shash descriptor. Since there are many other stack variables, this can push it over the 1024 byte warning limit, in particular with clang and KASAN: crypto/testmgr.c:1693:12: error: stack frame size of 1312 bytes in function '__alg_test_hash' [-Werror,-Wframe-larger-than=] Make test_hash_vs_generic_impl() do the same thing as the corresponding eaed and skcipher functions by allocating the descriptor dynamically. We can still do better than this, but it brings us well below the 1024 byte limit. Suggested-by: Eric Biggers Fixes: 9a8a6b3f0950 ("crypto: testmgr - fuzz hashes against their generic implementation") Signed-off-by: Arnd Bergmann --- crypto/testmgr.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- 2.20.0 diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 0e07f61f1a31..0ce28b3aab3c 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -1503,14 +1503,12 @@ static int test_hash_vec(const char *driver, const struct hash_testvec *vec, * Generate a hash test vector from the given implementation. * Assumes the buffers in 'vec' were already allocated. */ -static void generate_random_hash_testvec(struct crypto_shash *tfm, +static void generate_random_hash_testvec(struct shash_desc *desc, struct hash_testvec *vec, unsigned int maxkeysize, unsigned int maxdatasize, char *name, size_t max_namelen) { - SHASH_DESC_ON_STACK(desc, tfm); - /* Data */ vec->psize = generate_random_length(maxdatasize); generate_random_bytes((u8 *)vec->plaintext, vec->psize); @@ -1527,7 +1525,7 @@ static void generate_random_hash_testvec(struct crypto_shash *tfm, vec->ksize = 1 + (prandom_u32() % maxkeysize); generate_random_bytes((u8 *)vec->key, vec->ksize); - vec->setkey_error = crypto_shash_setkey(tfm, vec->key, + vec->setkey_error = crypto_shash_setkey(desc->tfm, vec->key, vec->ksize); /* If the key couldn't be set, no need to continue to digest. */ if (vec->setkey_error) @@ -1535,7 +1533,6 @@ static void generate_random_hash_testvec(struct crypto_shash *tfm, } /* Digest */ - desc->tfm = tfm; vec->digest_error = crypto_shash_digest(desc, vec->plaintext, vec->psize, (u8 *)vec->digest); done: @@ -1562,6 +1559,7 @@ static int test_hash_vs_generic_impl(const char *driver, const char *algname = crypto_hash_alg_common(tfm)->base.cra_name; char _generic_driver[CRYPTO_MAX_ALG_NAME]; struct crypto_shash *generic_tfm = NULL; + struct shash_desc *generic_desc = NULL; unsigned int i; struct hash_testvec vec = { 0 }; char vec_name[64]; @@ -1601,6 +1599,14 @@ static int test_hash_vs_generic_impl(const char *driver, goto out; } + generic_desc = kzalloc(sizeof(*desc) + + crypto_shash_descsize(generic_tfm), GFP_KERNEL); + if (!generic_desc) { + err = -ENOMEM; + goto out; + } + generic_desc->tfm = generic_tfm; + /* Check the algorithm properties for consistency. */ if (digestsize != crypto_shash_digestsize(generic_tfm)) { @@ -1632,7 +1638,7 @@ static int test_hash_vs_generic_impl(const char *driver, } for (i = 0; i < fuzz_iterations * 8; i++) { - generate_random_hash_testvec(generic_tfm, &vec, + generate_random_hash_testvec(generic_desc, &vec, maxkeysize, maxdatasize, vec_name, sizeof(vec_name)); generate_random_testvec_config(cfg, cfgname, sizeof(cfgname)); @@ -1650,6 +1656,7 @@ static int test_hash_vs_generic_impl(const char *driver, kfree(vec.plaintext); kfree(vec.digest); crypto_free_shash(generic_tfm); + kzfree(generic_desc); return err; } #else /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */