From: Gaurav Kumar Garg Date: Tue, 10 Jan 2017 14:25:13 +0000 (+0100) Subject: rbd: bench-write should return error if io-size >= 4G X-Git-Tag: v12.0.0~216^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F12864%2Fhead;p=ceph.git 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 Signed-off-by: Gaurav Kumar Garg --- diff --git a/src/tools/rbd/action/Bench.cc b/src/tools/rbd/action/Bench.cc index 3df08c9bde1e..757b9f477f21 100644 --- a/src/tools/rbd/action/Bench.cc +++ b/src/tools/rbd/action/Bench.cc @@ -196,6 +196,11 @@ int do_bench(librbd::Image& image, io_type_t io_type, return -EINVAL; } + if (io_size > std::numeric_limits::max()) { + std::cerr << "rbd: io-size should be less than 4G" << std::endl; + return -EINVAL; + } + rbd_bencher b(&image, io_type, io_size); std::cout << "bench "