From patchwork Sun Jul 2 14:41:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106842 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8292203obb; Sun, 2 Jul 2017 07:43:16 -0700 (PDT) X-Received: by 10.98.32.200 with SMTP id m69mr5405535pfj.5.1499006596776; Sun, 02 Jul 2017 07:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006596; cv=none; d=google.com; s=arc-20160816; b=M1htpJj0KKQofSHjPdtP7KawLYnaBHHYIzvLoMaiPa3GM5uWrNs/g1xNyMTltPeCaq 72Ow7f9TlASMUyewKy9MCd3huRaSnXwtfHoQXJVyoo8fzpF1c2GiKEN8HjinPsqiLnFx MAXZxdT2psrBiT7BFCduw/Rb++8ygSKvUrDDbv0gqjjVEDXsNtHR1kyg+GHW4F8Hun1D ST1NG0XTOEzhVvOI/p8oi2Rq3PItqWNkgVnUPeskutvMItg8NmCyIyeV0vQsyLpTepoY ZvVOPtd1Mx/HaBOoeU/xcOznSpkBQwPaHHE+3JJ+0gu60gehfLLtsyicY9UMVznC0yiD G83Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=riNmqUsaE2cb+KqO9T4hjGvGutosYPr8PbuQLe9VDDw=; b=pQiMAle+6UcIYVOxbz/m2fi62WiKDiou/S+tEalqtRhO9+Y125wGWvFDTKzuAE68tk rW7FQgFz7NygwQwRctu3QurVLY2Xit9Km2UEavvfGPeD8p7s7dDRKjy2gY3KW2+mL4rm kW0r/UWjgg1K57kaPjCwPAE3ONQIJ9NgOByYhZTBWZsF/0a8CFvgrHfTVsOkRZDd5t++ OuRCMSHhticXJHtN2fx3/AnhTmeTNXDuYYrmwckdI8K6jIbRFDbori/E4EVmH06hj5YW AuKowRCIOPbPhb/Dw6NTfGnIZZSwnyQdxr7ysQg8VQGtMufUJU15PDr6Qqkws5WX8HCU /V2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 g72si10235551pfa.464.2017.07.02.07.43.16; Sun, 02 Jul 2017 07:43:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752201AbdGBOnJ (ORCPT + 25 others); Sun, 2 Jul 2017 10:43:09 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53476 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751717AbdGBOnB (ORCPT ); Sun, 2 Jul 2017 10:43:01 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 13279344; Sun, 2 Jul 2017 07:42:56 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2F08C3F578; Sun, 2 Jul 2017 07:42:47 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 02/28] crypto: atmel: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:44 +0300 Message-Id: <1499006535-19760-3-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. drivers/crypto/atmel-sha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.1.4 diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c index a948202..30223ee 100644 --- a/drivers/crypto/atmel-sha.c +++ b/drivers/crypto/atmel-sha.c @@ -1204,7 +1204,7 @@ static int atmel_sha_finup(struct ahash_request *req) ctx->flags |= SHA_FLAGS_FINUP; err1 = atmel_sha_update(req); - if (err1 == -EINPROGRESS || err1 == -EBUSY) + if (err1 == -EINPROGRESS || err1 == -EIOCBQUEUED) return err1; /* From patchwork Sun Jul 2 14:41:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106844 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8292749obb; Sun, 2 Jul 2017 07:43:59 -0700 (PDT) X-Received: by 10.99.51.142 with SMTP id z136mr5618985pgz.275.1499006638943; Sun, 02 Jul 2017 07:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006638; cv=none; d=google.com; s=arc-20160816; b=JeRizetmw05XuGTLsKhtELQWtYjHoy102q1NgiN4rp5yq+I4BA9PW9MOm7Z7gejLA+ rl8hbTN1J757dPOUMDrj98ZBwjNAzyhT2qFGUbLTQzCheH1+vN4u/8YPggL/f0W6Yul2 Sqtzb4rYPMEygyeViYmNbpUkwuC6lFJrR9p1DhGqtklecYaHx8yyS+nbA3umpoHxogoN lLkowCrMJ4qaJrTNrtENWudUZw7sEwp6pX60A63m90wVenLNFQb32tKlqA9fAa+WGeIh EgXOJVugcqjeYHPoqgmnONyvIA69KJ9Et1TYtHpwWv7hfKAwTOmPFMk6jOuWv1EeQNwE okZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=nUmlO6ReVFrVtffumYqw03nAxThJjp1o/iZ22srjGro=; b=m3WYRgqxtHCh9Nbkoavu7nB1CN0DvucF9SvphMTURy0KdpvJIe/sybwskVUeUoyNXd xxUtDi90t+YT60pQBtIkPYlprxxTz/JSoxxfoQoq426K5/0kXx3QPKrLHyJ0c6Pfh/2q ocwkVdiK9yWMludTU0NRwrTc+i9r2AUsY31PrzzGfT3k/Uwp3lG2Eha7dtR+jjzyIFt7 IT1Gj5i4ZUqBxifHKCCalu39y/L1jh4bSlR/f2VLA48L0499xuHq2zxcWGRosIzygw1A uW8Ut3+7+PWBp3RsK8LdO+rsPr3qkW+50o7baJg+1GtFd9YBYAANoSfvHsw6oNUPcLfH TMow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 g16si10183773pfe.261.2017.07.02.07.43.58; Sun, 02 Jul 2017 07:43:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752305AbdGBOni (ORCPT + 25 others); Sun, 2 Jul 2017 10:43:38 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53584 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752214AbdGBOn1 (ORCPT ); Sun, 2 Jul 2017 10:43:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E28C4344; Sun, 2 Jul 2017 07:43:21 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 14F0A3F578; Sun, 2 Jul 2017 07:43:13 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 04/28] crypto: marvell/cesa: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:46 +0300 Message-Id: <1499006535-19760-5-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. drivers/crypto/marvell/cesa.c | 2 +- drivers/crypto/marvell/cesa.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c index 6e7a5c7..5a0f7d1 100644 --- a/drivers/crypto/marvell/cesa.c +++ b/drivers/crypto/marvell/cesa.c @@ -184,7 +184,7 @@ int mv_cesa_queue_req(struct crypto_async_request *req, ret = crypto_enqueue_request(&engine->queue, req); if ((mv_cesa_req_get_type(creq) == CESA_DMA_REQ) && (ret == -EINPROGRESS || - (ret == -EBUSY && req->flags & CRYPTO_TFM_REQ_MAY_BACKLOG))) + ret == -EIOCBQUEUED)) mv_cesa_tdma_chain(engine, creq); spin_unlock_bh(&engine->lock); diff --git a/drivers/crypto/marvell/cesa.h b/drivers/crypto/marvell/cesa.h index b7872f6..4ca755f 100644 --- a/drivers/crypto/marvell/cesa.h +++ b/drivers/crypto/marvell/cesa.h @@ -763,7 +763,7 @@ static inline int mv_cesa_req_needs_cleanup(struct crypto_async_request *req, * the backlog and will be processed later. There's no need to * clean it up. */ - if (ret == -EBUSY && req->flags & CRYPTO_TFM_REQ_MAY_BACKLOG) + if (ret == -EIOCBQUEUED) return false; /* Request wasn't queued, we need to clean it up */ From patchwork Sun Jul 2 14:41:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106845 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8292765obb; Sun, 2 Jul 2017 07:43:59 -0700 (PDT) X-Received: by 10.101.70.193 with SMTP id n1mr5653194pgr.249.1499006639697; Sun, 02 Jul 2017 07:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006639; cv=none; d=google.com; s=arc-20160816; b=SuLpX1frdzT3DJTgIxqZtffORoQwLA77i7TAFUjGh3jqBWuh37CbN5xBLdGIzLdnDU tKT8uOEKWwYBOP6XQEwM/dklZl1tgJqVc5o7aQzoMOqUZ4r5QvBs6IviPd1F6XD/SG5E nMuXfWCVNmArdB8tmXaF2lsft9Kyj+3eDo0wET1nyvPqgVW37efkyIli6B875UrtQXrM /1dIqfIQYQzkJbwKc4FXkd+Nj4HPFm/5Z2eexQLDe6S4Ot9YoPpaqBKtNn8Rw11keG9T /qjvsuwcFc55fBYltK6KjOWeRlV2ftXmmmBMqcI0GcFLSfRXuGt0dkGBqkwHF/5VzQYg wp6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zx0+h+IjV6gaQhmT2xYh+Lg7nXsrPccddwLSuEcrenY=; b=xkbZJfFzvMNmzPfIR1ZkYhynVQgyi2+FMmwsp+DMfqs2GeeD5MSzgCGqO91xhaAQRa 5TEDeMaJLi0dy9sfu+rHIEQqJUWrlLm6vJCgyCCIOowu/Z/hrsh3HeQFVeGJpX/eEUH1 JngkRy+7wzuuzg8bDeOJtdS8H2Lej46F8TkWzWFPnWPL8fTT5n2Qsk1oe3yizL7iNb8u 3PHF19W+SyX+f2IgsXT4wDarmcevZUu8ApfMNW9mxDkhTkVvwiohwTNGuj1FgPe4j4rr h3HfH7r6zK+hinMBc9kGkO2WJbZ2SM7DikcPIXIJV6FTgkV9V7TF0bdsKywOK0IGKrNs nvPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 g16si10183773pfe.261.2017.07.02.07.43.59; Sun, 02 Jul 2017 07:43:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752374AbdGBOnv (ORCPT + 25 others); Sun, 2 Jul 2017 10:43:51 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53646 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752315AbdGBOnp (ORCPT ); Sun, 2 Jul 2017 10:43:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D14BD15B2; Sun, 2 Jul 2017 07:43:34 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 03BB93F578; Sun, 2 Jul 2017 07:43:26 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 05/28] crypto: mediatek: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:47 +0300 Message-Id: <1499006535-19760-6-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. drivers/crypto/mediatek/mtk-aes.c | 2 +- drivers/crypto/mediatek/mtk-sha.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.1.4 diff --git a/drivers/crypto/mediatek/mtk-aes.c b/drivers/crypto/mediatek/mtk-aes.c index 9e845e8..5254e13 100644 --- a/drivers/crypto/mediatek/mtk-aes.c +++ b/drivers/crypto/mediatek/mtk-aes.c @@ -1012,7 +1012,7 @@ static int mtk_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key, AES_BLOCK_SIZE, data->iv); err = crypto_skcipher_encrypt(&data->req); - if (err == -EINPROGRESS || err == -EBUSY) { + if (err == -EINPROGRESS || err == -EIOCBQUEUED) { err = wait_for_completion_interruptible( &data->result.completion); if (!err) diff --git a/drivers/crypto/mediatek/mtk-sha.c b/drivers/crypto/mediatek/mtk-sha.c index 5f4f845..5c75b50 100644 --- a/drivers/crypto/mediatek/mtk-sha.c +++ b/drivers/crypto/mediatek/mtk-sha.c @@ -782,7 +782,7 @@ static int mtk_sha_finup(struct ahash_request *req) ctx->flags |= SHA_FLAGS_FINUP; err1 = mtk_sha_update(req); - if (err1 == -EINPROGRESS || err1 == -EBUSY) + if (err1 == -EINPROGRESS || err1 == -EIOCBQUEUED) return err1; /* * final() has to be always called to cleanup resources From patchwork Sun Jul 2 14:41:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106851 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8293988obb; Sun, 2 Jul 2017 07:45:38 -0700 (PDT) X-Received: by 10.99.105.4 with SMTP id e4mr2968359pgc.228.1499006738528; Sun, 02 Jul 2017 07:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006738; cv=none; d=google.com; s=arc-20160816; b=r9vYDpHyFnucPgrFeyk8jD/NLxuEVksMgQAWa3sd4pXA1f9IdSPowsDAJzRsuVjFLx WAZohDetnXo4bV9bKF5JR0fqhFr+4qNSL22LRlLrwSVETfCITcsnJmG3QxKc4TSXZtOh Wj3ub5b/e3C4mUpUZW6KU2K8Ak8x84MguTSzlyUSoThuWfuHSk9S8Vi0dfH8ANAvyAwH Uz326RaCOjWBOwsZzY3icq3lK09ROCSWDdwxKNHddCiw24k4ddShCn7N/DVF8lIh8iZT gow9EAU918m0muTbV1q9Xge7AdMA6FBWg5LiJ4iySI/jtpFUwLZdTzhYUCwfeBIowlJd /GqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=5AjSNo7G+HzzsL4bRpWipuijDqW6otC5kx0HyxzRhtw=; b=yaGwBzJuQOKvZurjffzbuNNdEf13tfvCV2RtMh0pre1ked8W4pZ1GhOmZPSWBnwhIw qnb0ixlv8B9imvt7G5CVp5x0OAc6iRswrzbgq9LdvU7P3jEQfm+iSDVsoIeJ0isMB6UL dioU6hlq/5sOyjvp3SYxAuPRnMiqrlaPtHqmEkA7defhwFh6cN9btaPqHnmaRkFMbXPh h9rYFHy8nlAk3osoXEPy57zppux4hBpiiFt4co+knHsRPOZIimmWND+eacAHFD6OgbmA +jRDh8GBNWUbytfijzrs67o/jCJeDcD6vSlKiFX6aZRt85+GNmrrbgbag+Vje9QQpLdy BZTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 p22si11118323pli.557.2017.07.02.07.45.38; Sun, 02 Jul 2017 07:45:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752589AbdGBOpH (ORCPT + 25 others); Sun, 2 Jul 2017 10:45:07 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53912 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbdGBOo4 (ORCPT ); Sun, 2 Jul 2017 10:44:56 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D3697344; Sun, 2 Jul 2017 07:44:40 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 06C713F578; Sun, 2 Jul 2017 07:44:32 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 10/28] fscrypt: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:52 +0300 Message-Id: <1499006535-19760-11-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. fs/crypto/crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.1.4 diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index c7835df..c5c89ed 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -190,7 +190,7 @@ int fscrypt_do_page_crypto(const struct inode *inode, fscrypt_direction_t rw, res = crypto_skcipher_decrypt(req); else res = crypto_skcipher_encrypt(req); - if (res == -EINPROGRESS || res == -EBUSY) { + if (res == -EINPROGRESS || res == -EIOCBQUEUED) { BUG_ON(req->base.data != &ecr); wait_for_completion(&ecr.completion); res = ecr.res; From patchwork Sun Jul 2 14:41:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106855 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8294421obb; Sun, 2 Jul 2017 07:46:10 -0700 (PDT) X-Received: by 10.99.97.12 with SMTP id v12mr5547683pgb.117.1499006770508; Sun, 02 Jul 2017 07:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006770; cv=none; d=google.com; s=arc-20160816; b=t1TBTCYe/V9fbhy4MxV/MUzEXl3W/pxM8DJ6FuisuSvXThSF0TssOPIiyWdWIPrvhf tFkFMZFDRGIV8nVWhmwft2MWNZaGxgikhaGvyadHuyx60B8VmO458o9GXRCVTFy/LTMW SGO24+Qkfd8zLgUlD4Sr3DzQaXLAa8KyvRwo/ErzQL/a2RahWTBfe/p+X0v/i4CeqNDG 6Tf8J4sslkkFE6EJoOlWpmlgVm71eM3xLxLbId/cV2WEaCs+n3S0YGcPV/4N3cTfLDpv 1BvnkYQx/kf66kws5E+P0TLEz7Y5NvMtCHBMCIp4zFr7XpkepyfncbZeeYHHvQTF65LZ aGGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=t63/z2yOUzX+kDtjXhkZlir1BhT9Ka6QJpQn01CdEv8=; b=IXmHFemSakNmbo5xiFPtF5iXDQ8UXhpFb5sWomAtSiNSJe314IC6gwnR6jR2vVd1ak srMFR3kHVAPb/xTWu0HPXK9ZFzN+pIQa3+02arZPd/VEN6IAlScXOEBOEPpjGT4gOrF8 /kvPYk6+GLxVOkqxw9PxPvIIBU7Tnv2ZUCAxFU7GjGdxf6dRje673enQrh/jjIS+8Kz5 VXW5GMnEJM7BGDH722CiFqj7vnr+T0k3hgBp/ScRiTNfBRurNgEVg6pA5xSTU+EcML6L xZOZcBYGB8IK/ALZMbLrCAzCK+lW8tn718doWvFwsD8w53mV0QO9AdOPAc648atMXif1 4wpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 r14si10162713pgf.6.2017.07.02.07.46.10; Sun, 02 Jul 2017 07:46:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbdGBOpx (ORCPT + 25 others); Sun, 2 Jul 2017 10:45:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54180 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752638AbdGBOpr (ORCPT ); Sun, 2 Jul 2017 10:45:47 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A07B715B2; Sun, 2 Jul 2017 07:45:46 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C569E3F578; Sun, 2 Jul 2017 07:45:38 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 15/28] crypto: move algif to generic async completion Date: Sun, 2 Jul 2017 17:41:57 +0300 Message-Id: <1499006535-19760-16-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org algif starts several async crypto ops and waits for their completion. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- crypto/af_alg.c | 27 --------------------------- crypto/algif_aead.c | 14 +++++++------- crypto/algif_hash.c | 29 +++++++++++++---------------- crypto/algif_skcipher.c | 15 +++++++-------- include/crypto/if_alg.h | 14 -------------- 5 files changed, 27 insertions(+), 72 deletions(-) -- 2.1.4 diff --git a/crypto/af_alg.c b/crypto/af_alg.c index c67daba..bf4acaf 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -480,33 +480,6 @@ int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con) } EXPORT_SYMBOL_GPL(af_alg_cmsg_send); -int af_alg_wait_for_completion(int err, struct af_alg_completion *completion) -{ - switch (err) { - case -EINPROGRESS: - case -EIOCBQUEUED: - wait_for_completion(&completion->completion); - reinit_completion(&completion->completion); - err = completion->err; - break; - }; - - return err; -} -EXPORT_SYMBOL_GPL(af_alg_wait_for_completion); - -void af_alg_complete(struct crypto_async_request *req, int err) -{ - struct af_alg_completion *completion = req->data; - - if (err == -EINPROGRESS) - return; - - completion->err = err; - complete(&completion->completion); -} -EXPORT_SYMBOL_GPL(af_alg_complete); - static int __init af_alg_init(void) { int err = proto_register(&alg_proto, 0); diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c index 8af664f..4881cb1 100644 --- a/crypto/algif_aead.c +++ b/crypto/algif_aead.c @@ -57,7 +57,7 @@ struct aead_ctx { void *iv; - struct af_alg_completion completion; + struct crypto_wait wait; unsigned long used; @@ -648,10 +648,10 @@ static int aead_recvmsg_sync(struct socket *sock, struct msghdr *msg, int flags) used, ctx->iv); aead_request_set_ad(&ctx->aead_req, ctx->aead_assoclen); - err = af_alg_wait_for_completion(ctx->enc ? - crypto_aead_encrypt(&ctx->aead_req) : - crypto_aead_decrypt(&ctx->aead_req), - &ctx->completion); + err = crypto_wait_req(ctx->enc ? + crypto_aead_encrypt(&ctx->aead_req) : + crypto_aead_decrypt(&ctx->aead_req), + &ctx->wait); if (err) { /* EBADMSG implies a valid cipher operation took place */ @@ -912,7 +912,7 @@ static int aead_accept_parent_nokey(void *private, struct sock *sk) ctx->enc = 0; ctx->tsgl.cur = 0; ctx->aead_assoclen = 0; - af_alg_init_completion(&ctx->completion); + crypto_init_wait(&ctx->wait); sg_init_table(ctx->tsgl.sg, ALG_MAX_PAGES); INIT_LIST_HEAD(&ctx->list); @@ -920,7 +920,7 @@ static int aead_accept_parent_nokey(void *private, struct sock *sk) aead_request_set_tfm(&ctx->aead_req, aead); aead_request_set_callback(&ctx->aead_req, CRYPTO_TFM_REQ_MAY_BACKLOG, - af_alg_complete, &ctx->completion); + crypto_req_done, &ctx->wait); sk->sk_destruct = aead_sock_destruct; diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index 5e92bd2..6a6739a 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c @@ -26,7 +26,7 @@ struct hash_ctx { u8 *result; - struct af_alg_completion completion; + struct crypto_wait wait; unsigned int len; bool more; @@ -88,8 +88,7 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg, if ((msg->msg_flags & MSG_MORE)) hash_free_result(sk, ctx); - err = af_alg_wait_for_completion(crypto_ahash_init(&ctx->req), - &ctx->completion); + err = crypto_wait_req(crypto_ahash_init(&ctx->req), &ctx->wait); if (err) goto unlock; } @@ -110,8 +109,8 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg, ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, NULL, len); - err = af_alg_wait_for_completion(crypto_ahash_update(&ctx->req), - &ctx->completion); + err = crypto_wait_req(crypto_ahash_update(&ctx->req), + &ctx->wait); af_alg_free_sg(&ctx->sgl); if (err) goto unlock; @@ -129,8 +128,8 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg, goto unlock; ahash_request_set_crypt(&ctx->req, NULL, ctx->result, 0); - err = af_alg_wait_for_completion(crypto_ahash_final(&ctx->req), - &ctx->completion); + err = crypto_wait_req(crypto_ahash_final(&ctx->req), + &ctx->wait); } unlock: @@ -171,7 +170,7 @@ static ssize_t hash_sendpage(struct socket *sock, struct page *page, } else { if (!ctx->more) { err = crypto_ahash_init(&ctx->req); - err = af_alg_wait_for_completion(err, &ctx->completion); + err = crypto_wait_req(err, &ctx->wait); if (err) goto unlock; } @@ -179,7 +178,7 @@ static ssize_t hash_sendpage(struct socket *sock, struct page *page, err = crypto_ahash_update(&ctx->req); } - err = af_alg_wait_for_completion(err, &ctx->completion); + err = crypto_wait_req(err, &ctx->wait); if (err) goto unlock; @@ -215,17 +214,15 @@ static int hash_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, ahash_request_set_crypt(&ctx->req, NULL, ctx->result, 0); if (!result && !ctx->more) { - err = af_alg_wait_for_completion( - crypto_ahash_init(&ctx->req), - &ctx->completion); + err = crypto_wait_req(crypto_ahash_init(&ctx->req), &ctx->wait); if (err) goto unlock; } if (!result || ctx->more) { ctx->more = 0; - err = af_alg_wait_for_completion(crypto_ahash_final(&ctx->req), - &ctx->completion); + err = crypto_wait_req(crypto_ahash_final(&ctx->req), + &ctx->wait); if (err) goto unlock; } @@ -476,13 +473,13 @@ static int hash_accept_parent_nokey(void *private, struct sock *sk) ctx->result = NULL; ctx->len = len; ctx->more = 0; - af_alg_init_completion(&ctx->completion); + crypto_init_wait(&ctx->wait); ask->private = ctx; ahash_request_set_tfm(&ctx->req, hash); ahash_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG, - af_alg_complete, &ctx->completion); + crypto_req_done, &ctx->wait); sk->sk_destruct = hash_sock_destruct; diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 43839b0..75fa9a5 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -43,7 +43,7 @@ struct skcipher_ctx { void *iv; - struct af_alg_completion completion; + struct crypto_wait wait; atomic_t inflight; size_t used; @@ -684,11 +684,10 @@ static int skcipher_recvmsg_sync(struct socket *sock, struct msghdr *msg, skcipher_request_set_crypt(&ctx->req, sg, ctx->rsgl.sg, used, ctx->iv); - err = af_alg_wait_for_completion( - ctx->enc ? - crypto_skcipher_encrypt(&ctx->req) : - crypto_skcipher_decrypt(&ctx->req), - &ctx->completion); + err = crypto_wait_req(ctx->enc ? + crypto_skcipher_encrypt(&ctx->req) : + crypto_skcipher_decrypt(&ctx->req), + &ctx->wait); free: af_alg_free_sg(&ctx->rsgl); @@ -948,14 +947,14 @@ static int skcipher_accept_parent_nokey(void *private, struct sock *sk) ctx->merge = 0; ctx->enc = 0; atomic_set(&ctx->inflight, 0); - af_alg_init_completion(&ctx->completion); + crypto_init_wait(&ctx->wait); ask->private = ctx; skcipher_request_set_tfm(&ctx->req, skcipher); skcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_SLEEP | CRYPTO_TFM_REQ_MAY_BACKLOG, - af_alg_complete, &ctx->completion); + crypto_req_done, &ctx->wait); sk->sk_destruct = skcipher_sock_destruct; diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h index e2b9c6f..86764fb 100644 --- a/include/crypto/if_alg.h +++ b/include/crypto/if_alg.h @@ -14,7 +14,6 @@ #define _CRYPTO_IF_ALG_H #include -#include #include #include #include @@ -37,11 +36,6 @@ struct alg_sock { void *private; }; -struct af_alg_completion { - struct completion completion; - int err; -}; - struct af_alg_control { struct af_alg_iv *iv; int op; @@ -81,17 +75,9 @@ void af_alg_link_sg(struct af_alg_sgl *sgl_prev, struct af_alg_sgl *sgl_new); int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con); -int af_alg_wait_for_completion(int err, struct af_alg_completion *completion); -void af_alg_complete(struct crypto_async_request *req, int err); - static inline struct alg_sock *alg_sk(struct sock *sk) { return (struct alg_sock *)sk; } -static inline void af_alg_init_completion(struct af_alg_completion *completion) -{ - init_completion(&completion->completion); -} - #endif /* _CRYPTO_IF_ALG_H */ From patchwork Sun Jul 2 14:41:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106856 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8294725obb; Sun, 2 Jul 2017 07:46:36 -0700 (PDT) X-Received: by 10.84.215.208 with SMTP id g16mr1457150plj.191.1499006796293; Sun, 02 Jul 2017 07:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006796; cv=none; d=google.com; s=arc-20160816; b=Rxcdvua29SL1NlXURndvxAuI6Oq/v7twcbln9ub9UWD4RiAfYePJ2PoE6fq3013oPB gECNSHcIjVgN9eTBVEENoTO/UuPYtrU76o8nHOMSbLKkeH26eNATOlmMz/k8boEgAZuJ BO9MCxL469Kck6P9Umnpr1p5fRLnXaNQ0/Qe/9HDMQUMto4dsNwd27txf4iib2i2rlE3 EGFWsL18Leo+54lUIwPV2aZ2UCYCWJTfcE84zXKCITgzWYjl0O6Xye2BF8ROcgYs7t/0 DUaVAHyuE6mFwF601Lb0xGOyeEFro21nokcDvI4GELsNG3tNoHU37LDrAbSIh9vv/hk8 XPhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=mBIA/+71fn4aktCad5U20n0CBbsp9uSZ0R2Oo8dtavw=; b=eJrkK5n1QW52vGdPy+dFtiAE/i7paDzho68WrqhMCVRyIgCZ0zMAVzvIPRpsGXOPg4 oLkdmcCx2MqRMXXQFO6MRn15J/8r7J5bBidi76Qr3/PjbJHH3aXTksgO0sNVgjoGS+mT 6KMDCGRBFuhMHTIBBRS7jCRsRo/fkE25CUzhOSF9ReMxLf4c2eYPb/eow5of7CXpAaX8 grPaRAFdydhGXmvidaR7OQL8zLYS0v1nrQIfIri6K+upXHc2x/WHD64Iteb3B0CJmrcw bm8j9304jrG5f2ZUbgT8Dvkpje/vJTLN30Q29EFTQZUucLmAqZPqnD66zSkxJeE/fWWw 9+RQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 y69si10330627pfb.190.2017.07.02.07.46.35; Sun, 02 Jul 2017 07:46:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752671AbdGBOqN (ORCPT + 25 others); Sun, 2 Jul 2017 10:46:13 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54244 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbdGBOqG (ORCPT ); Sun, 2 Jul 2017 10:46:06 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C625F344; Sun, 2 Jul 2017 07:46:00 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E7B793F578; Sun, 2 Jul 2017 07:45:52 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 16/28] crypto: move pub key to generic async completion Date: Sun, 2 Jul 2017 17:41:58 +0300 Message-Id: <1499006535-19760-17-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org public_key_verify_signature() is starting an async crypto op and waiting for it to complete. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- crypto/asymmetric_keys/public_key.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) -- 2.1.4 diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index 3fad1fd..d916235 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c @@ -57,29 +57,13 @@ static void public_key_destroy(void *payload0, void *payload3) public_key_signature_free(payload3); } -struct public_key_completion { - struct completion completion; - int err; -}; - -static void public_key_verify_done(struct crypto_async_request *req, int err) -{ - struct public_key_completion *compl = req->data; - - if (err == -EINPROGRESS) - return; - - compl->err = err; - complete(&compl->completion); -} - /* * Verify a signature using a public key. */ int public_key_verify_signature(const struct public_key *pkey, const struct public_key_signature *sig) { - struct public_key_completion compl; + struct crypto_wait cwait; struct crypto_akcipher *tfm; struct akcipher_request *req; struct scatterlist sig_sg, digest_sg; @@ -131,20 +115,16 @@ int public_key_verify_signature(const struct public_key *pkey, sg_init_one(&digest_sg, output, outlen); akcipher_request_set_crypt(req, &sig_sg, &digest_sg, sig->s_size, outlen); - init_completion(&compl.completion); + crypto_init_wait(&cwait); akcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - public_key_verify_done, &compl); + crypto_req_done, &cwait); /* Perform the verification calculation. This doesn't actually do the * verification, but rather calculates the hash expected by the * signature and returns that to us. */ - ret = crypto_akcipher_verify(req); - if ((ret == -EINPROGRESS) || (ret == -EIOCBQUEUED)) { - wait_for_completion(&compl.completion); - ret = compl.err; - } + ret = crypto_wait_req(crypto_akcipher_verify(req), &cwait); if (ret < 0) goto out_free_output; From patchwork Sun Jul 2 14:42:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106859 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8295170obb; Sun, 2 Jul 2017 07:47:11 -0700 (PDT) X-Received: by 10.84.128.78 with SMTP id 72mr5687547pla.161.1499006831732; Sun, 02 Jul 2017 07:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006831; cv=none; d=google.com; s=arc-20160816; b=rV1Q+FqmxRK0jpsfrgrZgb9CPk1Hz2UunP8QrKhYWGvIW0mZ33i9wiu+o931wSqZoR OK5Qa+co8IzS4sH1lHEr1rCZMPL5LG+YUX6nq+MBI5TijMeme/qyQWI5KNDzl/3SQXI1 fit/LULqjbE3xQclqxxm3UhNEkpoaB3K7FjxuAFBo3VMsdJmEv3r5eotJwENYIcz9DXW vlYMU/bGoplrpvm1yhXmv5dPac2e2/iyFdx5sZi3cjRLewNYDo0mJD19cFzcNMCLV3bU 1o9ufUQLi6XY6h4e7uC1HfuIrYcScUgUx8rni2a5gHV6YfCXs2WFHN4Bi3ZaE901sH4k nk+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=QrpJcRCU7kVgGU9cW0b5lHb0EDlvhZwItMrsJzRdsYo=; b=VK+IaE7DzlWI3vNEZM2dQb5FFML1iwjYysqRWghadZZbE6BhCeOF7HhjlEhPieO1Sb t4WU8aP2l05uDuISQ8AFD/HSJ3uevC+PmyB1HQt8q3SXigD8Du3UY6Djf3ynYFZZC/Ks 9SmjkEcbSRTGw8DWNhIK9sivGPe17Crc/JYAboJQj0tSBwZsA2ompYLTLBMkxUJRaZiX juCiBPZnc0lgarZBWsfd3JBkS5mEXWUYdzDwObPxhl2dcWfwFwQWIX56i+PT1gVRguaj n3+g7RAquiTFFsnR83axtExgFflCHy0PmdmUthpqNIgJtnEU42E8vEeCyxWVr3frWI5b HE8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 h4si11498213plk.467.2017.07.02.07.47.11; Sun, 02 Jul 2017 07:47:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752721AbdGBOrF (ORCPT + 25 others); Sun, 2 Jul 2017 10:47:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54462 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752244AbdGBOq6 (ORCPT ); Sun, 2 Jul 2017 10:46:58 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FF04344; Sun, 2 Jul 2017 07:46:53 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 47A9D3F578; Sun, 2 Jul 2017 07:46:45 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 20/28] dm: move dm-verity to generic async completion Date: Sun, 2 Jul 2017 17:42:02 +0300 Message-Id: <1499006535-19760-21-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dm-verity is starting async. crypto ops and waiting for them to complete. Move it over to generic code doing the same. This also fixes a possible data coruption bug created by the use of wait_for_completion_interruptible() without dealing correctly with an interrupt aborting the wait prior to the async op finishing. Signed-off-by: Gilad Ben-Yossef --- drivers/md/dm-verity-target.c | 81 +++++++++++-------------------------------- drivers/md/dm-verity.h | 5 --- 2 files changed, 20 insertions(+), 66 deletions(-) -- 2.1.4 diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 4fe7d18..343dd0d 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -92,74 +92,33 @@ static sector_t verity_position_at_level(struct dm_verity *v, sector_t block, return block >> (level * v->hash_per_block_bits); } -/* - * Callback function for asynchrnous crypto API completion notification - */ -static void verity_op_done(struct crypto_async_request *base, int err) -{ - struct verity_result *res = (struct verity_result *)base->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - -/* - * Wait for async crypto API callback - */ -static inline int verity_complete_op(struct verity_result *res, int ret) -{ - switch (ret) { - case 0: - break; - - case -EINPROGRESS: - case -EIOCBQUEUED: - ret = wait_for_completion_interruptible(&res->completion); - if (!ret) - ret = res->err; - reinit_completion(&res->completion); - break; - - default: - DMERR("verity_wait_hash: crypto op submission failed: %d", ret); - } - - if (unlikely(ret < 0)) - DMERR("verity_wait_hash: crypto op failed: %d", ret); - - return ret; -} - static int verity_hash_update(struct dm_verity *v, struct ahash_request *req, const u8 *data, size_t len, - struct verity_result *res) + struct crypto_wait *wait) { struct scatterlist sg; sg_init_one(&sg, data, len); ahash_request_set_crypt(req, &sg, NULL, len); - return verity_complete_op(res, crypto_ahash_update(req)); + return crypto_wait_req(crypto_ahash_update(req), wait); } /* * Wrapper for crypto_ahash_init, which handles verity salting. */ static int verity_hash_init(struct dm_verity *v, struct ahash_request *req, - struct verity_result *res) + struct crypto_wait *wait) { int r; ahash_request_set_tfm(req, v->tfm); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP | CRYPTO_TFM_REQ_MAY_BACKLOG, - verity_op_done, (void *)res); - init_completion(&res->completion); + crypto_req_done, (void *)wait); + crypto_init_wait(wait); - r = verity_complete_op(res, crypto_ahash_init(req)); + r = crypto_wait_req(crypto_ahash_init(req), wait); if (unlikely(r < 0)) { DMERR("crypto_ahash_init failed: %d", r); @@ -167,18 +126,18 @@ static int verity_hash_init(struct dm_verity *v, struct ahash_request *req, } if (likely(v->salt_size && (v->version >= 1))) - r = verity_hash_update(v, req, v->salt, v->salt_size, res); + r = verity_hash_update(v, req, v->salt, v->salt_size, wait); return r; } static int verity_hash_final(struct dm_verity *v, struct ahash_request *req, - u8 *digest, struct verity_result *res) + u8 *digest, struct crypto_wait *wait) { int r; if (unlikely(v->salt_size && (!v->version))) { - r = verity_hash_update(v, req, v->salt, v->salt_size, res); + r = verity_hash_update(v, req, v->salt, v->salt_size, wait); if (r < 0) { DMERR("verity_hash_final failed updating salt: %d", r); @@ -187,7 +146,7 @@ static int verity_hash_final(struct dm_verity *v, struct ahash_request *req, } ahash_request_set_crypt(req, NULL, digest, 0); - r = verity_complete_op(res, crypto_ahash_final(req)); + r = crypto_wait_req(crypto_ahash_final(req), wait); out: return r; } @@ -196,17 +155,17 @@ int verity_hash(struct dm_verity *v, struct ahash_request *req, const u8 *data, size_t len, u8 *digest) { int r; - struct verity_result res; + struct crypto_wait wait; - r = verity_hash_init(v, req, &res); + r = verity_hash_init(v, req, &wait); if (unlikely(r < 0)) goto out; - r = verity_hash_update(v, req, data, len, &res); + r = verity_hash_update(v, req, data, len, &wait); if (unlikely(r < 0)) goto out; - r = verity_hash_final(v, req, digest, &res); + r = verity_hash_final(v, req, digest, &wait); out: return r; @@ -389,7 +348,7 @@ int verity_hash_for_block(struct dm_verity *v, struct dm_verity_io *io, * Calculates the digest for the given bio */ int verity_for_io_block(struct dm_verity *v, struct dm_verity_io *io, - struct bvec_iter *iter, struct verity_result *res) + struct bvec_iter *iter, struct crypto_wait *wait) { unsigned int todo = 1 << v->data_dev_block_bits; struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size); @@ -414,7 +373,7 @@ int verity_for_io_block(struct dm_verity *v, struct dm_verity_io *io, */ sg_set_page(&sg, bv.bv_page, len, bv.bv_offset); ahash_request_set_crypt(req, &sg, NULL, len); - r = verity_complete_op(res, crypto_ahash_update(req)); + r = crypto_wait_req(crypto_ahash_update(req), wait); if (unlikely(r < 0)) { DMERR("verity_for_io_block crypto op failed: %d", r); @@ -482,7 +441,7 @@ static int verity_verify_io(struct dm_verity_io *io) struct dm_verity *v = io->v; struct bvec_iter start; unsigned b; - struct verity_result res; + struct crypto_wait wait; for (b = 0; b < io->n_blocks; b++) { int r; @@ -507,17 +466,17 @@ static int verity_verify_io(struct dm_verity_io *io) continue; } - r = verity_hash_init(v, req, &res); + r = verity_hash_init(v, req, &wait); if (unlikely(r < 0)) return r; start = io->iter; - r = verity_for_io_block(v, io, &io->iter, &res); + r = verity_for_io_block(v, io, &io->iter, &wait); if (unlikely(r < 0)) return r; r = verity_hash_final(v, req, verity_io_real_digest(v, io), - &res); + &wait); if (unlikely(r < 0)) return r; diff --git a/drivers/md/dm-verity.h b/drivers/md/dm-verity.h index a59e0ad..b675bc0 100644 --- a/drivers/md/dm-verity.h +++ b/drivers/md/dm-verity.h @@ -90,11 +90,6 @@ struct dm_verity_io { */ }; -struct verity_result { - struct completion completion; - int err; -}; - static inline struct ahash_request *verity_io_hash_req(struct dm_verity *v, struct dm_verity_io *io) { From patchwork Sun Jul 2 14:42:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106862 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8295751obb; Sun, 2 Jul 2017 07:47:56 -0700 (PDT) X-Received: by 10.99.117.11 with SMTP id q11mr5583911pgc.179.1499006876339; Sun, 02 Jul 2017 07:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006876; cv=none; d=google.com; s=arc-20160816; b=LdEHjO6ice95XSDvSc4DpXG7R/LOeH+AY1P/MVFw6MeMEAjLLOJBkh/2SvwSaf/2au hirEve1I0OXNinEbtRHXZSzsFElkzrTCvoqoWmjfBDVnzzoDn7yqYyIf7eJI7vU5hjDT eYtxTy5cw1VDTWVA+TB6yXZ07rn4S9xFC1TimlNJQIps6+uJFuJ4ge11iwP0ab+m3tu5 Dd6ycZjgiwarMRRxN2MFmaB4yQ6LXp3n7eVMVybpD29DUsLJTQOgpoRQ76Z8xT2Rodpm rRYeU7gY47oibKrBzcdLk02CXwHecjKMlx1bGP1Slcz9RafM9ej9LDePjjOT/Fyhfrt0 9wxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7Axnko0zeDM/s4LhnCxj0zsIJC74fPAKG/K+lZHijaw=; b=UVaNfFjzqNRzk7IShgBNy6Y6I0fN17D0+80l+nbfOJon1L5qHkaonm6r0he9TvvkZw 6vaSp7idXJ97iOrGSXlneyb26kKG8eXXParu/pQ0ZzqrckSGFcowjTQ06uzTHERbPW40 qHMLmXaAKxBPFs1O5As4+p0wxs/oqlBgngg4SmVuoNunxep1WiEf3bKIixFWHecB2mNH Xdhjnia2/WezNiZ5YF+6AY10UgICWAUbc/2L/Y3YahP1zdWC3AHgQU469qzMKwthDHV+ Zeco7WheyVYtmEPOSGYWLipYdwXw06PEczVytjrH43rFfGqMtPlswF/rBnAuFauVuf2G jlQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 p27si11437777pli.523.2017.07.02.07.47.56; Sun, 02 Jul 2017 07:47:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752747AbdGBOrv (ORCPT + 25 others); Sun, 2 Jul 2017 10:47:51 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54612 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbdGBOrp (ORCPT ); Sun, 2 Jul 2017 10:47:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 690DB1610; Sun, 2 Jul 2017 07:47:34 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 952D43F578; Sun, 2 Jul 2017 07:47:26 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 23/28] ima: move to generic async completion Date: Sun, 2 Jul 2017 17:42:05 +0300 Message-Id: <1499006535-19760-24-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ima starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef Acked-by: Mimi Zohar --- security/integrity/ima/ima_crypto.c | 56 +++++++++++-------------------------- 1 file changed, 17 insertions(+), 39 deletions(-) -- 2.1.4 diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c index 226dd88..0e4db1fe 100644 --- a/security/integrity/ima/ima_crypto.c +++ b/security/integrity/ima/ima_crypto.c @@ -27,11 +27,6 @@ #include "ima.h" -struct ahash_completion { - struct completion completion; - int err; -}; - /* minimum file size for ahash use */ static unsigned long ima_ahash_minsize; module_param_named(ahash_minsize, ima_ahash_minsize, ulong, 0644); @@ -196,30 +191,13 @@ static void ima_free_atfm(struct crypto_ahash *tfm) crypto_free_ahash(tfm); } -static void ahash_complete(struct crypto_async_request *req, int err) +static inline int ahash_wait(int err, struct crypto_wait *wait) { - struct ahash_completion *res = req->data; - if (err == -EINPROGRESS) - return; - res->err = err; - complete(&res->completion); -} + err = crypto_wait_req(err, wait); -static int ahash_wait(int err, struct ahash_completion *res) -{ - switch (err) { - case 0: - break; - case -EINPROGRESS: - case -EIOCBQUEUED: - wait_for_completion(&res->completion); - reinit_completion(&res->completion); - err = res->err; - /* fall through */ - default: + if (err) pr_crit_ratelimited("ahash calculation failed: err: %d\n", err); - } return err; } @@ -233,7 +211,7 @@ static int ima_calc_file_hash_atfm(struct file *file, int rc, read = 0, rbuf_len, active = 0, ahash_rc = 0; struct ahash_request *req; struct scatterlist sg[1]; - struct ahash_completion res; + struct crypto_wait wait; size_t rbuf_size[2]; hash->length = crypto_ahash_digestsize(tfm); @@ -242,12 +220,12 @@ static int ima_calc_file_hash_atfm(struct file *file, if (!req) return -ENOMEM; - init_completion(&res.completion); + crypto_init_wait(&wait); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - ahash_complete, &res); + crypto_req_done, &wait); - rc = ahash_wait(crypto_ahash_init(req), &res); + rc = ahash_wait(crypto_ahash_init(req), &wait); if (rc) goto out1; @@ -288,7 +266,7 @@ static int ima_calc_file_hash_atfm(struct file *file, * read/request, wait for the completion of the * previous ahash_update() request. */ - rc = ahash_wait(ahash_rc, &res); + rc = ahash_wait(ahash_rc, &wait); if (rc) goto out3; } @@ -304,7 +282,7 @@ static int ima_calc_file_hash_atfm(struct file *file, * read/request, wait for the completion of the * previous ahash_update() request. */ - rc = ahash_wait(ahash_rc, &res); + rc = ahash_wait(ahash_rc, &wait); if (rc) goto out3; } @@ -318,7 +296,7 @@ static int ima_calc_file_hash_atfm(struct file *file, active = !active; /* swap buffers, if we use two */ } /* wait for the last update request to complete */ - rc = ahash_wait(ahash_rc, &res); + rc = ahash_wait(ahash_rc, &wait); out3: if (read) file->f_mode &= ~FMODE_READ; @@ -327,7 +305,7 @@ static int ima_calc_file_hash_atfm(struct file *file, out2: if (!rc) { ahash_request_set_crypt(req, NULL, hash->digest, 0); - rc = ahash_wait(crypto_ahash_final(req), &res); + rc = ahash_wait(crypto_ahash_final(req), &wait); } out1: ahash_request_free(req); @@ -527,7 +505,7 @@ static int calc_buffer_ahash_atfm(const void *buf, loff_t len, { struct ahash_request *req; struct scatterlist sg; - struct ahash_completion res; + struct crypto_wait wait; int rc, ahash_rc = 0; hash->length = crypto_ahash_digestsize(tfm); @@ -536,12 +514,12 @@ static int calc_buffer_ahash_atfm(const void *buf, loff_t len, if (!req) return -ENOMEM; - init_completion(&res.completion); + crypto_init_wait(&wait); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - ahash_complete, &res); + crypto_req_done, &wait); - rc = ahash_wait(crypto_ahash_init(req), &res); + rc = ahash_wait(crypto_ahash_init(req), &wait); if (rc) goto out; @@ -551,10 +529,10 @@ static int calc_buffer_ahash_atfm(const void *buf, loff_t len, ahash_rc = crypto_ahash_update(req); /* wait for the update request to complete */ - rc = ahash_wait(ahash_rc, &res); + rc = ahash_wait(ahash_rc, &wait); if (!rc) { ahash_request_set_crypt(req, NULL, hash->digest, 0); - rc = ahash_wait(crypto_ahash_final(req), &res); + rc = ahash_wait(crypto_ahash_final(req), &wait); } out: ahash_request_free(req); From patchwork Sun Jul 2 14:42:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106866 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8296509obb; Sun, 2 Jul 2017 07:48:55 -0700 (PDT) X-Received: by 10.99.174.67 with SMTP id e3mr5532892pgp.75.1499006935139; Sun, 02 Jul 2017 07:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006935; cv=none; d=google.com; s=arc-20160816; b=qtbH0E5xgIMxUXj+VvQVfxw5ukEavEkbmJHpyTL2j9xDo1rskpZ1vL9e0AO/foz40F vmWR/GdoroBJmmPii1cRvmiKnrODYUMKjaZb4yTd9ueIc4FxGIRFDgelJovlqsXZ6M1S TWU1iYQqlXbfayuX34f9XFomJV41wrr83KZCebvTO8NYc7OK9njo9uiL8BlRu7uVy4/x etv/dG6SPA1VcaBJyXHIB2UIzdaOrDsctu3/348KwJoq4qQyjMGqoqlkayeLC3uYfhTI 59fYQeGFTJFaF1fAvSEXziagYWaWk79KkevPgXnfAQenmPenusGrTnBHlb2zUCaHS8X+ 8C/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=DPOda9RCrxfUcw5P0IA/S3e3ITN7KUcA7SyMFQ1wedg=; b=PSGARNlwn9BPj/ri3yyP2LESWPMyIwZgtZdROWAGTDt+SVwIOF23GbUBR9uuxv3n2/ 0VyyUI7UWuAG4Ra5uUXtFjXGowKldPPCUvhL1qXzubgQISD7PYuOzK62wn9A9C7Xk0oz 9U1DqTTlM274x1aEOackKuqEYy14qa19iOzl/UZd1OVQRbdqoP6RtPUJUmU5pth8eq6X XujaDxZDpHmmWeTJJhRMsaV2TMkQJFlHy1Ps2uqXCejsjWgQCIf6Gu//LJ08jTgPWfh+ h0rRcrpVo1Fgr+Mih8RZCFVmA3H5UBTlz6i9E+1n2vtJQghsTG8Unh1kilJVfzolH6Ip ytQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 p3si10208060pfg.45.2017.07.02.07.48.54; Sun, 02 Jul 2017 07:48:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752456AbdGBOss (ORCPT + 25 others); Sun, 2 Jul 2017 10:48:48 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54836 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751635AbdGBOsl (ORCPT ); Sun, 2 Jul 2017 10:48:41 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EF12C344; Sun, 2 Jul 2017 07:48:30 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1F4AF3F578; Sun, 2 Jul 2017 07:48:22 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 27/28] crypto: mediatek: move to generic async completion Date: Sun, 2 Jul 2017 17:42:09 +0300 Message-Id: <1499006535-19760-28-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mediatek driver starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/mediatek/mtk-aes.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) -- 2.1.4 diff --git a/drivers/crypto/mediatek/mtk-aes.c b/drivers/crypto/mediatek/mtk-aes.c index 5254e13..e2c7c95 100644 --- a/drivers/crypto/mediatek/mtk-aes.c +++ b/drivers/crypto/mediatek/mtk-aes.c @@ -137,11 +137,6 @@ struct mtk_aes_gcm_ctx { struct crypto_skcipher *ctr; }; -struct mtk_aes_gcm_setkey_result { - int err; - struct completion completion; -}; - struct mtk_aes_drv { struct list_head dev_list; /* Device list lock */ @@ -936,17 +931,6 @@ static int mtk_aes_gcm_crypt(struct aead_request *req, u64 mode) &req->base); } -static void mtk_gcm_setkey_done(struct crypto_async_request *req, int err) -{ - struct mtk_aes_gcm_setkey_result *result = req->data; - - if (err == -EINPROGRESS) - return; - - result->err = err; - complete(&result->completion); -} - /* * Because of the hardware limitation, we need to pre-calculate key(H) * for the GHASH operation. The result of the encryption operation @@ -962,7 +946,7 @@ static int mtk_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key, u32 hash[4]; u8 iv[8]; - struct mtk_aes_gcm_setkey_result result; + struct crypto_wait wait; struct scatterlist sg[1]; struct skcipher_request req; @@ -1002,22 +986,17 @@ static int mtk_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key, if (!data) return -ENOMEM; - init_completion(&data->result.completion); + crypto_init_wait(&data->wait); sg_init_one(data->sg, &data->hash, AES_BLOCK_SIZE); skcipher_request_set_tfm(&data->req, ctr); skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP | CRYPTO_TFM_REQ_MAY_BACKLOG, - mtk_gcm_setkey_done, &data->result); + crypto_req_done, &data->wait); skcipher_request_set_crypt(&data->req, data->sg, data->sg, AES_BLOCK_SIZE, data->iv); - err = crypto_skcipher_encrypt(&data->req); - if (err == -EINPROGRESS || err == -EIOCBQUEUED) { - err = wait_for_completion_interruptible( - &data->result.completion); - if (!err) - err = data->result.err; - } + err = crypto_wait_req(crypto_skcipher_encrypt(&data->req), + &data->wait); if (err) goto out;