Skip to content
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

Conversation

gaurav36
Copy link
Contributor

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) {

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you :), will do it in next PR

Copy link
Contributor

Choose a reason for hiding this comment

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

@dillaman @gaurav36
Why not use defined constant: INT32_MAX

Copy link

@dillaman dillaman Jan 10, 2017

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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;

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

@gaurav36 gaurav36 Jan 10, 2017

Choose a reason for hiding this comment

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

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

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>
@gaurav36 gaurav36 force-pushed the bug-18422-rbd-bench-write-crash-4G-io-size branch from 3201c12 to 6ab73e5 Compare January 10, 2017 15:04
@tchaikov tchaikov added the rbd label Jan 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants