]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
librbd: readv/writev fix iovecs length computation overflow 45353/head
authorJonas Pfefferle <pepperjo@japf.ch>
Wed, 9 Mar 2022 13:26:42 +0000 (14:26 +0100)
committerJonas Pfefferle <pepperjo@japf.ch>
Fri, 18 Mar 2022 08:26:48 +0000 (09:26 +0100)
commite50405ef857f487bc1c104bbf3e8859ea099a0c4
tree0d45704d9d5d8388dbdf0c1820f9bdf509a2f200
parent1af515da6d433dc9d154facd7e0c7300cb621ece
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>
src/librbd/librbd.cc
src/test/librbd/test_librbd.cc