librbd: readv/writev fix iovecs length computation overflow
iovec have unsigned length (size_t) and before this patch the
total length was computed by adding iovec's length to a signed
length variable (ssize_t). While the code checked if the resulting
length was negative on overflow, the case where length is positive
after overflow was not checked. This patch fixes the overflow check
by changing length to unsigned size_t.
Additionally, this patch fixes the case where some iovecs have been
added to the bufferlist and the aio completion has been blocked, but
adding an additional iovec fails because of overflow. This leads to
the UserBufferDeleter trying to unblock the completion on destruction
of the bufferlist but asserting because the completion was never
armed. We avoid this by first computing the total length and checking
for overflows and iovcnt before adding them to the bufferlist.
Signed-off-by: Jonas Pfefferle <pepperjo@japf.ch>
(cherry picked from commit
e50405ef857f487bc1c104bbf3e8859ea099a0c4)
Conflicts:
src/librbd/librbd.cc [ commit
b12b8c447a41 ("librbd: switch
to new api::Io dispatch helper methods") not in octopus ]