Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2497370ybl; Thu, 29 Aug 2019 08:59:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7DXh/CdXCKb/tILjrp8Wdau0Y/tQBciyZfK3YuqTEMCMEMA8aB3YPb41AKZczV1awo0+V X-Received: by 2002:a17:902:8488:: with SMTP id c8mr10068247plo.164.1567094368469; Thu, 29 Aug 2019 08:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567094368; cv=none; d=google.com; s=arc-20160816; b=zRj/Xmlo5fG3t4YuTKyGJnYdOU8iG64GwPk7uQT3I4psaMPIL2E2WBVdqNB1nrImKU JlGjj7JpnSUekszoJL5CIe9aTGD0kar6F4o2lSGteT3cPTkhwqnQHc/+FV2iF8iHwk77 yznBkcahpHqYVMPkJzfu/oK8vH9bXm8H/v8/axAMOehCCbf9MXLbxIocrQGb9egLyOtP z1IyjxxF+3vCtCPm7HESp7saLveWIW1JDh76CTuJUb45EzYvUBK3mVBwruSYz4aNLqqs /28hsSRbWZ076UWtoxf8GUGambDw9y0OFz3rWM/9zZNANU254pX8IvrKp2fsduKtAuu2 amlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=F0IGQL/ukZeSouqGM+Ew8q24eWD8aTdWwI5/zVLkZT8=; b=N9jpWYC92i681GUiFGlLMc272rjST1j5y7d7DP4ANZzQLkzJS8bLcYMPQyGElOh4hQ oRs3iQ5/zcJ/SkDJvJemEc0ARVzZgVPlV0/2iQk7Cgeepqj0AIOSlIdCvC9Nuuq7VYxz QbfcNbVqGElQVSuY+faEx6K+dUBCGgzrpun/2qMbkWQWM4llyd6xvnasRaF1yWEEkGnM Fblfa0eBldv57HNWHea/PH3/V65oTn+W5I0RFcAITBQp5uKPHPfQnmM3mZXkYjumTiX7 Seor+pBoPeVPC2z8lZoNjz2oa6WTzV8J6r8SmhUAalj2NmrB5/9oHAH5MYBUhvGfJkhW qGPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G5EYYBsl; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si2453394pjn.77.2019.08.29.08.59.08; Thu, 29 Aug 2019 08:59:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=G5EYYBsl; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727362AbfH2P6e (ORCPT + 99 others); Thu, 29 Aug 2019 11:58:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:58078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726283AbfH2P6e (ORCPT ); Thu, 29 Aug 2019 11:58:34 -0400 Received: from zzz.localdomain (h184-61-154-48.mdsnwi.dsl.dynamic.tds.net [184.61.154.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0AF4420578; Thu, 29 Aug 2019 15:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567094312; bh=nj0U9SGIgoP+SiWF11LyGTpSq7TNiqMEvEF4ZodQNHQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G5EYYBsl/vvk5LMiSF3JHds526ds5lv5ok6JDArgYKX0k00l3MKDlQy7EIXCXN/tj hgJAD1+gkwSLKCwAtVrDPJfvxjvQ3q6pATcrj/vO/cAXrgppo1ny6SsFi5eYC5tKt5 cdz4abWNrDASPx3o2+o0nyNZiUUJwq/cDV0yOtN8= Date: Thu, 29 Aug 2019 10:58:19 -0500 From: Eric Biggers To: Christophe Leroy Cc: linux-crypto@vger.kernel.org, Herbert Xu , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 13/15] crypto: testmgr - convert hash testing to use testvec_configs Message-ID: <20190829155819.GA14558@zzz.localdomain> Mail-Followup-To: Christophe Leroy , linux-crypto@vger.kernel.org, Herbert Xu , linux-kernel@vger.kernel.org References: <20190201075150.18644-1-ebiggers@kernel.org> <20190201075150.18644-14-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Aug 29, 2019 at 05:32:46PM +0200, Christophe Leroy wrote: > Hi Eric, > > > Le 01/02/2019 ? 08:51, Eric Biggers a ?crit?: > > From: Eric Biggers > > > > Convert alg_test_hash() to use the new test framework, adding a list of > > testvec_configs to test by default. When the extra self-tests are > > enabled, randomly generated testvec_configs are tested as well. > > > > This improves hash test coverage mainly because now all algorithms have > > a variety of data layouts tested, whereas before each algorithm was > > responsible for declaring its own chunked test cases which were often > > missing or provided poor test coverage. The new code also tests both > > the MAY_SLEEP and !MAY_SLEEP cases and buffers that cross pages. > > > > This already found bugs in the hash walk code and in the arm32 and arm64 > > implementations of crct10dif. > > > > I removed the hash chunked test vectors that were the same as > > non-chunked ones, but left the ones that were unique. > > > > Signed-off-by: Eric Biggers > > --- > > crypto/testmgr.c | 795 ++++++++++++++++++++--------------------------- > > crypto/testmgr.h | 107 +------ > > 2 files changed, 352 insertions(+), 550 deletions(-) > > > > diff --git a/crypto/testmgr.c b/crypto/testmgr.c > > index 7638090ff1b0a..96aa268ff4184 100644 > > --- a/crypto/testmgr.c > > +++ b/crypto/testmgr.c > > [...] > > > > -static int __test_hash(struct crypto_ahash *tfm, > > - const struct hash_testvec *template, unsigned int tcount, > > - enum hash_test test_type, const int align_offset) > > +static int test_hash_vec_cfg(const char *driver, > > + const struct hash_testvec *vec, > > + unsigned int vec_num, > > + const struct testvec_config *cfg, > > + struct ahash_request *req, > > + struct test_sglist *tsgl, > > + u8 *hashstate) > > { > > - const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm)); > > - size_t digest_size = crypto_ahash_digestsize(tfm); > > - unsigned int i, j, k, temp; > > - struct scatterlist sg[8]; > > - char *result; > > - char *key; > > - struct ahash_request *req; > > - struct crypto_wait wait; > > - void *hash_buff; > > - char *xbuf[XBUFSIZE]; > > - int ret = -ENOMEM; > > - > > - result = kmalloc(digest_size, GFP_KERNEL); > > - if (!result) > > - return ret; > > - key = kmalloc(MAX_KEYLEN, GFP_KERNEL); > > - if (!key) > > - goto out_nobuf; > > - if (testmgr_alloc_buf(xbuf)) > > - goto out_nobuf; > > + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); > > + const unsigned int alignmask = crypto_ahash_alignmask(tfm); > > + const unsigned int digestsize = crypto_ahash_digestsize(tfm); > > + const unsigned int statesize = crypto_ahash_statesize(tfm); > > + const u32 req_flags = CRYPTO_TFM_REQ_MAY_BACKLOG | cfg->req_flags; > > + const struct test_sg_division *divs[XBUFSIZE]; > > + DECLARE_CRYPTO_WAIT(wait); > > + struct kvec _input; > > + struct iov_iter input; > > + unsigned int i; > > + struct scatterlist *pending_sgl; > > + unsigned int pending_len; > > + u8 result[HASH_MAX_DIGESTSIZE + TESTMGR_POISON_LEN]; > > Before this patch, result was allocated with kmalloc(). > Now, result is in the stack. Is there a reason for this change ? > > Due to this change, the talitos driver fails when using CONFIG_VMAP_STACK, > because result is not dma-able anymore. > Yes, moving 'result' to the stack simplified the code slightly and also helps detect buggy drivers that assume that 'result' is DMA-able. Note that some "real" API users also put 'result' on the stack, as the API allows it. This is not new; the only new thing is that the tests now test it. > > How should this be fixed ? > Take a look at how other drivers have fixed this issue in the past, e.g. commit c19650d6ea9 ("crypto: caam - fix DMA mapping of stack memory"). Seems that you need to DMA into a temporary buffer. - Eric