Skip to content

Commit

Permalink
Merge tag 'ceph-for-4.12-rc3' of git://github.com/ceph/ceph-client
Browse files Browse the repository at this point in the history
Pul ceph fixes from Ilya Dryomov:
 "A bunch of make W=1 and static checker fixups, a RECONNECT_SEQ
  messenger patch from Zheng and Luis' fallocate fix"

* tag 'ceph-for-4.12-rc3' of git://github.com/ceph/ceph-client:
  ceph: check that the new inode size is within limits in ceph_fallocate()
  libceph: cleanup old messages according to reconnect seq
  libceph: NULL deref on crush_decode() error path
  libceph: fix error handling in process_one_ticket()
  libceph: validate blob_struct_v in process_one_ticket()
  libceph: drop version variable from ceph_monmap_decode()
  libceph: make ceph_msg_data_advance() return void
  libceph: use kbasename() and kill ceph_file_part()
  • Loading branch information
torvalds committed May 26, 2017
2 parents a38b461 + 42c99fc commit 80941b2
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 35 deletions.
6 changes: 5 additions & 1 deletion fs/ceph/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1671,8 +1671,12 @@ static long ceph_fallocate(struct file *file, int mode,
}

size = i_size_read(inode);
if (!(mode & FALLOC_FL_KEEP_SIZE))
if (!(mode & FALLOC_FL_KEEP_SIZE)) {
endoff = offset + length;
ret = inode_newsize_ok(inode, endoff);
if (ret)
goto unlock;
}

if (fi->fmode & CEPH_FILE_MODE_LAZY)
want = CEPH_CAP_FILE_BUFFER | CEPH_CAP_FILE_LAZYIO;
Expand Down
6 changes: 3 additions & 3 deletions include/linux/ceph/ceph_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/string.h>

#ifdef CONFIG_CEPH_LIB_PRETTYDEBUG

/*
Expand All @@ -12,12 +14,10 @@
*/

