Skip to contentSkip to conversation

sound/pci/asihpi: check adapter index in hpi_ioctl

PATCH In review Dan Rosenberg 3 participants 3 messages Mar 17, 2011 – Mar 18, 2011 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound/pci/asihpi: check adapter index in hpi_ioctl

The user-supplied index into the adapters array needs to be checked, or an out-of-bounds kernel pointer could be accessed and used, leading to potentially exploitable memory corruption.

---
 sound/pci/asihpi/hpioctl.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
sound/pci/asihpi/hpioctl.c +5 -0
index 22dbd91..448dd01 100644
@@ -155,6 +155,11 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		goto out;
 	}
 
+	if (hm->h.adapter_index >= HPI_MAX_ADAPTERS) {
+		err = -EINVAL;
+		goto out;
+	}
+
 	pa = &adapters[hm->h.adapter_index];
 	hr->h.size = 0;
 	if (hm->h.object == HPI_OBJ_SUBSYSTEM) {
#1 lore raw
Quoted 8 lines · Dan Rosenberg

The user-supplied index into the adapters array needs to be checked, or an out-of-bounds kernel pointer could be accessed and used, leading to potentially exploitable memory corruption.

---
 sound/pci/asihpi/hpioctl.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.

</formletter>

thanks,

greg k-h

#2 lore raw
In reply to Dan Rosenberg

At Thu, 17 Mar 2011 18:32:24 -0400,

Quoted 6 lines · Dan Rosenberg

The user-supplied index into the adapters array needs to be checked, or an out-of-bounds kernel pointer could be accessed and used, leading to potentially exploitable memory corruption.

Applied now (with Cc to stable kernel). Thanks.

Takashi

Quoted 22 lines
---
 sound/pci/asihpi/hpioctl.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
sound/pci/asihpi/hpioctl.c +5 -0
index 22dbd91..448dd01 100644
@@ -155,6 +155,11 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		goto out;
 	}
 
+	if (hm->h.adapter_index >= HPI_MAX_ADAPTERS) {
+		err = -EINVAL;
+		goto out;
+	}
+
 	pa = &adapters[hm->h.adapter_index];
 	hr->h.size = 0;
 	if (hm->h.object == HPI_OBJ_SUBSYSTEM) {