Skip to content

Commit 7882a26

Browse files
committed
libceph: rename and align ceph_x_authorizer::reply_buf
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>
1 parent a45f795 commit 7882a26

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

net/ceph/auth_x.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,8 @@ static int ceph_x_create_authorizer(
603603
auth->authorizer = (struct ceph_authorizer *) au;
604604
auth->authorizer_buf = au->buf->vec.iov_base;
605605
auth->authorizer_buf_len = au->buf->vec.iov_len;
606-
auth->authorizer_reply_buf = au->reply_buf;
607-
auth->authorizer_reply_buf_len = sizeof (au->reply_buf);
606+
auth->authorizer_reply_buf = au->enc_buf;
607+
auth->authorizer_reply_buf_len = CEPHX_AU_ENC_BUF_LEN;
608608
auth->sign_message = ac->ops->sign_message;
609609
auth->check_message_signature = ac->ops->check_message_signature;
610610

@@ -638,10 +638,10 @@ static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac,
638638
int ret = 0;
639639
struct ceph_x_authorize_reply reply;
640640
void *preply = &reply;
641-
void *p = au->reply_buf;
642-
void *end = p + sizeof(au->reply_buf);
641+
void *p = au->enc_buf;
643642

644-
ret = ceph_x_decrypt(&au->session_key, &p, end, &preply, sizeof(reply));
643+
ret = ceph_x_decrypt(&au->session_key, &p, p + CEPHX_AU_ENC_BUF_LEN,
644+
&preply, sizeof(reply));
645645
if (ret < 0)
646646
return ret;
647647
if (ret != sizeof(reply))

net/ceph/auth_x.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct ceph_x_ticket_handler {
2424
unsigned long renew_after, expires;
2525
};
2626

27+
#define CEPHX_AU_ENC_BUF_LEN 128 /* big enough for encrypted blob */
2728

2829
struct ceph_x_authorizer {
2930
struct ceph_authorizer base;
@@ -32,7 +33,7 @@ struct ceph_x_authorizer {
3233
unsigned int service;
3334
u64 nonce;
3435
u64 secret_id;
35-
char reply_buf[128]; /* big enough for encrypted blob */
36+
char enc_buf[CEPHX_AU_ENC_BUF_LEN] __aligned(8);
3637
};
3738

3839
struct ceph_x_info {

0 commit comments

Comments
 (0)