]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
libceph: Remove obsolete session key alignment logic
authorEric Biggers <ebiggers@kernel.org>
Sat, 14 Mar 2026 21:25:19 +0000 (14:25 -0700)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 16 Mar 2026 10:06:22 +0000 (11:06 +0100)
Since the call to crypto_shash_setkey() was replaced with
hmac_sha256_preparekey() which doesn't allocate memory regardless of the
alignment of the input key, remove the session key alignment logic from
process_auth_done().  Also remove the inclusion of crypto/hash.h, which
is no longer needed since crypto_shash is no longer used.

[ idryomov: rewrap comment ]

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
net/ceph/messenger_v2.c

index 50f65820f623f309533f94e571cafad815c87ea5..05f6eea299fc013912bef4f1592128f6b09b325a 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/ceph/ceph_debug.h>
 
 #include <crypto/aead.h>
-#include <crypto/hash.h>
 #include <crypto/sha2.h>
 #include <crypto/utils.h>
 #include <linux/bvec.h>
@@ -2352,16 +2351,14 @@ bad:
 }
 
 /*
- * Align session_key and con_secret to avoid GFP_ATOMIC allocation
- * inside crypto_shash_setkey() and crypto_aead_setkey() called from
- * setup_crypto().  __aligned(16) isn't guaranteed to work for stack
- * objects, so do it by hand.
+ * Align con_secret to avoid GFP_ATOMIC allocation inside
+ * crypto_aead_setkey() called from setup_crypto().  __aligned(16)
+ * isn't guaranteed to work for stack objects, so do it by hand.
  */
 static int process_auth_done(struct ceph_connection *con, void *p, void *end)
 {
-       u8 session_key_buf[CEPH_MAX_KEY_LEN + 16];
+       u8 session_key[CEPH_MAX_KEY_LEN];
        u8 con_secret_buf[CEPH_MAX_CON_SECRET_LEN + 16];
-       u8 *session_key = PTR_ALIGN(&session_key_buf[0], 16);
        u8 *con_secret = PTR_ALIGN(&con_secret_buf[0], 16);
        int session_key_len, con_secret_len;
        int payload_len;
@@ -2415,7 +2412,7 @@ static int process_auth_done(struct ceph_connection *con, void *p, void *end)
        con->state = CEPH_CON_S_V2_AUTH_SIGNATURE;
 
 out:
-       memzero_explicit(session_key_buf, sizeof(session_key_buf));
+       memzero_explicit(session_key, sizeof(session_key));
        memzero_explicit(con_secret_buf, sizeof(con_secret_buf));
        return ret;