aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/asihpi
diff options
context:
space:
mode:
authorEliot Blennerhassett <eliot@blennerhassett.gen.nz>2014-12-31 05:48:32 -0500
committerTakashi Iwai <tiwai@suse.de>2014-12-31 08:12:43 -0500
commit0d02e1292715d00674a49626146e3a854b504cb1 (patch)
treea0ac354d0799db7e834d0af19e45a496acffb0ac /sound/pci/asihpi
parent240491e143414973a0204e6c7cd4cfd19cb3e027 (diff)
ALSA: asihpi: fix an information leak in asihpi_hpi_ioctl()
Add missing limits to keep copied data within allocated buffer. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Eliot Blennerhassett <eliot@blennerhassett.gen.nz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/asihpi')
-rw-r--r--sound/pci/asihpi/hpi6000.c7
-rw-r--r--sound/pci/asihpi/hpioctl.c2
2 files changed, 7 insertions, 2 deletions
diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c
index 2414d7a2239d..2d6364825d4d 100644
--- a/sound/pci/asihpi/hpi6000.c
+++ b/sound/pci/asihpi/hpi6000.c
@@ -47,7 +47,7 @@
47 47
48/* operational/messaging errors */ 48/* operational/messaging errors */
49#define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901 49#define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901
50 50#define HPI6000_ERROR_RESP_GET_LEN 902
51#define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK 903 51#define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK 903
52#define HPI6000_ERROR_MSG_GET_ADR 904 52#define HPI6000_ERROR_MSG_GET_ADR 904
53#define HPI6000_ERROR_RESP_GET_ADR 905 53#define HPI6000_ERROR_RESP_GET_ADR 905
@@ -1365,7 +1365,10 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
1365 length = hpi_read_word(pdo, HPI_HIF_ADDR(length)); 1365 length = hpi_read_word(pdo, HPI_HIF_ADDR(length));
1366 } while (hpi6000_check_PCI2040_error_flag(pao, H6READ) && --timeout); 1366 } while (hpi6000_check_PCI2040_error_flag(pao, H6READ) && --timeout);
1367 if (!timeout) 1367 if (!timeout)
1368 length = sizeof(struct hpi_response); 1368 return HPI6000_ERROR_RESP_GET_LEN;
1369
1370 if (length > phr->size)
1371 return HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
1369 1372
1370 /* get the response */ 1373 /* get the response */
1371 p_data = (u32 *)phr; 1374 p_data = (u32 *)phr;
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 6aa677e60555..72af66bdf714 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -153,6 +153,8 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
153 goto out; 153 goto out;
154 } 154 }
155 155
156 res_max_size = min_t(size_t, res_max_size, sizeof(*hr));
157
156 switch (hm->h.function) { 158 switch (hm->h.function) {
157 case HPI_SUBSYS_CREATE_ADAPTER: 159 case HPI_SUBSYS_CREATE_ADAPTER:
158 case HPI_ADAPTER_DELETE: 160 case HPI_ADAPTER_DELETE: