Skip to content

Commit a90c6ac

Browse files
committed
Merge tag 'ceph-for-4.13-rc2' of git://github.com/ceph/ceph-client
Pull ceph fixes from Ilya Dryomov: "A number of small fixes for -rc1 Luminous changes plus a readdir race fix, marked for stable" * tag 'ceph-for-4.13-rc2' of git://github.com/ceph/ceph-client: libceph: potential NULL dereference in ceph_msg_data_create() ceph: fix race in concurrent readdir libceph: don't call encode_request_finish() on MOSDBackoff messages libceph: use alloc_pg_mapping() in __decode_pg_upmap_items() libceph: set -EINVAL in one place in crush_decode() libceph: NULL deref on osdmap_apply_incremental() error path libceph: fix old style declaration warnings
2 parents 74cbd96 + 7c40b22 commit a90c6ac

5 files changed

Lines changed: 33 additions & 22 deletions

File tree

‎fs/ceph/dir.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx,
271271
if (ret < 0)
272272
err = ret;
273273
dput(last);
274+
/* last_name no longer match cache index */
275+
if (fi->readdir_cache_idx >= 0) {
276+
fi->readdir_cache_idx = -1;
277+
fi->dir_release_count = 0;
278+
}
274279
}
275280
return err;
276281
}

‎include/linux/ceph/ceph_features.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
#define CEPH_FEATURE_INCARNATION_2 (1ull<<57) // CEPH_FEATURE_SERVER_JEWEL
1111

1212
#define DEFINE_CEPH_FEATURE(bit, incarnation, name) \
13-
const static uint64_t CEPH_FEATURE_##name = (1ULL<<bit); \
14-
const static uint64_t CEPH_FEATUREMASK_##name = \
13+
static const uint64_t CEPH_FEATURE_##name = (1ULL<<bit); \
14+
static const uint64_t CEPH_FEATUREMASK_##name = \
1515
(1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation);
1616

1717
/* this bit is ignored but still advertised by release *when* */
1818
#define DEFINE_CEPH_FEATURE_DEPRECATED(bit, incarnation, name, when) \
19-
const static uint64_t DEPRECATED_CEPH_FEATURE_##name = (1ULL<<bit); \
20-
const static uint64_t DEPRECATED_CEPH_FEATUREMASK_##name = \
19+
static const uint64_t DEPRECATED_CEPH_FEATURE_##name = (1ULL<<bit); \
20+
static const uint64_t DEPRECATED_CEPH_FEATUREMASK_##name = \
2121
(1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation);
2222

