qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] util/iov: Do not assert offset is in iov
@ 2024-04-28 11:11 Akihiko Odaki
  2024-04-28 11:11 ` [PATCH 1/2] " Akihiko Odaki
  2024-04-28 11:11 ` [PATCH 2/2] Revert "hw/net/net_tx_pkt: Fix overrun in update_sctp_checksum()" Akihiko Odaki
  0 siblings, 2 replies; 7+ messages in thread
From: Akihiko Odaki @ 2024-04-28 11:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Dmitry Fleytman, Jason Wang
  Cc: qemu-devel, Akihiko Odaki

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.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
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,
-- 
Akihiko Odaki <akihiko.odaki@daynix.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-13  3:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-28 11:11 [PATCH 0/2] util/iov: Do not assert offset is in iov Akihiko Odaki
2024-04-28 11:11 ` [PATCH 1/2] " Akihiko Odaki
2024-05-08 14:51   ` Philippe Mathieu-Daudé
2025-01-11  5:10     ` Akihiko Odaki
2025-01-13  3:01       ` Jason Wang
2024-04-28 11:11 ` [PATCH 2/2] Revert "hw/net/net_tx_pkt: Fix overrun in update_sctp_checksum()" Akihiko Odaki
2024-04-28 19:45   ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).