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);