media: siano: Drop responses shorter than the message header
Subsystems (3)
PATCH 1/1 media: siano: Drop responses shorter than the message header
smsusb and smssdio set cb->size from the msg_length field that the device sends. Nothing checks that msg_length covers the 8-byte message header. For MSG_SMS_DVBT_BDA_DATA, smsdvb_onresponse() passes cb->size - sizeof(struct sms_msg_hdr) to dvb_dmx_swfilter(). A msg_length below 8 wraps this count to nearly SIZE_MAX. The demux then reads past the end of the buffer pool. On 32-bit big-endian hosts, a short message of another type also makes smsendian_handle_rx_message() byte-swap words past the buffer.
Drop such responses in both receive paths, beforesmsendian_handle_rx_message().
Found with a CodeQL-based static analysis tool that we are developing. Reproduced in a userspace harness under AddressSanitizer. Not tested on hardware.
---
I used an LLM to help write the harness and this patch.
drivers/media/mmc/siano/smssdio.c | 6 ++++++ drivers/media/usb/siano/smsusb.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/media/mmc/siano/smssdio.c +6 -0
@@ -226,6 +226,12 @@ static void smssdio_interrupt(struct sdio_func *func) } } +if (hdr->msg_length <sizeof (struct sms_msg_hdr )) { +pr_err ("invalid response msglen %d\n" , hdr->msg_length); +smscore_putbuffer (smsdev->coredev, cb); +return ; + } + cb->size = hdr->msg_length; cb->offset =0 ;
drivers/media/usb/siano/smsusb.c +2 -1
@@ -98,7 +98,8 @@ static void smsusb_onresponse(struct urb *urb)struct sms_msg_hdr *phdr = (struct sms_msg_hdr *)surb->cb->p;smsendian_handle_message_header (phdr); -if (urb->actual_length >= phdr->msg_length) { +if (phdr->msg_length >=sizeof (struct sms_msg_hdr ) && + urb->actual_length >= phdr->msg_length) { surb->cb->size = phdr->msg_length; if (dev->response_alignment &&
Signature · 1 line
2.34.1