linux/drivers/media
Gustavo A. R. Silva 4c99885d59 media: venus: hfi_cmds: Replace one-element array with flex-array member and use __counted_by
Array `data` in `struct hfi_sfr` is being used as a fake flexible array
at run-time:

drivers/media/platform/qcom/venus/hfi_venus.c:
1033         p = memchr(sfr->data, '\0', sfr->buf_size);
1034         /*
1035          * SFR isn't guaranteed to be NULL terminated since SYS_ERROR indicates
1036          * that Venus is in the process of crashing.
1037          */
1038         if (!p)
1039                 sfr->data[sfr->buf_size - 1] = '\0';
1040
1041         dev_err_ratelimited(dev, "SFR message from FW: %s\n", sfr->data);

Fake flexible arrays are deprecated, and should be replaced by
flexible-array members. So, replace one-element array with a
flexible-array member in `struct hfi_sfr`.

While there, also annotate array `data` with __counted_by() to prepare
for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

This results in no differences in binary output.

This issue was found with the help of Coccinelle, and audited and fixed
manually.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2023-10-23 12:24:52 +02:00
..
cec media: cec: meson: always include meson sub-directory in Makefile 2023-10-13 11:33:22 +02:00
common media: videobuf2: Fix IS_ERR checking in vb2_dc_put_userptr() 2023-10-13 11:33:22 +02:00
dvb-core lib/math: Move dvb_math.c into lib/math/int_log.c 2023-07-09 22:47:48 +01:00
dvb-frontends media: dvb-frontends: drop check because i2c_unregister_device() is NULL safe 2023-10-07 10:55:46 +02:00
firewire media: firewire: firedtv-avc.c: replace BUG with proper, error return 2023-08-10 07:58:37 +02:00
i2c media: i2c: adp1653: don't reuse the same node pointer 2023-10-12 10:12:54 +02:00
mc media: mc: Check pad flag validity 2023-10-07 10:55:48 +02:00
mmc
pci media: pci: cx18: if cx == NULL, then don't use it. 2023-10-13 11:33:22 +02:00
platform media: venus: hfi_cmds: Replace one-element array with flex-array member and use __counted_by 2023-10-23 12:24:52 +02:00
radio media: radio-si476x: don't fill in bus_info 2023-09-27 10:47:23 +02:00
rc media: lirc: drop trailing space from scancode transmit 2023-10-11 16:26:16 +02:00
spi
test-drivers media: vidtv: mux: Add check and kfree for kstrdup 2023-10-07 10:55:45 +02:00
tuners media: dvb: symbol fixup for dvb_attach() 2023-09-09 08:15:11 +01:00
usb media: cx231xx: Use EP5_BUF_SIZE macro 2023-10-13 11:33:22 +02:00
v4l2-core media: v4l: subdev: Print debug information on frame descriptor 2023-10-07 10:55:48 +02:00
Kconfig media: Kconfig: Make DVB_CORE=m possible when MEDIA_SUPPORT=y 2022-12-07 17:58:46 +01:00
Makefile