Skip to content

Commit f6e1ea1

Browse files
committed
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
2 parents 139711f + 664f1e2 commit f6e1ea1

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

fs/ceph/mds_client.c

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,22 @@ static int set_request_path_attr(struct inode *rinode, struct dentry *rdentry,
24752475
return r;
24762476
}
24772477

2478+
static void encode_timestamp_and_gids(void **p,
2479+
const struct ceph_mds_request *req)
2480+
{
2481+
struct ceph_timespec ts;
2482+
int i;
2483+
2484+
ceph_encode_timespec64(&ts, &req->r_stamp);
2485+
ceph_encode_copy(p, &ts, sizeof(ts));
2486+
2487+
/* gid_list */
2488+
ceph_encode_32(p, req->r_cred->group_info->ngroups);
2489+
for (i = 0; i < req->r_cred->group_info->ngroups; i++)
2490+
ceph_encode_64(p, from_kgid(&init_user_ns,
2491+
req->r_cred->group_info->gid[i]));
2492+
}
2493+
24782494
/*
24792495
* called under mdsc->mutex
24802496
*/
@@ -2491,7 +2507,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
24912507
u64 ino1 = 0, ino2 = 0;
24922508
int pathlen1 = 0, pathlen2 = 0;
24932509
bool freepath1 = false, freepath2 = false;
2494-
int len, i;
2510+
int len;
24952511
u16 releases;
24962512
void *p, *end;
24972513
int ret;
@@ -2517,17 +2533,10 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
25172533
goto out_free1;
25182534
}
25192535

2520-
if (legacy) {
2521-
/* Old style */
2522-
len = sizeof(*head);
2523-
} else {
2524-
/* New style: add gid_list and any later fields */
2525-
len = sizeof(struct ceph_mds_request_head) + sizeof(u32) +
2526-
(sizeof(u64) * req->r_cred->group_info->ngroups);
2527-
}
2528-
2536+
len = legacy ? sizeof(*head) : sizeof(struct ceph_mds_request_head);
25292537
len += pathlen1 + pathlen2 + 2*(1 + sizeof(u32) + sizeof(u64)) +
25302538
sizeof(struct ceph_timespec);
2539+
len += sizeof(u32) + (sizeof(u64) * req->r_cred->group_info->ngroups);
25312540

25322541
/* calculate (max) length for cap releases */
25332542
len += sizeof(struct ceph_mds_request_release) *
@@ -2548,7 +2557,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
25482557
msg->hdr.tid = cpu_to_le64(req->r_tid);
25492558

25502559
/*
2551-
* The old ceph_mds_request_header didn't contain a version field, and
2560+
* The old ceph_mds_request_head didn't contain a version field, and
25522561
* one was added when we moved the message version from 3->4.
25532562
*/
25542563
if (legacy) {
@@ -2609,20 +2618,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
26092618

26102619
head->num_releases = cpu_to_le16(releases);
26112620

2612-
/* time stamp */
2613-
{
2614-
struct ceph_timespec ts;
2615-
ceph_encode_timespec64(&ts, &req->r_stamp);
2616-
ceph_encode_copy(&p, &ts, sizeof(ts));
2617-
}
2618-
2619-
/* gid list */
2620-
if (!legacy) {
2621-
ceph_encode_32(&p, req->r_cred->group_info->ngroups);
2622-
for (i = 0; i < req->r_cred->group_info->ngroups; i++)
2623-
ceph_encode_64(&p, from_kgid(&init_user_ns,
2624-
req->r_cred->group_info->gid[i]));
2625-
}
2621+
encode_timestamp_and_gids(&p, req);
26262622

26272623
if (WARN_ON_ONCE(p > end)) {
26282624
ceph_msg_put(msg);
@@ -2730,13 +2726,8 @@ static int __prepare_send_request(struct ceph_mds_session *session,
27302726
/* remove cap/dentry releases from message */
27312727
rhead->num_releases = 0;
27322728

2733-
/* time stamp */
27342729
p = msg->front.iov_base + req->r_request_release_offset;
2735-
{
2736-
struct ceph_timespec ts;
2737-
ceph_encode_timespec64(&ts, &req->r_stamp);
2738-
ceph_encode_copy(&p, &ts, sizeof(ts));
2739-
}
2730+
encode_timestamp_and_gids(&p, req);
27402731

27412732
msg->front.iov_len = p - msg->front.iov_base;
27422733
msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);

include/linux/ceph/msgr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
#define CEPH_MSGR2_INCARNATION_1 (0ull)
3434

3535
#define DEFINE_MSGR2_FEATURE(bit, incarnation, name) \
36-
static const uint64_t CEPH_MSGR2_FEATURE_##name = (1ULL << bit); \
37-
static const uint64_t CEPH_MSGR2_FEATUREMASK_##name = \
36+
static const uint64_t __maybe_unused CEPH_MSGR2_FEATURE_##name = (1ULL << bit); \
37+
static const uint64_t __maybe_unused CEPH_MSGR2_FEATUREMASK_##name = \
3838
(1ULL << bit | CEPH_MSGR2_INCARNATION_##incarnation);
3939

4040
#define HAVE_MSGR2_FEATURE(x, name) \

net/ceph/messenger_v2.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,8 @@ static int prepare_auth_signature(struct ceph_connection *con)
13331333
void *buf;
13341334
int ret;
13351335

1336-
buf = alloc_conn_buf(con, head_onwire_len(SHA256_DIGEST_SIZE, false));
1336+
buf = alloc_conn_buf(con, head_onwire_len(SHA256_DIGEST_SIZE,
1337+
con_secure(con)));
13371338
if (!buf)
13381339
return -ENOMEM;
13391340

@@ -2032,10 +2033,18 @@ static int process_auth_reply_more(struct ceph_connection *con,
20322033
return -EINVAL;
20332034
}
20342035

2036+
/*
2037+
* Align session_key and con_secret to avoid GFP_ATOMIC allocation
2038+
* inside crypto_shash_setkey() and crypto_aead_setkey() called from
2039+
* setup_crypto(). __aligned(16) isn't guaranteed to work for stack
2040+
* objects, so do it by hand.
2041+
*/
20352042
static int process_auth_done(struct ceph_connection *con, void *p, void *end)
20362043
{
2037-
u8 session_key[CEPH_KEY_LEN];
2038-
u8 con_secret[CEPH_MAX_CON_SECRET_LEN];
2044+
u8 session_key_buf[CEPH_KEY_LEN + 16];
2045+
u8 con_secret_buf[CEPH_MAX_CON_SECRET_LEN + 16];
2046+
u8 *session_key = PTR_ALIGN(&session_key_buf[0], 16);
2047+
u8 *con_secret = PTR_ALIGN(&con_secret_buf[0], 16);
20392048
int session_key_len, con_secret_len;
20402049
int payload_len;
20412050
u64 global_id;

0 commit comments

Comments
 (0)