# if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
extern const char *ceph_file_part(const char *s, int len);
# define dout(fmt, ...) \
pr_debug("%.*s %12.12s:%-4d : " fmt, \
8 - (int)sizeof(KBUILD_MODNAME), " ", \
ceph_file_part(__FILE__, sizeof(__FILE__)), \
__LINE__, ##__VA_ARGS__)
kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
# else
/* faux printk call just to see any compiler warnings. */
# define dout(fmt, ...) do { \
Expand Down
13 changes: 8 additions & 5 deletions net/ceph/auth_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static int process_one_ticket(struct ceph_auth_client *ac,
struct timespec validity;
void *tp, *tpend;
void **ptp;
struct ceph_crypto_key new_session_key;
struct ceph_crypto_key new_session_key = { 0 };
struct ceph_buffer *new_ticket_blob;
unsigned long new_expires, new_renew_after;
u64 new_secret_id;
Expand Down Expand Up @@ -215,6 +215,9 @@ static int process_one_ticket(struct ceph_auth_client *ac,
dout(" ticket blob is %d bytes\n", dlen);
ceph_decode_need(ptp, tpend, 1 + sizeof(u64), bad);
blob_struct_v = ceph_decode_8(ptp);
if (blob_struct_v != 1)
goto bad;

new_secret_id = ceph_decode_64(ptp);
ret = ceph_decode_buffer(&new_ticket_blob, ptp, tpend);
if (ret)
Expand All @@ -234,13 +237,13 @@ static int process_one_ticket(struct ceph_auth_client *ac,
type, ceph_entity_type_name(type), th->secret_id,
(int)th->ticket_blob->vec.iov_len);
xi->have_keys |= th->service;

out:
return ret;
return 0;

bad:
ret = -EINVAL;
goto out;
out:
ceph_crypto_key_destroy(&new_session_key);
return ret;
}

static int ceph_x_proc_ticket_reply(struct ceph_auth_client *ac,
Expand Down
13 changes: 0 additions & 13 deletions net/ceph/ceph_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@ static const struct kernel_param_ops param_ops_supported_features = {
module_param_cb(supported_features, &param_ops_supported_features, NULL,
S_IRUGO);

/*
* find filename portion of a path (/foo/bar/baz -> baz)
*/
const char *ceph_file_part(const char *s, int len)
{
const char *e = s + len;

while (e != s && *(e-1) != '/')
e--;
return e;
}
EXPORT_SYMBOL(ceph_file_part);

const char *ceph_msg_type_name(int type)
{
switch (type) {
Expand Down
26 changes: 16 additions & 10 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,8 @@ static struct page *ceph_msg_data_next(struct ceph_msg_data_cursor *cursor,
* Returns true if the result moves the cursor on to the next piece
* of the data item.
*/
static bool ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor,
size_t bytes)
static void ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor,
size_t bytes)
{
bool new_piece;

Expand Down Expand Up @@ -1207,8 +1207,6 @@ static bool ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor,
new_piece = true;
}
cursor->need_crc = new_piece;

return new_piece;
}

static size_t sizeof_footer(struct ceph_connection *con)
Expand Down Expand Up @@ -1577,7 +1575,6 @@ static int write_partial_message_data(struct ceph_connection *con)
size_t page_offset;
size_t length;
bool last_piece;
bool need_crc;
int ret;

page = ceph_msg_data_next(cursor, &page_offset, &length,
Expand All @@ -1592,7 +1589,7 @@ static int write_partial_message_data(struct ceph_connection *con)
}
if (do_datacrc && cursor->need_crc)
crc = ceph_crc32c_page(crc, page, page_offset, length);
need_crc = ceph_msg_data_advance(cursor, (size_t)ret);
ceph_msg_data_advance(cursor, (size_t)ret);
}

dout("%s %p msg %p done\n", __func__, con, msg);
Expand Down Expand Up @@ -2231,10 +2228,18 @@ static void process_ack(struct ceph_connection *con)
struct ceph_msg *m;
u64 ack = le64_to_cpu(con->in_temp_ack);
u64 seq;
bool reconnect = (con->in_tag == CEPH_MSGR_TAG_SEQ);
struct list_head *list = reconnect ? &con->out_queue : &con->out_sent;

while (!list_empty(&con->out_sent)) {
m = list_first_entry(&con->out_sent, struct ceph_msg,
list_head);
/*
* In the reconnect case, con_fault() has requeued messages
* in out_sent. We should cleanup old messages according to
* the reconnect seq.
*/
while (!list_empty(list)) {
m = list_first_entry(list, struct ceph_msg, list_head);
if (reconnect && m->needs_out_seq)
break;
seq = le64_to_cpu(m->hdr.seq);
if (seq > ack)
break;
Expand All @@ -2243,6 +2248,7 @@ static void process_ack(struct ceph_connection *con)
m->ack_stamp = jiffies;
ceph_msg_remove(m);
}

prepare_read_tag(con);
}

Expand Down Expand Up @@ -2299,7 +2305,7 @@ static int read_partial_msg_data(struct ceph_connection *con)

if (do_datacrc)
crc = ceph_crc32c_page(crc, page, page_offset, ret);
(void) ceph_msg_data_advance(cursor, (size_t)ret);
ceph_msg_data_advance(cursor, (size_t)ret);
}
if (do_datacrc)
con->in_data_crc = crc;
Expand Down
4 changes: 1 addition & 3 deletions net/ceph/mon_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
int i, err = -EINVAL;
struct ceph_fsid fsid;
u32 epoch, num_mon;
u16 version;
u32 len;

ceph_decode_32_safe(&p, end, len, bad);
ceph_decode_need(&p, end, len, bad);

dout("monmap_decode %p %p len %d\n", p, end, (int)(end-p));

ceph_decode_16_safe(&p, end, version, bad);
p += sizeof(u16); /* skip version */

ceph_decode_need(&p, end, sizeof(fsid) + 2*sizeof(u32), bad);
ceph_decode_copy(&p, &fsid, sizeof(fsid));
Expand Down
1 change: 1 addition & 0 deletions net/ceph/osdmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
u32 yes;
struct crush_rule *r;

err = -EINVAL;
ceph_decode_32_safe(p, end, yes, bad);
if (!yes) {
dout("crush_decode NO rule %d off %x %p to %p\n",
Expand Down

0 comments on commit 80941b2

Please sign in to comment.