Skip to content

util/iov: Do not assert offset is in iov

Akihiko Odaki qemu-devel 1 version In review

Get series with b4
b4 am [email protected] change-id 20240428-iov-a317b02601dc

Versions newest first

  1. v1 Latest2 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2util/iov: Do not assert offset is in iovinclude/qemu/iov.h util/iov.c+3 -73 replies
2/2Revert "hw/net/net_tx_pkt: Fix overrun in update_sctp_checksum()"hw/net/net_tx_pkt.c+0 -41 reply

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchPhilippe Mathieu-Daudé
1/2
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] util/iov: Do not assert offset is in iov

iov_from_buf(), iov_to_buf(), iov_memset(), and iov_copy() asserts that the given offset fits in the iov while tolerating the specified number of bytes to operate with to be greater than the size of iov. This is inconsistent so remove the assertions.

Asserting the offset fits in the iov makes sense if it is expected that there are other operations that process the content before the offset and the content is processed in order. Under this expectation, the offset should point to the end of bytes that are previously processed and fit in the iov. However, this expectation depends on the details of the caller, and did not hold true at least one case and required code to check iov_size(), which is added with commit 83ddb3dbba2e ("hw/net/net_tx_pkt: Fix overrun in update_sctp_checksum()").

Adding such a check is inefficient and error-prone. These functions already tolerate the specified number of bytes to operate with to be greater than the size of iov to avoid such checks so remove the assertions to tolerate invalid offset as well. They return the number of bytes they operated with so their callers can still check the returned value to ensure there are sufficient space at the given offset.

---
Akihiko Odaki (2):
util/iov: Do not assert offset is in iov
Revert "hw/net/net_tx_pkt: Fix overrun in update_sctp_checksum()"

 include/qemu/iov.h  | 5 +++--
 hw/net/net_tx_pkt.c | 4 ----
 util/iov.c          | 5 -----
 3 files changed, 3 insertions(+), 11 deletions(-)

---
base-commit: fd87be1dada5672f877e03c2ca8504458292c479
change-id: 20240428-iov-a317b02601dc

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>