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
rbd: bench-write should return error if io-size >= 4G #12864
Conversation
@@ -196,6 +196,10 @@ int do_bench(librbd::Image& image, io_type_t io_type, | |||
return -EINVAL; | |||
} | |||
|
|||
if (io_size > 4294967295) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 <=
There was a problem hiding this comment.
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>
3201c12
to
6ab73e5
Compare
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