]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: bench-write should return error if io-size >= 4G 13129/head
authorGaurav Kumar Garg <garg.gaurav52@gmail.com>
Tue, 10 Jan 2017 14:25:13 +0000 (15:25 +0100)
committerNathan Cutler <ncutler@suse.com>
Thu, 26 Jan 2017 10:42:13 +0000 (11:42 +0100)
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>
(cherry picked from commit 6ab73e5f420e89e19b52e39dab28fa4c94e00197)

Conflicts:
src/tools/rbd/action/BenchWrite.cc - jewel has rbd_bencher b(&image)
            while in master this has become rbd_bencher b(&image, io_type,
            io_size)

src/tools/rbd/action/BenchWrite.cc

index c012708896b8e21a3ab1920caed5624eac89b51d..47077c20fd8699820dccd0dceb64e70b61430c71 100644 (file)
@@ -126,6 +126,11 @@ int do_bench_write(librbd::Image& image, uint64_t io_size,
     return -EINVAL;
   }
 
+  if (io_size > std::numeric_limits<uint32_t>::max()) {
+    std::cerr << "rbd: io-size should be less than 4G" << std::endl;
+    return -EINVAL;
+  }
+
   rbd_bencher b(&image);
 
   std::cout << "bench-write "