linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: aesni: add setkey for driver-gcm-aes-aesni
@ 2015-01-18 22:56 Stephan Mueller
  2015-01-18 22:58 ` Stephan Mueller
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Stephan Mueller @ 2015-01-18 22:56 UTC (permalink / raw)
  To: Tadeusz Struk, 'Herbert Xu'; +Cc: linux-crypto, 'LKML'

The cipher registered as __driver-gcm-aes-aesni is never intended
to be used directly by any caller. Instead it is a service mechanism to
rfc4106-gcm-aesni.

The kernel crypto API unconditionally calls the registered setkey
function. In case a caller erroneously uses __driver-gcm-aes-aesni a
call to crypto_aead_setkey will cause a NULL pointer dereference without
this patch.

CC: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 arch/x86/crypto/aesni-intel_glue.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 947c6bf..a278ef9 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -1012,6 +1012,16 @@ static int rfc4106_decrypt(struct aead_request *req)
 	}
 }
 
+static int __driver_rfc4106_set_key(struct crypto_aead *parent,
+				    const u8 *key, unsigned int key_len)
+{
+	/*
+	 * __driver-gcm-aes-aesni is only a backend for rfc4106-gcm-aesni
+	 * and is never intended to be used as a regular cipher.
+	 */
+	return -EOPNOTSUPP;
+}
+
 static int __driver_rfc4106_encrypt(struct aead_request *req)
 {
 	u8 one_entry_in_sg = 0;
@@ -1366,6 +1376,7 @@ static struct crypto_alg aesni_algs[] = { {
 	.cra_module		= THIS_MODULE,
 	.cra_u = {
 		.aead = {
+			.setkey		= __driver_rfc4106_set_key,
 			.encrypt	= __driver_rfc4106_encrypt,
 			.decrypt	= __driver_rfc4106_decrypt,
 		},
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-01-22 22:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-18 22:56 [PATCH] crypto: aesni: add setkey for driver-gcm-aes-aesni Stephan Mueller
2015-01-18 22:58 ` Stephan Mueller
2015-01-19 14:34 ` Tadeusz Struk
2015-01-20  3:17 ` Herbert Xu
2015-01-20  3:35   ` Stephan Mueller
2015-01-20  3:37     ` Herbert Xu
2015-01-20  3:54       ` Stephan Mueller
2015-01-20  4:03         ` Herbert Xu
2015-01-21  1:25   ` Stephan Mueller
2015-01-22 18:23     ` Tadeusz Struk
2015-01-22 21:20       ` Stephan Mueller
2015-01-22 21:55         ` Tadeusz Struk
2015-01-22 22:23       ` Herbert Xu
2015-01-22 22:30         ` Tadeusz Struk

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).