The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v3 0/2] vfio: selftests: Add calloc_assert() and avoid VLAs
@ 2026-06-15 19:44 Alex Mastro
  2026-06-15 19:44 ` [PATCH v3 1/2] vfio: selftests: Add calloc_assert() helper Alex Mastro
  2026-06-15 19:44 ` [PATCH v3 2/2] vfio: selftests: Avoid VLAs Alex Mastro
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Mastro @ 2026-06-15 19:44 UTC (permalink / raw)
  To: Alex Williamson, David Matlack, Shuah Khan,
	Raghavendra Rao Ananta, Vipin Sharma
  Cc: kvm, linux-kselftest, linux-kernel, Shuah Khan, Alex Mastro

Add a VFIO selftest calloc_assert() helper, then use it in places that
open-code calloc() or malloc() followed by VFIO_ASSERT_NOT_NULL().

Use that helper to replace initialized variable-length stack buffers in
vfio_pci_device.c with heap allocations. This avoids GCC rejecting
initialized VLAs and avoids treating a u8 buffer as a possibly
under-aligned VFIO request struct.

Changes in v3:
- Add the calloc_assert() helper as a precursor patch.
- Convert existing VFIO selftest calloc() assertion sites.
- Update the VLA fix to use calloc_assert().
- Link to v2: https://patch.msgid.link/20260615-scratch-amastro-vfio-selftests-avoid-vlas-v2-1-4e4df462908a@fb.com

Changes in v2:
- Reverse xmas tree variable ordering
- Link to v1: https://patch.msgid.link/20260612-scratch-amastro-vfio-selftests-avoid-vlas-v1-1-ba3acb635f0a@fb.com

Signed-off-by: Alex Mastro <amastro@fb.com>
---
Alex Mastro (2):
      vfio: selftests: Add calloc_assert() helper
      vfio: selftests: Avoid VLAs

 .../selftests/vfio/lib/include/libvfio/assert.h    | 10 +++++++
 tools/testing/selftests/vfio/lib/iommu.c           | 12 +++-----
 tools/testing/selftests/vfio/lib/iova_allocator.c  |  4 +--
 tools/testing/selftests/vfio/lib/sysfs.c           |  3 +-
 tools/testing/selftests/vfio/lib/vfio_pci_device.c | 32 ++++++++++++----------
 .../vfio/vfio_pci_device_init_perf_test.c          |  4 +--
 6 files changed, 35 insertions(+), 30 deletions(-)
---
base-commit: a26b499b757cfc8bbff1088bb1b844639e250893
change-id: 20260612-scratch-amastro-vfio-selftests-avoid-vlas-395eb3dcb3ab

Best regards,
--  
Alex Mastro <amastro@fb.com>


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

end of thread, other threads:[~2026-06-15 22:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 19:44 [PATCH v3 0/2] vfio: selftests: Add calloc_assert() and avoid VLAs Alex Mastro
2026-06-15 19:44 ` [PATCH v3 1/2] vfio: selftests: Add calloc_assert() helper Alex Mastro
2026-06-15 22:51   ` David Matlack
2026-06-15 19:44 ` [PATCH v3 2/2] vfio: selftests: Avoid VLAs Alex Mastro
2026-06-15 22:56   ` David Matlack

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox