linux/drivers/comedi
Ian Abbott 64b24b713e comedi: me4000: Fix potential overrun of firmware buffer
commit 3fb43a7a5b upstream.

`me4000_xilinx_download()` loads the firmware that was requested by
`request_firmware()`.  It is possible for it to overrun the source
buffer because it blindly trusts the file format.  It reads a data
stream length from the first 4 bytes into variable `file_length` and
reads the data stream contents of length `file_length` from offset 16
onwards.

Add a test to ensure that the supplied firmware is long enough to
contain the header and the data stream.  On failure, log an error and
return `-EINVAL`.

Note: The firmware loading was totally broken before commit ac584af599
("staging: comedi: me4000: fix firmware downloading"), but that is the
most sensible target for this fix.

Fixes: ac584af599 ("staging: comedi: me4000: fix firmware downloading")
Cc: stable <stable@kernel.org>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://patch.msgid.link/20260205133949.71722-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-04-18 10:33:34 +02:00
..
drivers comedi: me4000: Fix potential overrun of firmware buffer 2026-04-18 10:33:34 +02:00
kcomedilib staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
comedi.h comedi: Fix getting range information for subdevices 16 to 255 2026-02-06 16:42:01 +01:00
comedi_buf.c comedi: fix divide-by-zero in comedi_buf_munge() 2025-10-29 14:03:12 +01:00
comedi_fops.c comedi: Fix getting range information for subdevices 16 to 255 2026-02-06 16:42:01 +01:00
comedi_internal.h comedi: fix race between polling and detaching 2025-08-28 16:24:26 +02:00
comedi_pci.c staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
comedi_pci.h staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
comedi_pcmcia.c staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
comedi_pcmcia.h staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
comedi_usb.c staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
comedi_usb.h staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
comedidev.h staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
comedilib.h staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
drivers.c comedi: Reinit dev->spinlock between attachments to low-level drivers 2026-04-18 10:33:34 +02:00
Kconfig staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
Makefile staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
proc.c staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00
range.c comedi: Fix getting range information for subdevices 16 to 255 2026-02-06 16:42:01 +01:00
TODO staging: comedi: move out of staging directory 2021-04-15 09:26:25 +02:00