Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

octopus: librbd: readv/writev fix iovecs length computation overflow #45560

Merged
merged 1 commit into from May 16, 2022

Conversation

idryomov
Copy link
Contributor

Backport #45353 to octopus.

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 e50405e)

Conflicts:
	src/librbd/librbd.cc [ commit b12b8c4 ("librbd: switch
	  to new api::Io dispatch helper methods") not in octopus ]
@idryomov
Copy link
Contributor Author

make check mgr-dashboard-frontend-unittests failure is unrelated.

@yuriw
Copy link
Contributor

yuriw commented May 11, 2022

jenkins test make check

@yuriw yuriw merged commit 43087f5 into ceph:octopus May 16, 2022
@idryomov idryomov deleted the wip-readv-writev-overflow-octopus branch July 4, 2022 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants