Skip to contentSkip to conversation

media: ttusb-budget: validate DiSEqC msg_len before memcpy (CVE-2014-8884 style)

PATCH New Kery Qi 1 participant 1 message Jan 8 Media (V4L/DVB)

lore
Share & tools
lore

Kery Qi

author
#0 lore raw

PATCH 1/1 media: ttusb-budget: validate DiSEqC msg_len before memcpy (CVE-2014-8884 style)

ttusb_send_diseqc() builds a fixed 12-byte stack buffer and copies cmd->msg into it using cmd->msg_len without any bounds check. A crafted (or buggy) msg_len can make memcpy() write past the end of the stack buffer.

If this code path is reachable, a local user can trigger the issue via the DVB frontend DiSEqC master command ioctl by supplying an oversized msg_len.

Fix by rejecting cmd->msg_len values that do not fit into the remaining space of the local buffer before calling memcpy(), mirroring the defensive check used in the CVE-2014-8884 fix.

Although this appears to be dead/unreachable code today, keep it hardened to avoid future regressions.

---
 drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c +3 -1
index 9e016b71aa91..946c763281cf 100644
@@ -456,7 +456,9 @@ static int ttusb_send_diseqc(struct dvb_frontend* fe,
 	b[4] = 0xFF;		/* send diseqc master, not burst */
 	b[5] = cmd->msg_len;
 
-	memcpy(b + 5, cmd->msg, cmd->msg_len);
+	if (cmd->msg_len > sizeof(b) - 6)
+		return -EINVAL;
+	memcpy(b + 6, cmd->msg, cmd->msg_len);
 
 	/* Diseqc */
 	if ((err = ttusb_cmd(ttusb, b, 4 + b[3], 0))) {
Signature · 1 line
2.34.1