A fix for an edge case in MClientRequest encoding and a couple of
trivial fixups for the new msgr2 support. -----BEGIN PGP SIGNATURE----- iQFHBAABCAAxFiEEydHwtzie9C7TfviiSn/eOAIR84sFAl/stgUTHGlkcnlvbW92 QGdtYWlsLmNvbQAKCRBKf944AhHzi7SECACa5sWn5GKArGNCYesG/Xnbl4FbtorA QNmDS7z5SBTsxQfOmkIq7Xon9fRxXEpWzr/eCEZKcXc+REHXGsy8zFz/HA0t97SS tSho288zfEifGK0k2aptBTXAiEnzhIweu9f5ZbxfLN+JPyfynxfvXytdXYFeU/Op zLUBSjJusmm671APBvyWl/5h/2N7XkpBM3AWNJjaW26+Mft3SpsS8Ui+USWb9SJF YEmsVR03W2pbSS66a774bThoLP8exfg7xMfUcWRHqYs3Awpp0mwMnKkHMfooYLGA Cc5FsQ7Exin23B4vCm6+0prg/cgwBg516HfsFH/jTcE2D/PjSCEX7tXE =ZGwT -----END PGP SIGNATURE----- Merge tag 'ceph-for-5.11-rc2' of git://github.com/ceph/ceph-client Pull ceph fixes from Ilya Dryomov: "A fix for an edge case in MClientRequest encoding and a couple of trivial fixups for the new msgr2 support" * tag 'ceph-for-5.11-rc2' of git://github.com/ceph/ceph-client: libceph: add __maybe_unused to DEFINE_MSGR2_FEATURE libceph: align session_key and con_secret to 16 bytes libceph: fix auth_signature buffer allocation in secure mode ceph: reencode gid_list when reconnecting
This commit is contained in:
commit
f6e1ea1964
@ -2475,6 +2475,22 @@ static int set_request_path_attr(struct inode *rinode, struct dentry *rdentry,
|
||||
return r;
|
||||
}
|
||||
|
||||
static void encode_timestamp_and_gids(void **p,
|
||||
const struct ceph_mds_request *req)
|
||||
{
|
||||
struct ceph_timespec ts;
|
||||
int i;
|
||||
|
||||
ceph_encode_timespec64(&ts, &req->r_stamp);
|
||||
ceph_encode_copy(p, &ts, sizeof(ts));
|
||||
|
||||
/* gid_list */
|
||||
ceph_encode_32(p, req->r_cred->group_info->ngroups);
|
||||
for (i = 0; i < req->r_cred->group_info->ngroups; i++)
|
||||
ceph_encode_64(p, from_kgid(&init_user_ns,
|
||||
req->r_cred->group_info->gid[i]));
|
||||
}
|
||||
|
||||
/*
|
||||
* called under mdsc->mutex
|
||||
*/
|
||||
@ -2491,7 +2507,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
|
||||
u64 ino1 = 0, ino2 = 0;
|
||||
int pathlen1 = 0, pathlen2 = 0;
|
||||
bool freepath1 = false, freepath2 = false;
|
||||
int len, i;
|
||||
int len;
|
||||
u16 releases;
|
||||
void *p, *end;
|
||||
int ret;
|
||||
@ -2517,17 +2533,10 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
|
||||
goto out_free1;
|
||||
}
|
||||
|
||||
if (legacy) {
|
||||
/* Old style */
|
||||
len = sizeof(*head);
|
||||
} else {
|
||||
/* New style: add gid_list and any later fields */
|
||||
len = sizeof(struct ceph_mds_request_head) + sizeof(u32) +
|
||||
(sizeof(u64) * req->r_cred->group_info->ngroups);
|
||||
}
|
||||
|
||||
len = legacy ? sizeof(*head) : sizeof(struct ceph_mds_request_head);
|
||||
len += pathlen1 + pathlen2 + 2*(1 + sizeof(u32) + sizeof(u64)) +
|
||||
sizeof(struct ceph_timespec);
|
||||
len += sizeof(u32) + (sizeof(u64) * req->r_cred->group_info->ngroups);
|
||||
|
||||
/* calculate (max) length for cap releases */
|
||||
len += sizeof(struct ceph_mds_request_release) *
|
||||
@ -2548,7 +2557,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
|
||||
msg->hdr.tid = cpu_to_le64(req->r_tid);
|
||||
|
||||
/*
|
||||
* The old ceph_mds_request_header didn't contain a version field, and
|
||||
* The old ceph_mds_request_head didn't contain a version field, and
|
||||
* one was added when we moved the message version from 3->4.
|
||||
*/
|
||||
if (legacy) {
|
||||
@ -2609,20 +2618,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
|
||||
|
||||
head->num_releases = cpu_to_le16(releases);
|
||||
|
||||
/* time stamp */
|
||||
{
|
||||
struct ceph_timespec ts;
|
||||
ceph_encode_timespec64(&ts, &req->r_stamp);
|
||||
ceph_encode_copy(&p, &ts, sizeof(ts));
|
||||
}
|
||||
|
||||
/* gid list */
|
||||
if (!legacy) {
|
||||
ceph_encode_32(&p, req->r_cred->group_info->ngroups);
|
||||
for (i = 0; i < req->r_cred->group_info->ngroups; i++)
|
||||
ceph_encode_64(&p, from_kgid(&init_user_ns,
|
||||
req->r_cred->group_info->gid[i]));
|
||||
}
|
||||
encode_timestamp_and_gids(&p, req);
|
||||
|
||||
if (WARN_ON_ONCE(p > end)) {
|
||||
ceph_msg_put(msg);
|
||||
@ -2730,13 +2726,8 @@ static int __prepare_send_request(struct ceph_mds_session *session,
|
||||
/* remove cap/dentry releases from message */
|
||||
rhead->num_releases = 0;
|
||||
|
||||
/* time stamp */
|
||||
p = msg->front.iov_base + req->r_request_release_offset;
|
||||
{
|
||||
struct ceph_timespec ts;
|
||||
ceph_encode_timespec64(&ts, &req->r_stamp);
|
||||
ceph_encode_copy(&p, &ts, sizeof(ts));
|
||||
}
|
||||
encode_timestamp_and_gids(&p, req);
|
||||
|
||||
msg->front.iov_len = p - msg->front.iov_base;
|
||||
msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
|
||||
|
@ -33,8 +33,8 @@
|
||||
#define CEPH_MSGR2_INCARNATION_1 (0ull)
|
||||
|
||||
#define DEFINE_MSGR2_FEATURE(bit, incarnation, name) \
|
||||
static const uint64_t CEPH_MSGR2_FEATURE_##name = (1ULL << bit); \
|
||||
static const uint64_t CEPH_MSGR2_FEATUREMASK_##name = \
|
||||
static const uint64_t __maybe_unused CEPH_MSGR2_FEATURE_##name = (1ULL << bit); \
|
||||
static const uint64_t __maybe_unused CEPH_MSGR2_FEATUREMASK_##name = \
|
||||
(1ULL << bit | CEPH_MSGR2_INCARNATION_##incarnation);
|
||||
|
||||
#define HAVE_MSGR2_FEATURE(x, name) \
|
||||
|
@ -1333,7 +1333,8 @@ static int prepare_auth_signature(struct ceph_connection *con)
|
||||
void *buf;
|
||||
int ret;
|
||||
|
||||
buf = alloc_conn_buf(con, head_onwire_len(SHA256_DIGEST_SIZE, false));
|
||||
buf = alloc_conn_buf(con, head_onwire_len(SHA256_DIGEST_SIZE,
|
||||
con_secure(con)));
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -2032,10 +2033,18 @@ bad:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
static int process_auth_done(struct ceph_connection *con, void *p, void *end)
|
||||
{
|
||||
u8 session_key[CEPH_KEY_LEN];
|
||||
u8 con_secret[CEPH_MAX_CON_SECRET_LEN];
|
||||
u8 session_key_buf[CEPH_KEY_LEN + 16];
|
||||
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;
|
||||
u64 global_id;
|
||||
|
Loading…
Reference in New Issue
Block a user