New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbd: bench-write should return error if io-size >= 4G #12864

Merged
merged 1 commit into from Jan 12, 2017

Conversation

Projects
None yet
4 participants
@gaurav36
Contributor

gaurav36 commented Jan 10, 2017

Currently if user perform bench-write with io-size > 4G
then its crashing because currently during memory allocation
bufferptr taking size of buffer as a unsigned and io-size > 4G
will overflow with unsigned. so during memset operation it will
try to set io_size size of memory area pointed by bufferptr,
(bufferptr area is: (4G - io_size)), so it will cause
segmentation fault.

Fix is to return error if io-size >= 4G

Fixes: http://tracker.ceph.com/issues/18422

Reported-by: Jason Dillaman dillaman@redhat.com
Signed-off-by: Gaurav Kumar Garg garg.gaurav52@gmail.com

@@ -196,6 +196,10 @@ int do_bench(librbd::Image& image, io_type_t io_type,
return -EINVAL;
}
if (io_size > 4294967295) {

This comment has been minimized.

@dillaman

dillaman Jan 10, 2017

Contributor

Nit: if (io_size > 0xFFFFFFFF) is more readable

This comment has been minimized.

@gaurav36

gaurav36 Jan 10, 2017

Contributor

thank you :), will do it in next PR

This comment has been minimized.

@wjwithagen

wjwithagen Jan 10, 2017

Contributor

@dillaman @gaurav36
Why not use defined constant: INT32_MAX

This comment has been minimized.

@dillaman

dillaman Jan 10, 2017

Contributor

Even better -- or the C++ std::numeric_limits<uint32_t>::max()

This comment has been minimized.

@gaurav36

gaurav36 Jan 10, 2017

Contributor

yeah, std::numeric_limits<uint32_t>::max() is better. will use in next PR

@@ -196,6 +196,10 @@ int do_bench(librbd::Image& image, io_type_t io_type,
return -EINVAL;
}
if (io_size > 4294967295) {
std::cerr << "rbd: io-size should be less than 4G" << std::endl;

This comment has been minimized.

@dillaman

dillaman Jan 10, 2017

Contributor

Nit: ... should not exceed 4G since it can be <=

This comment has been minimized.

@gaurav36

gaurav36 Jan 10, 2017

Contributor

it can be < but i can not be <=, because 4G is overflowing. 4G=4294967296 and after overflow value (unsigned l) will become 0. so i think io-size should be less than 4G

rbd: bench-write should return error if io-size >= 4G
Currently if user perform bench-write with io-size > 4G
then its crashing because currently during memory allocation
bufferptr taking size of buffer as a unsigned and io-size > 4G
will overflow with unsigned. so during memset operation it will
try to set io_size size of memory area pointed by bufferptr,
(bufferptr area is:  (4G - io_size)), so it will cause
segmentation fault.

Fix is to return error if io-size >= 4G

Fixes: http://tracker.ceph.com/issues/18422

Reported-by:  Jason Dillaman <dillaman@redhat.com>
Signed-off-by: Gaurav Kumar Garg <garg.gaurav52@gmail.com>

@tchaikov tchaikov added the rbd label Jan 10, 2017

@dillaman dillaman added the bug fix label Jan 10, 2017

@dillaman dillaman merged commit 59d0207 into ceph:master Jan 12, 2017

3 checks passed

Signed-off-by all commits in this PR are signed
Details
Unmodifed Submodules submodules for project are unmodified
Details
default Build finished.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment