]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
libceph: rename and align ceph_x_authorizer::reply_buf
authorIlya Dryomov <idryomov@gmail.com>
Fri, 2 Dec 2016 15:35:07 +0000 (16:35 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 12 Dec 2016 22:09:19 +0000 (23:09 +0100)
It's going to be used as a temporary buffer for in-place en/decryption
with ceph_crypt() instead of on-stack buffers, so rename to enc_buf.
Ensure alignment to avoid GFP_ATOMIC allocations in the crypto stack.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Sage Weil <sage@redhat.com>
net/ceph/auth_x.c
net/ceph/auth_x.h

index de30c585c2a2ec4b280525781af14df69b4f5ff7..ef1423294517122b0d1a48d26946dfe5cfe5f0fb 100644 (file)
@@ -603,8 +603,8 @@ static int ceph_x_create_authorizer(
        auth->authorizer = (struct ceph_authorizer *) au;
        auth->authorizer_buf = au->buf->vec.iov_base;
        auth->authorizer_buf_len = au->buf->vec.iov_len;
-       auth->authorizer_reply_buf = au->reply_buf;
-       auth->authorizer_reply_buf_len = sizeof (au->reply_buf);
+       auth->authorizer_reply_buf = au->enc_buf;
+       auth->authorizer_reply_buf_len = CEPHX_AU_ENC_BUF_LEN;
        auth->sign_message = ac->ops->sign_message;
        auth->check_message_signature = ac->ops->check_message_signature;
 
@@ -638,10 +638,10 @@ static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac,
        int ret = 0;
        struct ceph_x_authorize_reply reply;
        void *preply = &reply;
-       void *p = au->reply_buf;
-       void *end = p + sizeof(au->reply_buf);
+       void *p = au->enc_buf;
 
-       ret = ceph_x_decrypt(&au->session_key, &p, end, &preply, sizeof(reply));
+       ret = ceph_x_decrypt(&au->session_key, &p, p + CEPHX_AU_ENC_BUF_LEN,
+                            &preply, sizeof(reply));
        if (ret < 0)
                return ret;
        if (ret != sizeof(reply))
index 21a5af904bae751391bf7d508dd75b1d2ee426e2..48e9ad41bd2aa70cdf42922a830f052d39e5ea7d 100644 (file)
@@ -24,6 +24,7 @@ struct ceph_x_ticket_handler {
        unsigned long renew_after, expires;
 };
 
+#define CEPHX_AU_ENC_BUF_LEN   128  /* big enough for encrypted blob */
 
 struct ceph_x_authorizer {
        struct ceph_authorizer base;
@@ -32,7 +33,7 @@ struct ceph_x_authorizer {
        unsigned int service;
        u64 nonce;
        u64 secret_id;
-       char reply_buf[128];  /* big enough for encrypted blob */
+       char enc_buf[CEPHX_AU_ENC_BUF_LEN] __aligned(8);
 };
 
 struct ceph_x_info {