Re: [PATCH 0/4] system: Forbid alloca()
On 5/6/25 21:35, Philippe Mathieu-Daudé wrote: Eradicate alloca() uses on system code, then enable -Walloca to prevent new ones to creep back in. Philippe Mathieu-Daudé (4): hw/gpio/pca9552: Avoid using g_newa() backends/tpmL Avoid using g_alloca() tests/unit/test-char: Avoid using g_alloca() Patches 1-3 queued.
Re: [PATCH 0/4] system: Forbid alloca()
On Thu, Jun 05, 2025 at 09:35:36PM +0200, Philippe Mathieu-Daudé wrote: > Eradicate alloca() uses on system code, then enable > -Walloca to prevent new ones to creep back in. > > Philippe Mathieu-Daudé (4): > hw/gpio/pca9552: Avoid using g_newa() > backends/tpmL Avoid using g_alloca() > tests/unit/test-char: Avoid using g_alloca() > buildsys: Prohibit alloca() use on system code > > meson.build | 4 > backends/tpm/tpm_emulator.c | 4 ++-- > hw/gpio/pca9552.c | 2 +- > tests/unit/test-char.c | 3 +-- > 4 files changed, 8 insertions(+), 5 deletions(-) Modulo the comments that have already been discussed: Reviewed-by: Stefan Hajnoczi signature.asc Description: PGP signature
Re: [PATCH 0/4] system: Forbid alloca()
Philippe Mathieu-Daudé writes: > Eradicate alloca() uses on system code, then enable > -Walloca to prevent new ones to creep back in. Should we also mention it in style.rst: Use of the ``malloc/free/realloc/calloc/valloc/memalign/posix_memalign`` APIs is not allowed in the QEMU codebase. Instead of these routines, > > Philippe Mathieu-Daudé (4): > hw/gpio/pca9552: Avoid using g_newa() > backends/tpmL Avoid using g_alloca() > tests/unit/test-char: Avoid using g_alloca() > buildsys: Prohibit alloca() use on system code > > meson.build | 4 > backends/tpm/tpm_emulator.c | 4 ++-- > hw/gpio/pca9552.c | 2 +- > tests/unit/test-char.c | 3 +-- > 4 files changed, 8 insertions(+), 5 deletions(-) -- Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH 0/4] system: Forbid alloca()
On 6/6/25 10:37, Peter Maydell wrote: On Thu, 5 Jun 2025 at 20:35, Philippe Mathieu-Daudé wrote: Eradicate alloca() uses on system code, then enable -Walloca to prevent new ones to creep back in. Philippe Mathieu-Daudé (4): hw/gpio/pca9552: Avoid using g_newa() backends/tpmL Avoid using g_alloca() tests/unit/test-char: Avoid using g_alloca() buildsys: Prohibit alloca() use on system code meson.build | 4 backends/tpm/tpm_emulator.c | 4 ++-- hw/gpio/pca9552.c | 2 +- tests/unit/test-char.c | 3 +-- 4 files changed, 8 insertions(+), 5 deletions(-) There is also a use of alloca() in target/ppc/kvm.c in kvmppc_load_htab_chunk(), so I suspect that patch 4 here will break compilation on PPC hosts with KVM enabled. Oops sorry I missed that one :/
Re: [PATCH 0/4] system: Forbid alloca()
On Thu, 5 Jun 2025 at 20:35, Philippe Mathieu-Daudé wrote: > > Eradicate alloca() uses on system code, then enable > -Walloca to prevent new ones to creep back in. > > Philippe Mathieu-Daudé (4): > hw/gpio/pca9552: Avoid using g_newa() > backends/tpmL Avoid using g_alloca() > tests/unit/test-char: Avoid using g_alloca() > buildsys: Prohibit alloca() use on system code > > meson.build | 4 > backends/tpm/tpm_emulator.c | 4 ++-- > hw/gpio/pca9552.c | 2 +- > tests/unit/test-char.c | 3 +-- > 4 files changed, 8 insertions(+), 5 deletions(-) There is also a use of alloca() in target/ppc/kvm.c in kvmppc_load_htab_chunk(), so I suspect that patch 4 here will break compilation on PPC hosts with KVM enabled. thanks -- PMM
Re: [PATCH 0/4] system: Forbid alloca()
On 6/5/25 12:35 PM, Philippe Mathieu-Daudé wrote: Eradicate alloca() uses on system code, then enable -Walloca to prevent new ones to creep back in. Philippe Mathieu-Daudé (4): hw/gpio/pca9552: Avoid using g_newa() backends/tpmL Avoid using g_alloca() tests/unit/test-char: Avoid using g_alloca() buildsys: Prohibit alloca() use on system code meson.build | 4 backends/tpm/tpm_emulator.c | 4 ++-- hw/gpio/pca9552.c | 2 +- tests/unit/test-char.c | 3 +-- 4 files changed, 8 insertions(+), 5 deletions(-) Good idea! For the series: Reviewed-by: Pierrick Bouvier
