All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Fix use-after-free and make format overflow more difficult
@ 2026-03-04  6:28 Akihiko Odaki
  2026-03-04  6:28 ` [PATCH v3 1/4] contrib/elf2dmp: Grow PDB URL buffer Akihiko Odaki
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Akihiko Odaki @ 2026-03-04  6:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: Viktor Prutyanov, Alex Williamson, Cédric Le Goater,
	Markus Armbruster, Michael Roth, Paolo Bonzini,
	Marc-André Lureau, Daniel P. Berrangé,
	Philippe Mathieu-Daudé, Keith Busch, Klaus Jensen,
	Jesper Devantier, qemu-block, Akihiko Odaki, Alex Williamson

nvme-ns has a use-after-free of a formatted string, so fix it by
embedding a fixed-length buffer to the object. Embedding a buffer lets
me avoid a chore to add a function to call g_free().

But I don't want to worry about a buffer overflow, so let the compiler
check that the buffer won't overflow; C is so restrictive that it cannot
enforce the existence of g_free(). Compilers can check the length of
formatted string on the other hand.

Then GCC started complaining about buffer overflow, so let's treat them.
Fortunately, the potential buffer overflows it detected are not
user-facing or very subtle. Treating them by growing buffers can improve
robustness with practically no cost.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
Changes in v3:
- Changed to avoid sprintf() with "%.6f" in tests.
- Replaced the message of patch "vfio/pci: Grow buffer in
  vfio_pci_host_match()" with a improved version by Alex Williamson.
- Link to v2: https://lore.kernel.org/qemu-devel/20260302-nvme-v2-0-37ad8b5788c3@rsg.ci.i.u-tokyo.ac.jp

Changes in v2:
- Rebased.
- Changed to use g_strdup_printf() in patch
  "contrib/elf2dmp: Grow PDB URL buffer".
- Link to v1: https://lore.kernel.org/qemu-devel/20260125-nvme-v1-0-0658c31fade9@rsg.ci.i.u-tokyo.ac.jp

---
Akihiko Odaki (4):
      contrib/elf2dmp: Grow PDB URL buffer
      vfio/pci: Grow buffer in vfio_pci_host_match()
      tests: Avoid sprintf() with "%.6f"
      meson: Add -Wformat-overflow=2

 meson.build                              |  1 +
 contrib/elf2dmp/main.c                   | 32 +++++++++++++++-----------------
 hw/vfio/pci.c                            |  2 +-
 tests/unit/test-qobject-input-visitor.c  |  8 ++------
 tests/unit/test-qobject-output-visitor.c |  7 ++-----
 5 files changed, 21 insertions(+), 29 deletions(-)
---
base-commit: afe653676dc6dfd49f0390239ff90b2f0052c2b8
change-id: 20260125-nvme-b4661e0a409e

Best regards,
--  
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>



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

end of thread, other threads:[~2026-03-04  9:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04  6:28 [PATCH v3 0/4] Fix use-after-free and make format overflow more difficult Akihiko Odaki
2026-03-04  6:28 ` [PATCH v3 1/4] contrib/elf2dmp: Grow PDB URL buffer Akihiko Odaki
2026-03-04  6:28 ` [PATCH v3 2/4] vfio/pci: Grow buffer in vfio_pci_host_match() Akihiko Odaki
2026-03-04  6:28 ` [PATCH v3 3/4] tests: Avoid sprintf() with "%.6f" Akihiko Odaki
2026-03-04  9:59   ` Markus Armbruster
2026-03-04  6:28 ` [PATCH v3 4/4] meson: Add -Wformat-overflow=2 Akihiko Odaki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.