From b6eb0c84a3e8ada2dff1d32a3b8bcf80e6ebd246 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Thu, 26 Nov 2020 11:22:49 -0500 Subject: [PATCH] LU-14151 gss: use skcipher when sync_skcipher not available Linux 4.2 introduced support for skcipher in commit 7a7ffe65c8c5 crypto: skcipher - Add top-level skcipher interface Based on the existence of crypto_alloc_skcipher, use the skcipher API instead of the blkcipher API, in case the sync_skcipher API is not available. Test-Parameters: clientdistro=el8.2 env=SHARED_KEY=true,SK_FLAVOR=skpi mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 testlist=sanity Test-Parameters: clientdistro=el7.8 env=SHARED_KEY=true,SK_FLAVOR=skpi mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 testlist=sanity Signed-off-by: Sebastien Buisson Change-Id: I4e62cd5c8219a215c5528f81d525c054215073e3 Reviewed-on: https://review.whamcloud.com/40768 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 19 +++++++++++++++++++ lustre/ptlrpc/gss/gss_crypto.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 79c4d0b..286f717 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1143,6 +1143,24 @@ account_page_dirtied, [ ]) # LC_ACCOUNT_PAGE_DIRTIED_3ARGS # +# LC_HAVE_CRYPTO_ALLOC_SKCIPHER +# +# Kernel version 4.12 commit 7a7ffe65c8c5 +# introduced crypto_alloc_skcipher(). +# +AC_DEFUN([LC_HAVE_CRYPTO_ALLOC_SKCIPHER], [ +LB_CHECK_COMPILE([if crypto_alloc_skcipher is defined], +crypto_alloc_skcipher, [ + #include +],[ + crypto_alloc_skcipher(NULL, 0, 0); +],[ + AC_DEFINE(HAVE_CRYPTO_ALLOC_SKCIPHER, 1, + [crypto_alloc_skcipher is defined]) +]) +]) # LC_HAVE_CRYPTO_ALLOC_SKCIPHER + +# # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY # # 4.3 replace interval with interval_exp in 'struct blk_integrity' @@ -2365,6 +2383,7 @@ AC_DEFUN([LC_PROG_LINUX], [ LC_BIO_ENDIO_USES_ONE_ARG LC_SYMLINK_OPS_USE_NAMEIDATA LC_ACCOUNT_PAGE_DIRTIED_3ARGS + LC_HAVE_CRYPTO_ALLOC_SKCIPHER # 4.3 LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY diff --git a/lustre/ptlrpc/gss/gss_crypto.h b/lustre/ptlrpc/gss/gss_crypto.h index 5dbc9f5..7653e21 100644 --- a/lustre/ptlrpc/gss/gss_crypto.h +++ b/lustre/ptlrpc/gss/gss_crypto.h @@ -26,6 +26,36 @@ #else /* ! SYNC_SKCIPHER_REQUEST_ON_STACK */ +#ifdef HAVE_CRYPTO_ALLOC_SKCIPHER + +#define crypto_sync_skcipher crypto_skcipher + +#define SYNC_SKCIPHER_REQUEST_ON_STACK SKCIPHER_REQUEST_ON_STACK + +#define skcipher_request_set_sync_tfm skcipher_request_set_tfm + +#define skcipher_request_set_crypt_iv(d) + +#define crypto_sync_skcipher_blocksize crypto_skcipher_blocksize + +#define crypto_sync_skcipher_setkey crypto_skcipher_setkey + +#define crypto_alloc_sync_skcipher crypto_alloc_skcipher + +#define crypto_free_sync_skcipher crypto_free_skcipher + +#define crypto_sync_skcipher_ivsize crypto_skcipher_ivsize + +#define crypto_skcipher_encrypt_iv(desc, dst, src, blocksize) \ + crypto_skcipher_encrypt((desc)) + +#define crypto_skcipher_decrypt_iv(desc, dst, src, blocksize) \ + crypto_skcipher_decrypt((desc)) + +#define skcipher_request_zero(req) /* nop */ + +#else /* ! HAVE_CRYPTO_ALLOC_SKCIPHER */ + #define crypto_sync_skcipher crypto_blkcipher #define SYNC_SKCIPHER_REQUEST_ON_STACK(name, tfm) \ @@ -66,6 +96,7 @@ #define skcipher_request_zero(req) /* nop */ +#endif /* HAVE_CRYPTO_ALLOC_SKCIPHER */ #endif /* SYNC_SKCIPHER_REQUEST_ON_STACK */ struct gss_keyblock { -- 1.8.3.1