Message ID | 20250605193540.59874-1-philmd@linaro.org |
---|---|
Headers | show |
Series | system: Forbid alloca() | expand |
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 <pierrick.bouvier@linaro.org>
On Thu, 5 Jun 2025 at 20:35, Philippe Mathieu-Daudé <philmd@linaro.org> 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
Philippe Mathieu-Daudé <philmd@linaro.org> 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(-)
On 6/6/25 10:37, Peter Maydell wrote: > On Thu, 5 Jun 2025 at 20:35, Philippe Mathieu-Daudé <philmd@linaro.org> 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 :/