Bug #47210
openlibrbd:rbd.OSError: [errno 2147483648] error reading myimage 0~2147483648
0%
Description
rbd.pyx will report error "librbd:rbd.OSError: [errno 2147483648] error reading..." when we try to read
2GB+ data from an image. the test case to reproduce is
https://pastebin.ubuntu.com/p/qBhhDFB6wf/
In this test case I first created a 5GB image, then tried to read 2GB from it via image.read(0, 2 * 1024**3)
but it report above error message, it is fine if I change the length to 2GB -1.
The issue here is because of the integer overflow.
https://github.com/ceph/ceph/blob/luminous/src/librbd/librbd.cc#L3356
As we can see from above line of code, it is using integer r to store a return value that could be ssize_t (64 bit),
But it's not the only place that is wrong, if we chase deeper, we'll find C_Safer_cond's rval is an "int", but we
are using it to store the total bytes that being read by rbd client for one rbd read operation, and the total bytes could
exceeds the maximum "int" value when we specify the read length >= 2GB.
This is preventing user to read a >=2GB length data at one time, eg. when cinder-backup want to read 2GB chunk at a time.