Skip to content

Commit 89f8765

Browse files
jhovoldKalle Valo
authored andcommitted
mwifiex: fix division by zero in fw download path
Add the missing endpoint sanity checks to probe() to avoid division by zero in mwifiex_write_data_sync() in case a malicious device has broken descriptors (or when doing descriptor fuzz testing). Only add checks for the firmware-download boot stage, which require both command endpoints, for now. The driver looks like it will handle a missing endpoint during normal operation without oopsing, albeit not very gracefully as it will try to submit URBs to the default pipe and fail. Note that USB core will reject URBs submitted for endpoints with zero wMaxPacketSize but that drivers doing packet-size calculations still need to handle this (cf. commit 2548288 ("USB: Fix: Don't skip endpoint descriptors with maxpacket=0")). Fixes: 4daffe3 ("mwifiex: add support for Marvell USB8797 chipset") Cc: [email protected] # 3.5 Cc: Amitkumar Karwar <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Brian Norris <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 541fd20 commit 89f8765

File tree

1 file changed

+16
-0
lines changed
  • drivers/net/wireless/marvell/mwifiex

1 file changed

+16
-0
lines changed

drivers/net/wireless/marvell/mwifiex/usb.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,22 @@ static int mwifiex_usb_probe(struct usb_interface *intf,
505505
}
506506
}
507507

508+
switch (card->usb_boot_state) {
509+
case USB8XXX_FW_DNLD:
510+
/* Reject broken descriptors. */
511+
if (!card->rx_cmd_ep || !card->tx_cmd_ep)
512+
return -ENODEV;
513+
if (card->bulk_out_maxpktsize == 0)
514+
return -ENODEV;
515+
break;
516+
case USB8XXX_FW_READY:
517+
/* Assume the driver can handle missing endpoints for now. */
518+
break;
519+
default:
520+
WARN_ON(1);
521+
return -ENODEV;
522+
}
523+
508524
usb_set_intfdata(intf, card);
509525

510526
ret = mwifiex_add_card(card, &card->fw_done, &usb_ops,

0 commit comments

Comments
 (0)