From patchwork Tue Jul 24 14:12:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 142805 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp7324667ljj; Tue, 24 Jul 2018 07:13:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd7OCzKqm3+p66JyWiBBw1PPP0UuhT1TVQH5G2BDEnkSTiCkBCEsJA45ni+sx1tBil1aznQ X-Received: by 2002:a63:db05:: with SMTP id e5-v6mr16469227pgg.152.1532441635711; Tue, 24 Jul 2018 07:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532441635; cv=none; d=google.com; s=arc-20160816; b=d8QOwhN5ZM7OBDffVD9HaOpa3xSPS1IxBXyw35U7J0fa+9XqSLjY9lic866W3VYjAp cKY9bvaNc0M591v7qYYRPu2Y6w6G3yoQj2ZUvigX6ndhK5AAFb6S/RzbOn3JSrGfmhmf Nn7hceResnNuF6v63TSFi5PceBs9aaiNGnk4VvLAF1rEtr+/G+Eo5tdEXi3fbQifaF+J DZ7htag1giEKBn8dm7OGmgw+XAvayfnuPEY0IgdVPvztQLuJz8yV1ilSuyd/Hi48T1DI lHGu4dGRMHTop3kxHCT85qFsdJj0Xxw0VOifhy7GUPrEV8RlyQtZs3lV83YD1N3g2MNy oDLg== 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=9zqhhKAv9OSpXQCLWj+nlxuJjwK5koCskgNGCmOrLMU=; b=uL0P+kFDBFgb2totzaY6m+d4qf82s82WJkW9tLrtJzXzydyWRsKFH7vpdMIkywYPf5 QQyKnZkiRic/XT2RQNQcr6OnrcCArRlNvTdtqBLIDTy5B5TeHBhu2Fh0pgYIEnv5CEwm KcszSDY6WL2VQOCCx1Hcqk9oPJNgDW1E61GsxA0P7CvLUgQozQwf7nePq0F2uFrV/fzf xR0/pUZ5+5lcScfMZFD59qmA1Z2Jbyf8FnYaeokFOwnRLCOhaQiYLwHuiUNBTpK+Xg5F SyaIyfh6HuJNQNPORVcajOV1jhnNLfpKNZYdFS3QHkrWAKvhBGtT1NqO5+V9AtzmUzIY Tp2w== 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 r2-v6si11687135pgd.138.2018.07.24.07.13.55; Tue, 24 Jul 2018 07:13: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 S2388528AbeGXPUd (ORCPT + 31 others); Tue, 24 Jul 2018 11:20:33 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52290 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388460AbeGXPUd (ORCPT ); Tue, 24 Jul 2018 11:20:33 -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 98FE015A2; Tue, 24 Jul 2018 07:13:52 -0700 (PDT) Received: from sugar.kfn.arm.com (E110176.Emea.Arm.com [10.50.4.179]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EC94B3F237; Tue, 24 Jul 2018 07:13:50 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , Geert Uytterhoeven , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] crypto: ccree: drop useless type flag during reg Date: Tue, 24 Jul 2018 15:12:43 +0100 Message-Id: <1532441567-11694-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532441567-11694-1-git-send-email-gilad@benyossef.com> References: <1532441567-11694-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 Drop the explicit setting of CRYPTO_ALG_TYPE_AEAD or CRYPTO_ALG_TYPE_SKCIPHER flags during alg registration as they are set anyway by the framework. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_aead.c | 16 +--------------- drivers/crypto/ccree/cc_cipher.c | 14 -------------- drivers/crypto/ccree/cc_driver.h | 1 - 3 files changed, 1 insertion(+), 30 deletions(-) -- 2.7.4 diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c index 03f4b9f..01b82b8 100644 --- a/drivers/crypto/ccree/cc_aead.c +++ b/drivers/crypto/ccree/cc_aead.c @@ -2344,7 +2344,6 @@ static struct cc_alg_template aead_algs[] = { .name = "authenc(hmac(sha1),cbc(aes))", .driver_name = "authenc-hmac-sha1-cbc-aes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_aead_setauthsize, @@ -2364,7 +2363,6 @@ static struct cc_alg_template aead_algs[] = { .name = "authenc(hmac(sha1),cbc(des3_ede))", .driver_name = "authenc-hmac-sha1-cbc-des3-ccree", .blocksize = DES3_EDE_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_aead_setauthsize, @@ -2384,7 +2382,6 @@ static struct cc_alg_template aead_algs[] = { .name = "authenc(hmac(sha256),cbc(aes))", .driver_name = "authenc-hmac-sha256-cbc-aes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_aead_setauthsize, @@ -2404,7 +2401,6 @@ static struct cc_alg_template aead_algs[] = { .name = "authenc(hmac(sha256),cbc(des3_ede))", .driver_name = "authenc-hmac-sha256-cbc-des3-ccree", .blocksize = DES3_EDE_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_aead_setauthsize, @@ -2424,7 +2420,6 @@ static struct cc_alg_template aead_algs[] = { .name = "authenc(xcbc(aes),cbc(aes))", .driver_name = "authenc-xcbc-aes-cbc-aes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_aead_setauthsize, @@ -2444,7 +2439,6 @@ static struct cc_alg_template aead_algs[] = { .name = "authenc(hmac(sha1),rfc3686(ctr(aes)))", .driver_name = "authenc-hmac-sha1-rfc3686-ctr-aes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_aead_setauthsize, @@ -2464,7 +2458,6 @@ static struct cc_alg_template aead_algs[] = { .name = "authenc(hmac(sha256),rfc3686(ctr(aes)))", .driver_name = "authenc-hmac-sha256-rfc3686-ctr-aes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_aead_setauthsize, @@ -2484,7 +2477,6 @@ static struct cc_alg_template aead_algs[] = { .name = "authenc(xcbc(aes),rfc3686(ctr(aes)))", .driver_name = "authenc-xcbc-aes-rfc3686-ctr-aes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_aead_setauthsize, @@ -2504,7 +2496,6 @@ static struct cc_alg_template aead_algs[] = { .name = "ccm(aes)", .driver_name = "ccm-aes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_ccm_setauthsize, @@ -2524,7 +2515,6 @@ static struct cc_alg_template aead_algs[] = { .name = "rfc4309(ccm(aes))", .driver_name = "rfc4309-ccm-aes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_rfc4309_ccm_setkey, .setauthsize = cc_rfc4309_ccm_setauthsize, @@ -2544,7 +2534,6 @@ static struct cc_alg_template aead_algs[] = { .name = "gcm(aes)", .driver_name = "gcm-aes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_aead_setkey, .setauthsize = cc_gcm_setauthsize, @@ -2564,7 +2553,6 @@ static struct cc_alg_template aead_algs[] = { .name = "rfc4106(gcm(aes))", .driver_name = "rfc4106-gcm-aes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_rfc4106_gcm_setkey, .setauthsize = cc_rfc4106_gcm_setauthsize, @@ -2584,7 +2572,6 @@ static struct cc_alg_template aead_algs[] = { .name = "rfc4543(gcm(aes))", .driver_name = "rfc4543-gcm-aes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_AEAD, .template_aead = { .setkey = cc_rfc4543_gcm_setkey, .setauthsize = cc_rfc4543_gcm_setauthsize, @@ -2621,8 +2608,7 @@ static struct cc_crypto_alg *cc_create_aead_alg(struct cc_alg_template *tmpl, alg->base.cra_priority = CC_CRA_PRIO; alg->base.cra_ctxsize = sizeof(struct cc_aead_ctx); - alg->base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY | - tmpl->type; + alg->base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY; alg->init = cc_aead_init; alg->exit = cc_aead_exit; diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index 1100185..eb99633 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -968,7 +968,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "ecb(paes)", .driver_name = "ecb-paes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_sethkey, .encrypt = cc_cipher_encrypt, @@ -985,7 +984,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "cbc(paes)", .driver_name = "cbc-paes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_sethkey, .encrypt = cc_cipher_encrypt, @@ -1002,7 +1000,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "ofb(paes)", .driver_name = "ofb-paes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_sethkey, .encrypt = cc_cipher_encrypt, @@ -1019,7 +1016,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "cts(cbc(paes))", .driver_name = "cts-cbc-paes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_sethkey, .encrypt = cc_cipher_encrypt, @@ -1036,7 +1032,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "ctr(paes)", .driver_name = "ctr-paes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_sethkey, .encrypt = cc_cipher_encrypt, @@ -1203,7 +1198,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "ecb(aes)", .driver_name = "ecb-aes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_setkey, .encrypt = cc_cipher_encrypt, @@ -1220,7 +1214,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "cbc(aes)", .driver_name = "cbc-aes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_setkey, .encrypt = cc_cipher_encrypt, @@ -1237,7 +1230,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "ofb(aes)", .driver_name = "ofb-aes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_setkey, .encrypt = cc_cipher_encrypt, @@ -1254,7 +1246,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "cts(cbc(aes))", .driver_name = "cts-cbc-aes-ccree", .blocksize = AES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_setkey, .encrypt = cc_cipher_encrypt, @@ -1271,7 +1262,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "ctr(aes)", .driver_name = "ctr-aes-ccree", .blocksize = 1, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_setkey, .encrypt = cc_cipher_encrypt, @@ -1288,7 +1278,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "cbc(des3_ede)", .driver_name = "cbc-3des-ccree", .blocksize = DES3_EDE_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_setkey, .encrypt = cc_cipher_encrypt, @@ -1305,7 +1294,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "ecb(des3_ede)", .driver_name = "ecb-3des-ccree", .blocksize = DES3_EDE_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_setkey, .encrypt = cc_cipher_encrypt, @@ -1322,7 +1310,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "cbc(des)", .driver_name = "cbc-des-ccree", .blocksize = DES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_setkey, .encrypt = cc_cipher_encrypt, @@ -1339,7 +1326,6 @@ static const struct cc_alg_template skcipher_algs[] = { .name = "ecb(des)", .driver_name = "ecb-des-ccree", .blocksize = DES_BLOCK_SIZE, - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .template_skcipher = { .setkey = cc_cipher_setkey, .encrypt = cc_cipher_encrypt, diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h index 95f82b2..d608a4f 100644 --- a/drivers/crypto/ccree/cc_driver.h +++ b/drivers/crypto/ccree/cc_driver.h @@ -148,7 +148,6 @@ struct cc_alg_template { char name[CRYPTO_MAX_ALG_NAME]; char driver_name[CRYPTO_MAX_ALG_NAME]; unsigned int blocksize; - u32 type; union { struct skcipher_alg skcipher; struct aead_alg aead; From patchwork Tue Jul 24 14:12:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 142806 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp7324715ljj; Tue, 24 Jul 2018 07:13:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcwRK7ruLhxdrnYVekHouWeegEk9WcZTR9IEPh3gHHDhMrAW5pV11prue+slEm8l8H96DoL X-Received: by 2002:a63:4763:: with SMTP id w35-v6mr16337071pgk.140.1532441638238; Tue, 24 Jul 2018 07:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532441638; cv=none; d=google.com; s=arc-20160816; b=KMUgBpvtkB7fO7FLnv4PofV5tkUW1JfWVVM3kxI8BP91bdKyWt0Ta0Hh8RCMiDvAWe 27JSPhYc4XrZwFTlbi7m5Tz90dX1Iu2woD2qhelL+N+E1b9v9swmJ2b3rtO5FUOpOMkU csyO0CQAOHdeQz8L/abAyeRkI/ulvVsd9w2Q7z70Bz9EP90N6cJzBTJbLbxuPiidJgl1 9UDAznWbmfk6MfiW2myaPCBhWAV2y+jaybv1IpTDM399q+RGRPzGTqKi3fdZFNpsNb4S 0o3prn3PMpd7mTO/yjN91DBMoAJNzwYX6uiZW68enft20uZezS5jhBNSKubwTeNhMd6H Zn2Q== 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=raY6OBa/a9pgeLtE0oJVZ6MVfsFVhlvTt8t9TdTPeFg=; b=AHodwvOLso4HSgT6WATWT2yQtU/yV/GOdS9sURjDS2LxFp8nfQZsHOFfE31CA16zOx Ipwe6i7/XU5pSL9Qte/3pzX9eisyF56QrnjBZsvSqRwYcjWVIadmqvPGrH4el1PYQ6EL W33UN7ieCYQFjT1/QSUCGQP0fd7S88hXFv93L4xfRdFgx4t03/po4jOJVuw7sYttvEvg KSiv7eztcZq7NJc37mCftOoEyG/I2tF72XAmuaLB5dw6BEoai0+hSwI+v05zLPDaGca5 BqMHbKs+eJ48x8He75WewOvQ1a6qRd6VuN9aIxA97yEONgEKIYqZ/d/SFRJie+szpne9 5pXA== 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 3-v6si8725301plz.220.2018.07.24.07.13.57; Tue, 24 Jul 2018 07:13: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 S2388544AbeGXPUg (ORCPT + 31 others); Tue, 24 Jul 2018 11:20:36 -0400 Received: from foss.arm.com ([217.140.101.70]:52294 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388460AbeGXPUf (ORCPT ); Tue, 24 Jul 2018 11:20:35 -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 8C77B7A9; Tue, 24 Jul 2018 07:13:55 -0700 (PDT) Received: from sugar.kfn.arm.com (E110176.Emea.Arm.com [10.50.4.179]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E22C13F237; Tue, 24 Jul 2018 07:13:53 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , Geert Uytterhoeven , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] crypto: ccree: remove cipher ivgen left overs Date: Tue, 24 Jul 2018 15:12:44 +0100 Message-Id: <1532441567-11694-3-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532441567-11694-1-git-send-email-gilad@benyossef.com> References: <1532441567-11694-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 IV generation is not available via the skcipher interface. Remove the left over support of it from the ablkcipher days. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_buffer_mgr.c | 8 ++------ drivers/crypto/ccree/cc_cipher.c | 11 ----------- drivers/crypto/ccree/cc_cipher.h | 1 - 3 files changed, 2 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index b325774..dd948e1 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -454,9 +454,7 @@ void cc_unmap_cipher_request(struct device *dev, void *ctx, dev_dbg(dev, "Unmapped iv: iv_dma_addr=%pad iv_size=%u\n", &req_ctx->gen_ctx.iv_dma_addr, ivsize); dma_unmap_single(dev, req_ctx->gen_ctx.iv_dma_addr, - ivsize, - req_ctx->is_giv ? DMA_BIDIRECTIONAL : - DMA_TO_DEVICE); + ivsize, DMA_TO_DEVICE); } /* Release pool */ if (req_ctx->dma_buf_type == CC_DMA_BUF_MLLI && @@ -498,9 +496,7 @@ int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx, dump_byte_array("iv", (u8 *)info, ivsize); req_ctx->gen_ctx.iv_dma_addr = dma_map_single(dev, (void *)info, - ivsize, - req_ctx->is_giv ? DMA_BIDIRECTIONAL : - DMA_TO_DEVICE); + ivsize, DMA_TO_DEVICE); if (dma_mapping_error(dev, req_ctx->gen_ctx.iv_dma_addr)) { dev_err(dev, "Mapping iv %u B at va=%pK for DMA failed\n", ivsize, info); diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index eb99633..64740dd 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -743,14 +743,6 @@ static int cc_cipher_process(struct skcipher_request *req, cc_setup_cipher_data(tfm, req_ctx, dst, src, nbytes, req, desc, &seq_len); - /* do we need to generate IV? */ - if (req_ctx->is_giv) { - cc_req.ivgen_dma_addr[0] = req_ctx->gen_ctx.iv_dma_addr; - cc_req.ivgen_dma_addr_len = 1; - /* set the IV size (8/16 B long)*/ - cc_req.ivgen_size = ivsize; - } - /* STAT_PHASE_3: Lock HW and push sequence */ rc = cc_send_request(ctx_p->drvdata, &cc_req, desc, seq_len, @@ -775,7 +767,6 @@ static int cc_cipher_encrypt(struct skcipher_request *req) { struct cipher_req_ctx *req_ctx = skcipher_request_ctx(req); - req_ctx->is_giv = false; req_ctx->backup_info = NULL; return cc_cipher_process(req, DRV_CRYPTO_DIRECTION_ENCRYPT); @@ -807,8 +798,6 @@ static int cc_cipher_decrypt(struct skcipher_request *req) req_ctx->backup_info = NULL; } - req_ctx->is_giv = false; - return cc_cipher_process(req, DRV_CRYPTO_DIRECTION_DECRYPT); } diff --git a/drivers/crypto/ccree/cc_cipher.h b/drivers/crypto/ccree/cc_cipher.h index 68444cf..4dbc0a1 100644 --- a/drivers/crypto/ccree/cc_cipher.h +++ b/drivers/crypto/ccree/cc_cipher.h @@ -22,7 +22,6 @@ struct cipher_req_ctx { u32 out_mlli_nents; u8 *backup_info; /*store iv for generated IV flow*/ u8 *iv; - bool is_giv; struct mlli_params mlli_params; }; From patchwork Tue Jul 24 14:12:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 142807 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp7324797ljj; Tue, 24 Jul 2018 07:14:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc7zZGLGirn0bif5EcefcNmfi8Shtl07gV66GEKA6L9XS09ORrky6n8A13pTjWv3FumkI4v X-Received: by 2002:a62:b40c:: with SMTP id h12-v6mr18088691pfn.18.1532441641946; Tue, 24 Jul 2018 07:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532441641; cv=none; d=google.com; s=arc-20160816; b=mXYlwNGQ9dSFFdybXTwC/FieckZ7nJXb8TalzVvotSvIn3u+jk0vpGKflNu/UY1diZ XrljspQK5d6dtjz33rAAWLMuxB52+pUj7Y6uJQnV1mwxhZerwkon8Vvz+0S0niPU8Vv3 1GrQZilcqgluwkEsKH96MCUM47InCW1wpGUoybZks9VhWdqp8q18wmJhU5m54/Tk7mif w9/ZxMinxGsYqnI8MYs7N/7oviqBn6/UCbSzcCwnzeFbzaPTTQAzKzVBkE5rm09Wjum3 JT9gbSwLanFQFn0ZBQcyA2ojrX3enq41TP670B3SJRAuqfyDYl4VQh0My10QwLKLffTQ DPMw== 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=runiEI3I8OxSunaVbcL1M03ZpeP7YYut3jc62+mkQ4I=; b=aIjJ1lSWj8P369r4cQtW6enc2Iw9DgLbmDXSZEiAxwpB2K2yZ3KTNBgqnzHs0tRtrv 1Uf4pf8ti7N+KLvMPLAvpVPdrPafU9dkusc4x/ZJNiIZHJYxdUknS93LFAlEZJ5HWy3w iDYYFliF45dtZZy4TPLxN4BnIgwycUVdvCTbJTmQu6otMg5y6yEO8mN6FXbMi2Yvi+Ft hZKDawkJmhC4DWYa9fqlwJbgQktXAaKOEqa9xuXUIQ2pxwn6mBrfvnWpwssiIkkYSQEG JxMdn7y7EH0ahz5JGMJRF/QDoFPl+BHGCFJCroJoBaHQpWcj9LSYvmOQlYtRrXdwJ9e4 AELQ== 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 w25-v6si11884854pga.58.2018.07.24.07.14.01; Tue, 24 Jul 2018 07:14:01 -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 S2388559AbeGXPUj (ORCPT + 31 others); Tue, 24 Jul 2018 11:20:39 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52304 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388460AbeGXPUi (ORCPT ); Tue, 24 Jul 2018 11:20:38 -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 6FE717A9; Tue, 24 Jul 2018 07:13:58 -0700 (PDT) Received: from sugar.kfn.arm.com (E110176.Emea.Arm.com [10.50.4.179]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C66B23F237; Tue, 24 Jul 2018 07:13:56 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , Geert Uytterhoeven , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] crypto: ccree: zero all of request ctx before use Date: Tue, 24 Jul 2018 15:12:45 +0100 Message-Id: <1532441567-11694-4-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532441567-11694-1-git-send-email-gilad@benyossef.com> References: <1532441567-11694-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 In certain error path req_ctx->iv was being freed despite not being allocated because it was not initialized to NULL. Rather than play whack a mole with the structure various field, zero it before use. This fixes a kernel panic that may occur if an invalid buffer size was requested triggering the bug above. Fixes: 63ee04c8b491 ("crypto: ccree - add skcipher support") Reported-by: Geert Uytterhoeven Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_cipher.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index 64740dd..9da0ecc 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -767,7 +767,7 @@ static int cc_cipher_encrypt(struct skcipher_request *req) { struct cipher_req_ctx *req_ctx = skcipher_request_ctx(req); - req_ctx->backup_info = NULL; + memset(req_ctx, 0, sizeof(*req_ctx)); return cc_cipher_process(req, DRV_CRYPTO_DIRECTION_ENCRYPT); } @@ -782,6 +782,8 @@ static int cc_cipher_decrypt(struct skcipher_request *req) gfp_t flags = cc_gfp_flags(&req->base); unsigned int len; + memset(req_ctx, 0, sizeof(*req_ctx)); + if (ctx_p->cipher_mode == DRV_CIPHER_CBC) { /* Allocate and save the last IV sized bytes of the source, @@ -794,8 +796,6 @@ static int cc_cipher_decrypt(struct skcipher_request *req) len = req->cryptlen - ivsize; scatterwalk_map_and_copy(req_ctx->backup_info, req->src, len, ivsize, 0); - } else { - req_ctx->backup_info = NULL; } return cc_cipher_process(req, DRV_CRYPTO_DIRECTION_DECRYPT); From patchwork Tue Jul 24 14:12:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 142808 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp7324845ljj; Tue, 24 Jul 2018 07:14:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2DNFmW5j88ADKNJwr/X/ytZOGx8fEb/2eWRz8HbLVKk+XRCrNWYHp2gMEejXLN71Dugaa X-Received: by 2002:a62:4a41:: with SMTP id x62-v6mr18001657pfa.45.1532441644481; Tue, 24 Jul 2018 07:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532441644; cv=none; d=google.com; s=arc-20160816; b=BZarkE/wg+JKgop59vLCZNjSPbeLSkZ5VXsq3PFK7Q0KCwRGOpt5aAZhFdqlEcaRGH zmPkDb99xjM8LTLWRkHIsG0AEy8wI5NvLg/C08KOUdqOoGkAQTt3nz6iSvjrVOkhbazN tfc0QhUqnznQ/qAqfAwYPM4hMr1MUWJgBGY7gpdlafD2akEjBhr3cz7Q2QZDSeiVixiw 9PMt2My/4UOvz/xrTmNfhKBSjR1CiEypw9lsw0ii9LSfrVYzhiEr7T+0dbYx27C2ktTb KhGFx/iBjLxQ4sSQqUI+gTnq7M63As1Ur7U1nBfErZ/R1aKFhYh/hawypNmX+GH6Hj+n miHg== 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=rT9ZdVMwFqoT8GYSFR6p87uQ3+p2nU4b5WAZzTHtaTs=; b=msRi966hmG4cHUPP/EMk+aH2dh4XNUAKm2/WhiMuZmAcyBphdEsyjrLPt6W7rJwwXI +6VoXMCgYMh1Qz5mEvWy7Mf8OK3PP8whvx2ETMFDBzuGVdDWQTiVHHJxBMlpeVPz5w1Q 0yFePhFAdo/ohtt1Y38mRCQWUMsJ+T1QZBR0ByUtlTJ2JSrBbNvdBDq2GhM6VD/aXwpO QWjkfiOMFm51lSkB+VBfxmMls9sFyeuz2bDUfaNRcy8RK3fZnthYyqQmEPyBUwBUucrt YKn4XojHR5TFIoEwOz5a2kMOpU5H6181sx/jG/I46QQoZFrxUJZOm8zm2KfkCH5SNWe7 0dgg== 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 x17-v6si10797947pfn.286.2018.07.24.07.14.04; Tue, 24 Jul 2018 07:14:04 -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 S2388574AbeGXPUm (ORCPT + 31 others); Tue, 24 Jul 2018 11:20:42 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52312 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388460AbeGXPUl (ORCPT ); Tue, 24 Jul 2018 11:20: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 28DFD7A9; Tue, 24 Jul 2018 07:14:01 -0700 (PDT) Received: from sugar.kfn.arm.com (E110176.Emea.Arm.com [10.50.4.179]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B04F63F237; Tue, 24 Jul 2018 07:13:59 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , Geert Uytterhoeven , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] crypto: ccree: allow bigger than sector XTS op Date: Tue, 24 Jul 2018 15:12:46 +0100 Message-Id: <1532441567-11694-5-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532441567-11694-1-git-send-email-gilad@benyossef.com> References: <1532441567-11694-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 ccree driver had a sanity check that we are not asked to encrypt an XTS buffer bigger than a sane sector size since XTS IV needs to include the sector number in the IV so this is not expected in any real use case. Unfortunately, this breaks cryptsetup benchmark test which has a synthetic performance test using 64k buffer of data with the same IV. Remove the sanity check and allow the user to hang themselves and/or run benchmarks if they so wish. Reported-by: Geert Uytterhoeven Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_cipher.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index 9da0ecc..7623b299 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -19,8 +19,6 @@ #define template_skcipher template_u.skcipher -#define CC_MIN_AES_XTS_SIZE 0x10 -#define CC_MAX_AES_XTS_SIZE 0x2000 struct cc_cipher_handle { struct list_head alg_list; }; @@ -98,8 +96,7 @@ static int validate_data_size(struct cc_cipher_ctx *ctx_p, case S_DIN_to_AES: switch (ctx_p->cipher_mode) { case DRV_CIPHER_XTS: - if (size >= CC_MIN_AES_XTS_SIZE && - size <= CC_MAX_AES_XTS_SIZE && + if (size >= AES_BLOCK_SIZE && IS_ALIGNED(size, AES_BLOCK_SIZE)) return 0; break;