2323
/*

‎net/ceph/messenger.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,8 +3203,10 @@ static struct ceph_msg_data *ceph_msg_data_create(enum ceph_msg_data_type type)
32033203
return NULL;
32043204

32053205
data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS);
3206-
if (data)
3207-
data->type = type;
3206+
if (!data)
3207+
return NULL;
3208+
3209+
data->type = type;
32083210
INIT_LIST_HEAD(&data->links);
32093211

32103212
return data;

‎net/ceph/osd_client.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5310,7 +5310,10 @@ static int invalidate_authorizer(struct ceph_connection *con)
53105310

53115311
static void osd_reencode_message(struct ceph_msg *msg)
53125312
{
5313-
encode_request_finish(msg);
5313+
int type = le16_to_cpu(msg->hdr.type);
5314+
5315+
if (type == CEPH_MSG_OSD_OP)
5316+
encode_request_finish(msg);
53145317
}
53155318

53165319
static int osd_sign_message(struct ceph_msg *msg)

‎net/ceph/osdmap.c‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static void crush_finalize(struct crush_map *c)
338338
static struct crush_map *crush_decode(void *pbyval, void *end)
339339
{
340340
struct crush_map *c;
341-
int err = -EINVAL;
341+
int err;
342342
int i, j;
343343
void **p = &pbyval;
344344
void *start = pbyval;
@@ -407,7 +407,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
407407
size = sizeof(struct crush_bucket_straw2);
408408
break;
409409
default:
410-
err = -EINVAL;
411410
goto bad;
412411
}
413412
BUG_ON(size == 0);
@@ -439,31 +438,31 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
439438
err = crush_decode_uniform_bucket(p, end,
440439
(struct crush_bucket_uniform *)b);
441440
if (err < 0)
442-
goto bad;
441+
goto fail;
443442
break;
444443
case CRUSH_BUCKET_LIST:
445444
err = crush_decode_list_bucket(p, end,
446445
(struct crush_bucket_list *)b);
447446
if (err < 0)
448-
goto bad;
447+
goto fail;
449448
break;
450449
case CRUSH_BUCKET_TREE:
451450
err = crush_decode_tree_bucket(p, end,
452451
(struct crush_bucket_tree *)b);
453452
if (err < 0)
454-
goto bad;
453+
goto fail;
455454
break;
456455
case CRUSH_BUCKET_STRAW:
457456
err = crush_decode_straw_bucket(p, end,
458457
(struct crush_bucket_straw *)b);
459458
if (err < 0)
460-
goto bad;
459+
goto fail;
461460
break;
462461
case CRUSH_BUCKET_STRAW2:
463462
err = crush_decode_straw2_bucket(p, end,
464463
(struct crush_bucket_straw2 *)b);
465464
if (err < 0)
466-
goto bad;
465+
goto fail;
467466
break;
468467
}
469468
}
@@ -474,7 +473,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
474473
u32 yes;
475474
struct crush_rule *r;
476475

477-
err = -EINVAL;
478476
ceph_decode_32_safe(p, end, yes, bad);
479477
if (!yes) {
480478
dout("crush_decode NO rule %d off %x %p to %p\n",
@@ -489,7 +487,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
489487
/* len */
490488
ceph_decode_32_safe(p, end, yes, bad);
491489
#if BITS_PER_LONG == 32
492-
err = -EINVAL;
493490
if (yes > (ULONG_MAX - sizeof(*r))
494491
/ sizeof(struct crush_rule_step))
495492
goto bad;
@@ -557,7 +554,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
557554
if (*p != end) {
558555
err = decode_choose_args(p, end, c);
559556
if (err)
560-
goto bad;
557+
goto fail;
561558
}
562559

563560
done:
@@ -567,10 +564,14 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
567564

568565
badmem:
569566
err = -ENOMEM;
570-
bad:
567+
fail:
571568
dout("crush_decode fail %d\n", err);
572569
crush_destroy(c);
573570
return ERR_PTR(err);
571+
572+
bad:
573+
err = -EINVAL;
574+
goto fail;
574575
}
575576

576577
int ceph_pg_compare(const struct ceph_pg *lhs, const struct ceph_pg *rhs)
@@ -1399,7 +1400,7 @@ static struct ceph_pg_mapping *__decode_pg_upmap_items(void **p, void *end,
13991400
return ERR_PTR(-EINVAL);
14001401

14011402
ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval);
1402-
pg = kzalloc(sizeof(*pg) + 2 * len * sizeof(u32), GFP_NOIO);
1403+
pg = alloc_pg_mapping(2 * len * sizeof(u32));
14031404
if (!pg)
14041405
return ERR_PTR(-ENOMEM);
14051406

@@ -1544,7 +1545,7 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map)
15441545
if (struct_v >= 3) {
15451546
/* erasure_code_profiles */
15461547
ceph_decode_skip_map_of_map(p, end, string, string, string,
1547-
bad);
1548+
e_inval);
15481549
}
15491550

15501551
if (struct_v >= 4) {
@@ -1825,9 +1826,9 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
18251826
if (struct_v >= 3) {
18261827
/* new_erasure_code_profiles */
18271828
ceph_decode_skip_map_of_map(p, end, string, string, string,
1828-
bad);
1829+
e_inval);
18291830
/* old_erasure_code_profiles */
1830-
ceph_decode_skip_set(p, end, string, bad);
1831+
ceph_decode_skip_set(p, end, string, e_inval);
18311832
}
18321833

18331834
if (struct_v >= 4) {

0 commit comments

Comments
 (0)