From patchwork Wed Jul 5 16:40:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cabiddu, Giovanni" X-Patchwork-Id: 13306313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 006B7EB64DA for ; Mon, 10 Jul 2023 06:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688971638; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=SfdTdaWG9kLVnEZtQ9v/EKS61z36tgxAysGiFg1pv7o=; b=HHE+I5kfIEjobN9YW9iXBTqZYEPA+VOUCvTD+MCNApyflcejJS3Cu6ZfEKoa6RSvRJ4h2d LKKq0tTRGaQPJrYkb8CrWSYkT0ivH59wxeYc4dGHLV8qmKpa8xVdgwMv3cT34dPBZxEqQl zqjVJS8Ny62LrUoyIIarwVp/oBbVZaw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-456-IS3NzkICP1SVyNnje0yVeA-1; Mon, 10 Jul 2023 02:47:15 -0400 X-MC-Unique: IS3NzkICP1SVyNnje0yVeA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 107C03815F77; Mon, 10 Jul 2023 06:47:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDAD44087C79; Mon, 10 Jul 2023 06:47:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8DF3F19451EC; Mon, 10 Jul 2023 06:46:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 480C31946588 for ; Wed, 5 Jul 2023 16:41:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2BC811121315; Wed, 5 Jul 2023 16:41:39 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2465D1121314 for ; Wed, 5 Jul 2023 16:41:39 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0569038294A8 for ; Wed, 5 Jul 2023 16:41:39 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-EwBjSpWrMZyBY0VxxNJ60g-1; Wed, 05 Jul 2023 12:41:37 -0400 X-MC-Unique: EwBjSpWrMZyBY0VxxNJ60g-1 X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="362258257" X-IronPort-AV: E=Sophos;i="6.01,183,1684825200"; d="scan'208";a="362258257" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2023 09:40:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="893241761" X-IronPort-AV: E=Sophos;i="6.01,183,1684825200"; d="scan'208";a="893241761" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314.ger.corp.intel.com) ([10.237.222.216]) by orsmga005.jf.intel.com with ESMTP; 05 Jul 2023 09:40:28 -0700 From: Giovanni Cabiddu To: herbert@gondor.apana.org.au, agk@redhat.com, snitzer@kernel.org Date: Wed, 5 Jul 2023 17:40:07 +0100 Message-Id: <20230705164009.58351-2-giovanni.cabiddu@intel.com> In-Reply-To: <20230705164009.58351-1-giovanni.cabiddu@intel.com> References: <20230705164009.58351-1-giovanni.cabiddu@intel.com> MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mailman-Approved-At: Mon, 10 Jul 2023 06:46:55 +0000 Subject: [dm-devel] [PATCH 1/3] dm integrity: do not filter algos with CRYPTO_ALG_ALLOCATES_MEMORY X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Giovanni Cabiddu , Fiona Trahe , horia.geanta@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com, heinzm@redhat.com, qat-linux@intel.com, linux-kernel@vger.kernel.org, ebiggers@kernel.org, iuliana.prodan@nxp.com, dm-devel@redhat.com, meenakshi.aggarwal@nxp.com, linux-crypto@vger.kernel.org, davem@davemloft.net, V.Sethi@nxp.com Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: intel.com The flag CRYPTO_ALG_ALLOCATES_MEMORY indicates that an algorithm might allocate memory in the datapath and therefore sleep. Dm-integrity is filtering out implementations of skcipher algorithms that have this flag set. However, in the same function it does allocations with GFP_KERNEL. As dm-integrity is re-entrant and capable of handling sleeps that could occur during allocations with GFP_KERNEL, then it is also capable of using skcipher algorithm implementations that have CRYPTO_ALG_ALLOCATES_MEMORY set. Remove the filtering of skcipher implementations with the flag CRYPTO_ALG_ALLOCATES_MEMORY set. Suggested-by: Herbert Xu Link: https://lore.kernel.org/linux-crypto/ZILvtASXQKLG43y9@gondor.apana.org.au/ Signed-off-by: Giovanni Cabiddu Reviewed-by: Fiona Trahe --- drivers/md/dm-integrity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 31838b13ea54..a1013eff01b4 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -3785,7 +3785,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error) struct journal_completion comp; comp.ic = ic; - ic->journal_crypt = crypto_alloc_skcipher(ic->journal_crypt_alg.alg_string, 0, CRYPTO_ALG_ALLOCATES_MEMORY); + ic->journal_crypt = crypto_alloc_skcipher(ic->journal_crypt_alg.alg_string, 0, 0); if (IS_ERR(ic->journal_crypt)) { *error = "Invalid journal cipher"; r = PTR_ERR(ic->journal_crypt); From patchwork Wed Jul 5 16:40:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cabiddu, Giovanni" X-Patchwork-Id: 13306314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17B42EB64D9 for ; Mon, 10 Jul 2023 06:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688971682; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wetnkyCxhusiEbrqDQEXP+mNR/xuEOxVAKft4uS51JA=; b=eMXv048BiJuUdED8gzZ9sIRNh5jm9w37gLN103EjdCEop74P95/wFrQqT5BlU9TV2nsdjm L1KQvwqkjxAD8FBjaraZOLGJwjo9B47H5r8P+ylvqjgH2kQnqo4VZl9fA8PgmPmV4sqL+J OfPfLcFMTACY1iYcqArBf/9gNI1RlQQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-39-ONvuKrfRPuOspR0b1Ayfiw-1; Mon, 10 Jul 2023 02:47:10 -0400 X-MC-Unique: ONvuKrfRPuOspR0b1Ayfiw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F27B87323F; Mon, 10 Jul 2023 06:46:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78F0D4CD0D5; Mon, 10 Jul 2023 06:46:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 564AF1949749; Mon, 10 Jul 2023 06:46:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 71F3B1946588 for ; Wed, 5 Jul 2023 16:41:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 52F004CD0C8; Wed, 5 Jul 2023 16:41:41 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B3FD492C13 for ; Wed, 5 Jul 2023 16:41:41 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D64F88D542 for ; Wed, 5 Jul 2023 16:41:41 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-359-ROTbjrT3OYqzxlNIcUOWpg-1; Wed, 05 Jul 2023 12:41:39 -0400 X-MC-Unique: ROTbjrT3OYqzxlNIcUOWpg-1 X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="362258285" X-IronPort-AV: E=Sophos;i="6.01,183,1684825200"; d="scan'208";a="362258285" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2023 09:40:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="893241766" X-IronPort-AV: E=Sophos;i="6.01,183,1684825200"; d="scan'208";a="893241766" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314.ger.corp.intel.com) ([10.237.222.216]) by orsmga005.jf.intel.com with ESMTP; 05 Jul 2023 09:40:32 -0700 From: Giovanni Cabiddu To: herbert@gondor.apana.org.au, agk@redhat.com, snitzer@kernel.org Date: Wed, 5 Jul 2023 17:40:08 +0100 Message-Id: <20230705164009.58351-3-giovanni.cabiddu@intel.com> In-Reply-To: <20230705164009.58351-1-giovanni.cabiddu@intel.com> References: <20230705164009.58351-1-giovanni.cabiddu@intel.com> MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mailman-Approved-At: Mon, 10 Jul 2023 06:46:55 +0000 Subject: [dm-devel] [PATCH 2/3] crypto: api - adjust meaning of CRYPTO_ALG_ALLOCATES_MEMORY X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Giovanni Cabiddu , Fiona Trahe , horia.geanta@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com, heinzm@redhat.com, Eric Biggers , qat-linux@intel.com, linux-kernel@vger.kernel.org, ebiggers@kernel.org, iuliana.prodan@nxp.com, dm-devel@redhat.com, meenakshi.aggarwal@nxp.com, linux-crypto@vger.kernel.org, davem@davemloft.net, V.Sethi@nxp.com Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: intel.com The CRYPTO_ALG_ALLOCATES_MEMORY flag doesn't allow to distinguish between implementations which don't allocate memory for scatterlists with 4 or less entries (the typical case for dm-crypt) and those that do. The flag's meaning is adjusted based on the ML discussion below. This patch removes the need to set the flag if the implementation can handle scatterlists up to 4 entries without allocating memory. The documentation is updated accordingly, with an extra clarification regarding sleeping. Suggested-by: Herbert Xu Suggested-by: Eric Biggers Link: https://lore.kernel.org/linux-crypto/20200722072932.GA27544@gondor.apana.org.au/ Link: https://lore.kernel.org/linux-crypto/20230523165503.GA864814@google.com/ Signed-off-by: Giovanni Cabiddu Reviewed-by: Fiona Trahe --- include/linux/crypto.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 31f6fee0c36c..15884790a3d0 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -87,8 +87,13 @@ /* * The algorithm may allocate memory during request processing, i.e. during - * encryption, decryption, or hashing. Users can request an algorithm with this - * flag unset if they can't handle memory allocation failures. + * encryption, decryption, or hashing. Algorithms that do not set this flag will + * guarantee that memory is not allocated during request processing, except in + * the avoidable exception cases described below. + * + * Users can request an algorithm with this flag unset if they can't handle + * memory allocation failures or sleeping during request processing. They should + * also follow the constraints below. * * This flag is currently only implemented for algorithms of type "skcipher", * "aead", "ahash", "shash", and "cipher". Algorithms of other types might not @@ -102,6 +107,9 @@ * - If the data were to be divided into chunks of size * crypto_skcipher_walksize() (with any remainder going at the end), no * chunk can cross a page boundary or a scatterlist element boundary. + * - The input and output scatterlists must have no more than 4 entries. + * If the scatterlists contain more than 4 entries, the algorithm may + * allocate memory. * aead: * - The IV buffer and all scatterlist elements must be aligned to the * algorithm's alignmask. @@ -110,10 +118,16 @@ * - If the plaintext/ciphertext were to be divided into chunks of size * crypto_aead_walksize() (with the remainder going at the end), no chunk * can cross a page boundary or a scatterlist element boundary. + * - The input and output scatterlists must have no more than 4 entries. + * If the scatterlists contain more than 4 entries, the algorithm may + * allocate memory. * ahash: * - The result buffer must be aligned to the algorithm's alignmask. * - crypto_ahash_finup() must not be used unless the algorithm implements * ->finup() natively. + * - The input and output scatterlists must have no more than 4 entries. + * If the scatterlists contain more than 4 entries, the algorithm may + * allocate memory. */ #define CRYPTO_ALG_ALLOCATES_MEMORY 0x00010000 From patchwork Wed Jul 5 16:40:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cabiddu, Giovanni" X-Patchwork-Id: 13306312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1ECBBC001DD for ; Mon, 10 Jul 2023 06:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688971637; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oa2DXqcNmu8dZeHD3BqrovzcBdsa83kza1c0ek1gQhA=; b=H6bsw2KY6etB5pXlo5Oe3pX9zOnu6X2uNLJO9BHHwF999qnm58YdPmyPgJS1T2Vbbh+7QN gv7dgT/ug8FJ0Qg0uPpwX8lYGEkyAn57Lmm2mMggtFKR/vIMirQRxoulgzjhu6tvN7ueMH LxebizO2BDxPaFzySCwuihaq36vDMpg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-350-wYsxrpkOOti0ruG0sgQtnA-1; Mon, 10 Jul 2023 02:47:12 -0400 X-MC-Unique: wYsxrpkOOti0ruG0sgQtnA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E0781C31C68; Mon, 10 Jul 2023 06:47:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F4FAC54FBC; Mon, 10 Jul 2023 06:47:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BDB14193F504; Mon, 10 Jul 2023 06:46:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8B8471946588 for ; Wed, 5 Jul 2023 16:41:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7B3BB1401C2F; Wed, 5 Jul 2023 16:41:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73B7B1401C20 for ; Wed, 5 Jul 2023 16:41:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F4A43C100AA for ; Wed, 5 Jul 2023 16:41:47 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-359-RHIWcSjaMd60B8BLa54Pdg-2; Wed, 05 Jul 2023 12:41:43 -0400 X-MC-Unique: RHIWcSjaMd60B8BLa54Pdg-2 X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="362258308" X-IronPort-AV: E=Sophos;i="6.01,183,1684825200"; d="scan'208";a="362258308" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2023 09:40:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="893241782" X-IronPort-AV: E=Sophos;i="6.01,183,1684825200"; d="scan'208";a="893241782" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314.ger.corp.intel.com) ([10.237.222.216]) by orsmga005.jf.intel.com with ESMTP; 05 Jul 2023 09:40:36 -0700 From: Giovanni Cabiddu To: herbert@gondor.apana.org.au, agk@redhat.com, snitzer@kernel.org Date: Wed, 5 Jul 2023 17:40:09 +0100 Message-Id: <20230705164009.58351-4-giovanni.cabiddu@intel.com> In-Reply-To: <20230705164009.58351-1-giovanni.cabiddu@intel.com> References: <20230705164009.58351-1-giovanni.cabiddu@intel.com> MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mailman-Approved-At: Mon, 10 Jul 2023 06:46:55 +0000 Subject: [dm-devel] [PATCH 3/3] crypto: qat - remove CRYPTO_ALG_ALLOCATES_MEMORY flag X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Giovanni Cabiddu , Fiona Trahe , horia.geanta@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com, heinzm@redhat.com, qat-linux@intel.com, linux-kernel@vger.kernel.org, ebiggers@kernel.org, iuliana.prodan@nxp.com, dm-devel@redhat.com, meenakshi.aggarwal@nxp.com, linux-crypto@vger.kernel.org, davem@davemloft.net, V.Sethi@nxp.com Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: intel.com Remove the CRYPTO_ALG_ALLOCATES_MEMORY flag from the aead, skcipher and acomp alg structures since the driver does not allocate memory in the request processing for scatterlists with 4 or less entries. This allows the QAT driver to be used by dm-crypt. Signed-off-by: Giovanni Cabiddu Reviewed-by: Fiona Trahe --- drivers/crypto/intel/qat/qat_common/qat_algs.c | 13 ++++++------- drivers/crypto/intel/qat/qat_common/qat_comp_algs.c | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/intel/qat/qat_common/qat_algs.c b/drivers/crypto/intel/qat/qat_common/qat_algs.c index 3c4bba4a8779..a7a6ac33052a 100644 --- a/drivers/crypto/intel/qat/qat_common/qat_algs.c +++ b/drivers/crypto/intel/qat/qat_common/qat_algs.c @@ -1278,7 +1278,7 @@ static struct aead_alg qat_aeads[] = { { .cra_name = "authenc(hmac(sha1),cbc(aes))", .cra_driver_name = "qat_aes_cbc_hmac_sha1", .cra_priority = 4001, - .cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, + .cra_flags = CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct qat_alg_aead_ctx), .cra_module = THIS_MODULE, @@ -1295,7 +1295,7 @@ static struct aead_alg qat_aeads[] = { { .cra_name = "authenc(hmac(sha256),cbc(aes))", .cra_driver_name = "qat_aes_cbc_hmac_sha256", .cra_priority = 4001, - .cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, + .cra_flags = CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct qat_alg_aead_ctx), .cra_module = THIS_MODULE, @@ -1312,7 +1312,7 @@ static struct aead_alg qat_aeads[] = { { .cra_name = "authenc(hmac(sha512),cbc(aes))", .cra_driver_name = "qat_aes_cbc_hmac_sha512", .cra_priority = 4001, - .cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, + .cra_flags = CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct qat_alg_aead_ctx), .cra_module = THIS_MODULE, @@ -1330,7 +1330,7 @@ static struct skcipher_alg qat_skciphers[] = { { .base.cra_name = "cbc(aes)", .base.cra_driver_name = "qat_aes_cbc", .base.cra_priority = 4001, - .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, + .base.cra_flags = CRYPTO_ALG_ASYNC, .base.cra_blocksize = AES_BLOCK_SIZE, .base.cra_ctxsize = sizeof(struct qat_alg_skcipher_ctx), .base.cra_alignmask = 0, @@ -1348,7 +1348,7 @@ static struct skcipher_alg qat_skciphers[] = { { .base.cra_name = "ctr(aes)", .base.cra_driver_name = "qat_aes_ctr", .base.cra_priority = 4001, - .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, + .base.cra_flags = CRYPTO_ALG_ASYNC, .base.cra_blocksize = 1, .base.cra_ctxsize = sizeof(struct qat_alg_skcipher_ctx), .base.cra_alignmask = 0, @@ -1366,8 +1366,7 @@ static struct skcipher_alg qat_skciphers[] = { { .base.cra_name = "xts(aes)", .base.cra_driver_name = "qat_aes_xts", .base.cra_priority = 4001, - .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK | - CRYPTO_ALG_ALLOCATES_MEMORY, + .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK, .base.cra_blocksize = AES_BLOCK_SIZE, .base.cra_ctxsize = sizeof(struct qat_alg_skcipher_ctx), .base.cra_alignmask = 0, diff --git a/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c b/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c index b533984906ec..bd1383da1c4a 100644 --- a/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c +++ b/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c @@ -442,7 +442,7 @@ static struct acomp_alg qat_acomp[] = { { .cra_name = "deflate", .cra_driver_name = "qat_deflate", .cra_priority = 4001, - .cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY, + .cra_flags = CRYPTO_ALG_ASYNC, .cra_ctxsize = sizeof(struct qat_compression_ctx), .cra_module = THIS_MODULE, },