diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2023-08-24 16:32:21 +0100 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2023-09-18 14:36:13 +0800 |
commit | 2a6cb383e2ec7224d8631c3c0a324bff469c9c64 (patch) | |
tree | 59136aca4b3b7e33553e4c5aadb38b278d252adc /hw/net/rocker | |
parent | cb039ef3d9e3112da01e1ecd9b136ac9809ef733 (diff) | |
download | qemu-2a6cb383e2ec7224d8631c3c0a324bff469c9c64.zip qemu-2a6cb383e2ec7224d8631c3c0a324bff469c9c64.tar.gz qemu-2a6cb383e2ec7224d8631c3c0a324bff469c9c64.tar.bz2 |
hw/net/fsl_etsec/rings.c: Avoid variable length array
In fill_rx_bd() we create a variable length array of size
etsec->rx_padding. In fact we know that this will never be
larger than 64 bytes, because rx_padding is set in rx_init_frame()
in a way that ensures it is only that large. Use a fixed sized
array and assert that it is big enough.
Since padd[] is now potentially rather larger than the actual
padding required, adjust the memset() we do on it to match the
size that we write with cpu_physical_memory_write(), rather than
clearing the entire array.
The codebase has very few VLAs, and if we can get rid of them all we
can make the compiler error on new additions. This is a defensive
measure against security bugs where an on-stack dynamic allocation
isn't correctly size-checked (e.g. CVE-2021-3527).
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net/rocker')
0 files changed, 0 insertions, 0 deletions