mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
USB: serial: mxuport: validate firmware header size
mxuport_probe() reads version bytes at fixed offsets after
request_firmware() succeeds. Firmware loading success does not prove that
the blob reaches the highest version offset.
Reject short firmware images before reading the version bytes. This is
source-level parser hardening; no affected device or crash was observed.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Fixes: ee467a1f20 ("USB: serial: add Moxa UPORT 12XX/14XX/16XX driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
This commit is contained in:
parent
fad0fd120e
commit
52beeed5e5
|
|
@ -1080,6 +1080,13 @@ static int mxuport_probe(struct usb_serial *serial,
|
|||
/* Use the firmware already in the device */
|
||||
err = 0;
|
||||
} else {
|
||||
if (fw_p->size <= VER_ADDR_3) {
|
||||
dev_err(&serial->interface->dev,
|
||||
"Firmware %s is too short\n", buf);
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
local_ver = ((fw_p->data[VER_ADDR_1] << 16) |
|
||||
(fw_p->data[VER_ADDR_2] << 8) |
|
||||
fw_p->data[VER_ADDR_3]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user