diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2019-04-22 11:16:04 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-04-25 05:11:41 -0400 |
commit | c114944d7d67f24e71562fcfc18d550ab787e4d4 (patch) | |
tree | 04f2d076bcc3f9a00ebf3395bfb90e21cc5eaf31 | |
parent | ef61eb43ada6c1d6b94668f0f514e4c268093ff3 (diff) |
USB: w1 ds2490: Fix bug caused by improper use of altsetting array
The syzkaller USB fuzzer spotted a slab-out-of-bounds bug in the
ds2490 driver. This bug is caused by improper use of the altsetting
array in the usb_interface structure (the array's entries are not
always stored in numerical order), combined with a naive assumption
that all interfaces probed by the driver will have the expected number
of altsettings.
The bug can be fixed by replacing references to the possibly
non-existent intf->altsetting[alt] entry with the guaranteed-to-exist
intf->cur_altsetting entry.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: syzbot+d65f673b847a1a96cdba@syzkaller.appspotmail.com
CC: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/w1/masters/ds2490.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c index 0f4ecfcdb549..a9fb77585272 100644 --- a/drivers/w1/masters/ds2490.c +++ b/drivers/w1/masters/ds2490.c | |||
@@ -1016,15 +1016,15 @@ static int ds_probe(struct usb_interface *intf, | |||
1016 | /* alternative 3, 1ms interrupt (greatly speeds search), 64 byte bulk */ | 1016 | /* alternative 3, 1ms interrupt (greatly speeds search), 64 byte bulk */ |
1017 | alt = 3; | 1017 | alt = 3; |
1018 | err = usb_set_interface(dev->udev, | 1018 | err = usb_set_interface(dev->udev, |
1019 | intf->altsetting[alt].desc.bInterfaceNumber, alt); | 1019 | intf->cur_altsetting->desc.bInterfaceNumber, alt); |
1020 | if (err) { | 1020 | if (err) { |
1021 | dev_err(&dev->udev->dev, "Failed to set alternative setting %d " | 1021 | dev_err(&dev->udev->dev, "Failed to set alternative setting %d " |
1022 | "for %d interface: err=%d.\n", alt, | 1022 | "for %d interface: err=%d.\n", alt, |
1023 | intf->altsetting[alt].desc.bInterfaceNumber, err); | 1023 | intf->cur_altsetting->desc.bInterfaceNumber, err); |
1024 | goto err_out_clear; | 1024 | goto err_out_clear; |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | iface_desc = &intf->altsetting[alt]; | 1027 | iface_desc = intf->cur_altsetting; |
1028 | if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { | 1028 | if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { |
1029 | pr_info("Num endpoints=%d. It is not DS9490R.\n", | 1029 | pr_info("Num endpoints=%d. It is not DS9490R.\n", |
1030 | iface_desc->desc.bNumEndpoints); | 1030 | iface_desc->desc.bNumEndpoints); |