Skip to content

Commit 663bd76

Browse files
committed
ALSA: usb-audio: Fix potential out-of-bound accesses for Extigy and Mbox devices
jira VULN-46737 cve CVE-2024-53197 commit-author Benoît Sevens <[email protected]> commit b909df1 upstream-diff This kernel doesn't have snd_usb_mbox3_boot_quirk(), so that change hunk from the upstream commit isn't necessary. A bogus device can provide a bNumConfigurations value that exceeds the initial value used in usb_get_configuration for allocating dev->config. This can lead to out-of-bounds accesses later, e.g. in usb_destroy_configuration. Signed-off-by: Benoît Sevens <[email protected]> Fixes: 1da177e ("Linux-2.6.12-rc2") Cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]> (cherry picked from commit b909df1) Signed-off-by: Brett Mastbergen <[email protected]>
1 parent 49f9d93 commit 663bd76

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

sound/usb/quirks.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip,
577577
static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interface *intf)
578578
{
579579
struct usb_host_config *config = dev->actconfig;
580+
struct usb_device_descriptor new_device_descriptor;
580581
int err;
581582

582583
if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD ||
@@ -588,10 +589,14 @@ static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interfac
588589
if (err < 0)
589590
dev_dbg(&dev->dev, "error sending boot message: %d\n", err);
590591
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
591-
&dev->descriptor, sizeof(dev->descriptor));
592-
config = dev->actconfig;
592+
&new_device_descriptor, sizeof(new_device_descriptor));
593593
if (err < 0)
594594
dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err);
595+
if (new_device_descriptor.bNumConfigurations > dev->descriptor.bNumConfigurations)
596+
dev_dbg(&dev->dev, "error too large bNumConfigurations: %d\n",
597+
new_device_descriptor.bNumConfigurations);
598+
else
599+
memcpy(&dev->descriptor, &new_device_descriptor, sizeof(dev->descriptor));
595600
err = usb_reset_configuration(dev);
596601
if (err < 0)
597602
dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err);
@@ -925,6 +930,7 @@ static void mbox2_setup_48_24_magic(struct usb_device *dev)
925930
static int snd_usb_mbox2_boot_quirk(struct usb_device *dev)
926931
{
927932
struct usb_host_config *config = dev->actconfig;
933+
struct usb_device_descriptor new_device_descriptor;
928934
int err;
929935
u8 bootresponse[0x12];
930936
int fwsize;
@@ -960,10 +966,14 @@ static int snd_usb_mbox2_boot_quirk(struct usb_device *dev)
960966
dev_dbg(&dev->dev, "device initialised!\n");
961967

962968
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
963-
&dev->descriptor, sizeof(dev->descriptor));
964-
config = dev->actconfig;
969+
&new_device_descriptor, sizeof(new_device_descriptor));
965970
if (err < 0)
966971
dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err);
972+
if (new_device_descriptor.bNumConfigurations > dev->descriptor.bNumConfigurations)
973+
dev_dbg(&dev->dev, "error too large bNumConfigurations: %d\n",
974+
new_device_descriptor.bNumConfigurations);
975+
else
976+
memcpy(&dev->descriptor, &new_device_descriptor, sizeof(dev->descriptor));
967977

968978
err = usb_reset_configuration(dev);
969979
if (err < 0)

0 commit comments

Comments
 (0)