From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Ilya Lesokhin <ilyal@mellanox.com>,
Sabrina Dubroca <sd@queasysnail.net>,
Stefano Brivio <sbrivio@redhat.com>,
Herbert Xu <herbert@gondor.apana.org.au>
Subject: [PATCH 4.15 09/55] crypto: aesni - add wrapper for generic gcm(aes)
Date: Fri, 2 Feb 2018 17:58:27 +0100 [thread overview]
Message-ID: <20180202140826.836479426@linuxfoundation.org> (raw)
In-Reply-To: <20180202140826.117602411@linuxfoundation.org>
4.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <sd@queasysnail.net>
commit fc8517bf627c9b834f80274a1bc9ecd39b27231b upstream.
When I added generic-gcm-aes I didn't add a wrapper like the one
provided for rfc4106(gcm(aes)). We need to add a cryptd wrapper to fall
back on in case the FPU is not available, otherwise we might corrupt the
FPU state.
Fixes: cce2ea8d90fe ("crypto: aesni - add generic gcm(aes)")
Reported-by: Ilya Lesokhin <ilyal@mellanox.com>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/crypto/aesni-intel_glue.c | 66 ++++++++++++++++++++++++++++++-------
1 file changed, 54 insertions(+), 12 deletions(-)
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -690,8 +690,8 @@ static int common_rfc4106_set_key(struct
rfc4106_set_hash_subkey(ctx->hash_subkey, key, key_len);
}
-static int rfc4106_set_key(struct crypto_aead *parent, const u8 *key,
- unsigned int key_len)
+static int gcmaes_wrapper_set_key(struct crypto_aead *parent, const u8 *key,
+ unsigned int key_len)
{
struct cryptd_aead **ctx = crypto_aead_ctx(parent);
struct cryptd_aead *cryptd_tfm = *ctx;
@@ -716,8 +716,8 @@ static int common_rfc4106_set_authsize(s
/* This is the Integrity Check Value (aka the authentication tag length and can
* be 8, 12 or 16 bytes long. */
-static int rfc4106_set_authsize(struct crypto_aead *parent,
- unsigned int authsize)
+static int gcmaes_wrapper_set_authsize(struct crypto_aead *parent,
+ unsigned int authsize)
{
struct cryptd_aead **ctx = crypto_aead_ctx(parent);
struct cryptd_aead *cryptd_tfm = *ctx;
@@ -929,7 +929,7 @@ static int helper_rfc4106_decrypt(struct
aes_ctx);
}
-static int rfc4106_encrypt(struct aead_request *req)
+static int gcmaes_wrapper_encrypt(struct aead_request *req)
{
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
struct cryptd_aead **ctx = crypto_aead_ctx(tfm);
@@ -945,7 +945,7 @@ static int rfc4106_encrypt(struct aead_r
return crypto_aead_encrypt(req);
}
-static int rfc4106_decrypt(struct aead_request *req)
+static int gcmaes_wrapper_decrypt(struct aead_request *req)
{
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
struct cryptd_aead **ctx = crypto_aead_ctx(tfm);
@@ -1128,6 +1128,30 @@ static int generic_gcmaes_decrypt(struct
aes_ctx);
}
+static int generic_gcmaes_init(struct crypto_aead *aead)
+{
+ struct cryptd_aead *cryptd_tfm;
+ struct cryptd_aead **ctx = crypto_aead_ctx(aead);
+
+ cryptd_tfm = cryptd_alloc_aead("__driver-generic-gcm-aes-aesni",
+ CRYPTO_ALG_INTERNAL,
+ CRYPTO_ALG_INTERNAL);
+ if (IS_ERR(cryptd_tfm))
+ return PTR_ERR(cryptd_tfm);
+
+ *ctx = cryptd_tfm;
+ crypto_aead_set_reqsize(aead, crypto_aead_reqsize(&cryptd_tfm->base));
+
+ return 0;
+}
+
+static void generic_gcmaes_exit(struct crypto_aead *aead)
+{
+ struct cryptd_aead **ctx = crypto_aead_ctx(aead);
+
+ cryptd_free_aead(*ctx);
+}
+
static struct aead_alg aesni_aead_algs[] = { {
.setkey = common_rfc4106_set_key,
.setauthsize = common_rfc4106_set_authsize,
@@ -1147,10 +1171,10 @@ static struct aead_alg aesni_aead_algs[]
}, {
.init = rfc4106_init,
.exit = rfc4106_exit,
- .setkey = rfc4106_set_key,
- .setauthsize = rfc4106_set_authsize,
- .encrypt = rfc4106_encrypt,
- .decrypt = rfc4106_decrypt,
+ .setkey = gcmaes_wrapper_set_key,
+ .setauthsize = gcmaes_wrapper_set_authsize,
+ .encrypt = gcmaes_wrapper_encrypt,
+ .decrypt = gcmaes_wrapper_decrypt,
.ivsize = GCM_RFC4106_IV_SIZE,
.maxauthsize = 16,
.base = {
@@ -1170,13 +1194,31 @@ static struct aead_alg aesni_aead_algs[]
.ivsize = GCM_AES_IV_SIZE,
.maxauthsize = 16,
.base = {
+ .cra_name = "__generic-gcm-aes-aesni",
+ .cra_driver_name = "__driver-generic-gcm-aes-aesni",
+ .cra_priority = 0,
+ .cra_flags = CRYPTO_ALG_INTERNAL,
+ .cra_blocksize = 1,
+ .cra_ctxsize = sizeof(struct generic_gcmaes_ctx),
+ .cra_alignmask = AESNI_ALIGN - 1,
+ .cra_module = THIS_MODULE,
+ },
+}, {
+ .init = generic_gcmaes_init,
+ .exit = generic_gcmaes_exit,
+ .setkey = gcmaes_wrapper_set_key,
+ .setauthsize = gcmaes_wrapper_set_authsize,
+ .encrypt = gcmaes_wrapper_encrypt,
+ .decrypt = gcmaes_wrapper_decrypt,
+ .ivsize = GCM_AES_IV_SIZE,
+ .maxauthsize = 16,
+ .base = {
.cra_name = "gcm(aes)",
.cra_driver_name = "generic-gcm-aesni",
.cra_priority = 400,
.cra_flags = CRYPTO_ALG_ASYNC,
.cra_blocksize = 1,
- .cra_ctxsize = sizeof(struct generic_gcmaes_ctx),
- .cra_alignmask = AESNI_ALIGN - 1,
+ .cra_ctxsize = sizeof(struct cryptd_aead *),
.cra_module = THIS_MODULE,
},
} };
next prev parent reply other threads:[~2018-02-02 17:15 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 16:58 [PATCH 4.15 00/55] 4.15.1-stable review Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 03/55] gpio: stmpe: i2c transfer are forbiden in atomic context Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 04/55] gpio: Fix kernel stack leak to userspace Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 05/55] ALSA: hda - Reduce the suspend time consumption for ALC256 Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 06/55] crypto: ecdh - fix typo in KPP dependency of CRYPTO_ECDH Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 07/55] crypto: aesni - handle zero length dst buffer Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 08/55] crypto: aesni - fix typo in generic_gcmaes_decrypt Greg Kroah-Hartman
2018-02-02 16:58 ` Greg Kroah-Hartman [this message]
2018-02-02 16:58 ` [PATCH 4.15 10/55] crypto: aesni - Fix out-of-bounds access of the data buffer in generic-gcm-aesni Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 11/55] crypto: aesni - Fix out-of-bounds access of the AAD " Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 12/55] crypto: inside-secure - fix hash when length is a multiple of a block Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 13/55] crypto: inside-secure - avoid unmapping DMA memory that was not mapped Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 14/55] crypto: sha3-generic - fixes for alignment and big endian operation Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 15/55] crypto: af_alg - whitelist mask and type Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 16/55] HID: wacom: EKR: ensure devres groups at higher indexes are released Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 17/55] HID: wacom: Fix reporting of touch toggle (WACOM_HID_WD_MUTE_DEVICE) events Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 18/55] power: reset: zx-reboot: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 19/55] gpio: iop: " Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 20/55] gpio: ath79: add missing MODULE_DESCRIPTION/LICENSE Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 21/55] mtd: nand: denali_pci: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 22/55] igb: Free IRQs when device is hotplugged Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 23/55] ima/policy: fix parsing of fsuuid Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 24/55] scsi: aacraid: Fix udev inquiry race condition Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 25/55] scsi: aacraid: Fix hang in kdump Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 26/55] scsi: storvsc: missing error code in storvsc_probe() Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 27/55] staging: lustre: separate a connection destroy from free struct kib_conn Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 28/55] staging: ccree: NULLify backup_info when unused Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 29/55] staging: ccree: fix fips event irq handling build Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 30/55] tty: fix data race between tty_init_dev and flush of buf Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 31/55] usb: option: Add support for FS040U modem Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 33/55] USB: cdc-acm: Do not log urb submission errors on disconnect Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 34/55] CDC-ACM: apply quirk for card reader Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 35/55] USB: serial: io_edgeport: fix possible sleep-in-atomic Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 36/55] usbip: prevent bind loops on devices attached to vhci_hcd Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 37/55] usbip: list: dont list " Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 38/55] USB: serial: simple: add Motorola Tetra driver Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 39/55] usb: f_fs: Prevent gadget unbind if it is already unbound Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 40/55] usb: uas: unconditionally bring back host after reset Greg Kroah-Hartman
2018-02-02 16:58 ` [PATCH 4.15 41/55] usb/gadget: Fix "high bandwidth" check in usb_gadget_ep_match_desc() Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 42/55] ANDROID: binder: remove waitqueue when thread exits Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 43/55] android: binder: use VM_ALLOC to get vm area Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 44/55] mei: me: allow runtime pm for platform with D0i3 Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 45/55] serial: 8250_of: fix return code when probe function fails to get reset Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 46/55] serial: 8250_uniphier: fix error return code in uniphier_uart_probe() Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 47/55] serial: 8250_dw: Revert "Improve clock rate setting" Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 48/55] serial: imx: Only wakeup via RTSDEN bit if the system has RTS/CTS Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 49/55] spi: imx: do not access registers while clocks disabled Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 50/55] iio: adc: stm32: fix scan of multiple channels with DMA Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 51/55] iio: chemical: ccs811: Fix output of IIO_CONCENTRATION channels Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 52/55] test_firmware: fix missing unlock on error in config_num_requests_store() Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 53/55] Input: synaptics-rmi4 - unmask F03 interrupts when port is opened Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 54/55] Input: synaptics-rmi4 - do not delete interrupt memory too early Greg Kroah-Hartman
2018-02-02 16:59 ` [PATCH 4.15 55/55] x86/efi: Clarify that reset attack mitigation needs appropriate userspace Greg Kroah-Hartman
2018-02-02 22:17 ` [PATCH 4.15 00/55] 4.15.1-stable review Shuah Khan
2018-02-03 5:16 ` Greg Kroah-Hartman
2018-02-03 4:35 ` Dan Rue
2018-02-03 5:18 ` Greg Kroah-Hartman
2018-02-05 15:50 ` Milosz Wasilewski
2018-02-03 15:34 ` Guenter Roeck
2018-02-03 15:44 ` Greg Kroah-Hartman
2018-02-03 16:46 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180202140826.836479426@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=ilyal@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sbrivio@redhat.com \
--cc=sd@queasysnail.net \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).