All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Fix use-after-free and make format overflow more difficult
@ 2026-03-02  7:48 Akihiko Odaki
  2026-03-02  7:48 ` [PATCH v2 1/4] contrib/elf2dmp: Grow PDB URL buffer Akihiko Odaki
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Akihiko Odaki @ 2026-03-02  7:48 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

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 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: Grow buffers for double string
      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  |  2 +-
 tests/unit/test-qobject-output-visitor.c |  2 +-
 5 files changed, 19 insertions(+), 20 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] 9+ messages in thread

end of thread, other threads:[~2026-03-02 19:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02  7:48 [PATCH v2 0/4] Fix use-after-free and make format overflow more difficult Akihiko Odaki
2026-03-02  7:48 ` [PATCH v2 1/4] contrib/elf2dmp: Grow PDB URL buffer Akihiko Odaki
2026-03-02  7:48 ` [PATCH v2 2/4] vfio/pci: Grow buffer in vfio_pci_host_match() Akihiko Odaki
2026-03-02 18:59   ` Alex Williamson
2026-03-02  7:48 ` [PATCH v2 3/4] tests: Grow buffers for double string Akihiko Odaki
2026-03-02 11:52   ` Markus Armbruster
2026-03-02 11:57     ` Daniel P. Berrangé
2026-03-02 12:54       ` Akihiko Odaki
2026-03-02  7:48 ` [PATCH v2 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.