summary refs log tree commit diff stats
path: root/include/standard-headers/linux/fuse.h
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2023-08-11 18:47:50 +0100
committerKlaus Jensen <k.jensen@samsung.com>2023-09-12 16:17:05 +0200
commitb02c2a85a6c8e5ecc1bfca1ef794b5897c9ebad3 (patch)
tree5d888137ea529ae87029b3d0cd9f39cb9e7d26eb /include/standard-headers/linux/fuse.h
parent9ef497755afc252fb8e060c9ea6b0987abfd20b6 (diff)
downloadfocaccia-qemu-b02c2a85a6c8e5ecc1bfca1ef794b5897c9ebad3.tar.gz
focaccia-qemu-b02c2a85a6c8e5ecc1bfca1ef794b5897c9ebad3.zip
hw/nvme: Use #define to avoid variable length array
In nvme_map_sgl() we create an array segment[] whose size is the
'const int SEG_CHUNK_SIZE'.  Since this is C, rather than C++, a
"const int foo" is not a true constant, it's merely a variable with a
constant value, and so semantically segment[] is a variable-length
array.  Switch SEG_CHUNK_SIZE to a #define so that we can make the
segment[] array truly fixed-size, in the sense that it doesn't
trigger the -Wvla warning.

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).

[PMM: rebased (function has moved file), expand commit message
 based on discussion from previous version of patch]

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Diffstat (limited to 'include/standard-headers/linux/fuse.h')
0 files changed, 0 insertions, 0 deletions