Skip to content

cephfs: fix write_buf's _len overflow problem#13587

Merged
jcsp merged 1 commit intoceph:masterfrom
yanghonggang:master
Apr 15, 2017
Merged

cephfs: fix write_buf's _len overflow problem#13587
jcsp merged 1 commit intoceph:masterfrom
yanghonggang:master

Conversation

@yanghonggang
Copy link
Contributor

After I have set about 400 64KB xattr kv pair to a file,
mds is crashed. Every time I try to start mds, it will crash again.
The root reason is write_buf._len overflowed when doing
Journaler::append_entry().

This patch try to fix this problem through the following changes:

1. limit file/dir's xattr size
2. throttle journal entry append operations
3. add bufferlist _len overflow checking

Fixes: http://tracker.ceph.com/issues/19033
Signed-off-by: Yang Honggang joseph.yang@xtaotech.com

@yanghonggang
Copy link
Contributor Author

@jcsp Your comments and suggestions will be greatly appreciated.

@ukernel
Copy link
Contributor

ukernel commented Feb 23, 2017

please split the change into three commit. one for buffer.{h,cc}, one for Journaler.{h,cc} and one for Server.cc

@yanghonggang
Copy link
Contributor Author

@ukernel done!

@jcsp jcsp requested a review from ukernel March 8, 2017 11:20
@jcsp
Copy link
Contributor

jcsp commented Mar 8, 2017

@ukernel does this look good to you?

@liewegas liewegas added bug-fix cephfs Ceph File System labels Mar 8, 2017
@yanghonggang
Copy link
Contributor Author

@ukernel @jcsp please help to review. many thanks.

@yanghonggang
Copy link
Contributor Author

@liewegas @ukernel @jcsp @gregsfortytwo

Normal user of our fs can damage the whole system by writing huge xattr kv pairs. I think this is a serious bug. Your quick reply can help me to fix this bug as soon as possible. Thank you for your time to review this patch.

char* ptr = _raw->data + _off + _len;
*ptr = c;
_len++;
assert(_len != 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if these asserts are compiled conditionally, for full debug builds only. This is already performance sensitive path that affects everyone.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@branch-predictor

Yes, this will affect performance. I think assert can be disabled globally by specifing DCMAKE_CXX_FLAGS="-DNDEBUG ..." cmake variable. Any better suggestion?

@jcsp
Copy link
Contributor

jcsp commented Apr 12, 2017

The Server and Journaler commits look good. After chatting with @liewegas the consensus on the buffer.h asserts is that although we already have lots of asserts there, we probably don't want to add more.

If you could drop the buffer.h commit from this PR, it will be good to merge.

@yanghonggang
Copy link
Contributor Author

@jcsp @branch-predictor @ukernel
Thank you for your suggestions, buffer.h commit is dropped. And commits are squashed together.


// check xattrs kv pairs size
size_t cur_xattrs_size = 0;
for (map<string, bufferptr>::iterator p = pxattrs->begin();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd recommend use the range-based loop when possible.

int max_bytes = req->head.args.readdir.max_bytes;
if (!max_bytes)
max_bytes = 512 << 10;
max_bytes = (512 << 10) + g_conf->mds_max_xattr_pairs_size; // make sure at least one item can be encoded
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please wrap at 80 chars.

After I have set about 400 64KB xattr kv pair to a file,
mds is crashed. Every time I try to start mds, it will crash again.
The root reason is write_buf._len overflowed when doing
Journaler::append_entry().

This patch try to fix this problem through the following changes:

 1. limit file/dir's xattr size
 2. throttle journal entry append operations

Fixes: http://tracker.ceph.com/issues/19033
Signed-off-by: Yang Honggang joseph.yang@xtaotech.com
@yanghonggang
Copy link
Contributor Author

@tchaikov
all lines are wrapped at 80 characters and change for to range-based.

@jcsp jcsp merged commit c65e4fb into ceph:master Apr 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix cephfs Ceph File System

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants