summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorAditya Bavanari <abavanar@codeaurora.org>2018-02-23 13:15:19 +0530
committerAditya Bavanari <abavanar@codeaurora.org>2018-03-06 12:52:27 +0530
commit893f3cf2fbc32303c7dc5f91d336b3d60982ad91 (patch)
treefc8170929d51afc40cddfa9d6219ca778ad424f1 /sound
parentc2c950b468079a41c31d819051ffb8d9ad9eac8f (diff)
asoc: msm: add check for integer overflow
Add check for integer overflow of user supplied data for ADSP stream command. CRs-Fixed: 2173850 Change-Id: Ic70093e890b7a6dd07529d77d10fff003282a8ea Signed-off-by: Aditya Bavanari <abavanar@codeaurora.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c13
-rw-r--r--sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c13
-rw-r--r--sound/soc/msm/qdsp6v2/msm-transcode-loopback-q6-v2.c13
-rw-r--r--sound/soc/msm/qdsp6v2/q6asm.c15
4 files changed, 49 insertions, 5 deletions
diff --git a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
index 45a3f42b6f55..15134a0d662e 100644
--- a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -3701,6 +3701,7 @@ static int msm_compr_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol,
struct msm_compr_audio *prtd;
int ret = 0;
struct msm_adsp_event_data *event_data = NULL;
+ uint64_t actual_payload_len = 0;
if (fe_id >= MSM_FRONTEND_DAI_MAX) {
pr_err("%s Received invalid fe_id %lu\n",
@@ -3738,6 +3739,16 @@ static int msm_compr_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol,
goto done;
}
+ actual_payload_len = sizeof(struct msm_adsp_event_data) +
+ event_data->payload_len;
+ if (actual_payload_len >= U32_MAX) {
+ pr_err("%s payload length 0x%X exceeds limit",
+ __func__, event_data->payload_len);
+ ret = -EINVAL;
+ goto done;
+ }
+
+
if ((sizeof(struct msm_adsp_event_data) + event_data->payload_len) >=
sizeof(ucontrol->value.bytes.data)) {
pr_err("%s param length=%d exceeds limit",
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
index 7e022619c097..08aca2e9da41 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -52,6 +52,7 @@ static struct audio_locks the_locks;
static const DECLARE_TLV_DB_LINEAR(msm_pcm_vol_gain, 0,
PCM_MASTER_VOL_MAX_STEPS);
+
struct snd_msm {
struct snd_card *card;
struct snd_pcm *pcm;
@@ -1084,6 +1085,7 @@ static int msm_pcm_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol,
struct msm_audio *prtd;
int ret = 0;
struct msm_adsp_event_data *event_data = NULL;
+ uint64_t actual_payload_len = 0;
if (!pdata) {
pr_err("%s pdata is NULL\n", __func__);
@@ -1120,6 +1122,15 @@ static int msm_pcm_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol,
goto done;
}
+ actual_payload_len = sizeof(struct msm_adsp_event_data) +
+ event_data->payload_len;
+ if (actual_payload_len >= U32_MAX) {
+ pr_err("%s payload length 0x%X exceeds limit",
+ __func__, event_data->payload_len);
+ ret = -EINVAL;
+ goto done;
+ }
+
if ((sizeof(struct msm_adsp_event_data) + event_data->payload_len) >=
sizeof(ucontrol->value.bytes.data)) {
pr_err("%s param length=%d exceeds limit",
diff --git a/sound/soc/msm/qdsp6v2/msm-transcode-loopback-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-transcode-loopback-q6-v2.c
index 18cac3424054..72dd751bb0d8 100644
--- a/sound/soc/msm/qdsp6v2/msm-transcode-loopback-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-transcode-loopback-q6-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -645,6 +645,7 @@ static int msm_transcode_stream_cmd_put(struct snd_kcontrol *kcontrol,
struct msm_transcode_loopback *prtd;
int ret = 0;
struct msm_adsp_event_data *event_data = NULL;
+ uint64_t actual_payload_len = 0;
if (fe_id >= MSM_FRONTEND_DAI_MAX) {
pr_err("%s Received invalid fe_id %lu\n",
@@ -682,6 +683,16 @@ static int msm_transcode_stream_cmd_put(struct snd_kcontrol *kcontrol,
goto done;
}
+ actual_payload_len = sizeof(struct msm_adsp_event_data) +
+ event_data->payload_len;
+ if (actual_payload_len >= U32_MAX) {
+ pr_err("%s payload length 0x%X exceeds limit",
+ __func__, event_data->payload_len);
+ ret = -EINVAL;
+ goto done;
+ }
+
+
if ((sizeof(struct msm_adsp_event_data) + event_data->payload_len) >=
sizeof(ucontrol->value.bytes.data)) {
pr_err("%s param length=%d exceeds limit",
diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c
index 201234a25bd9..07c2bcf4c002 100644
--- a/sound/soc/msm/qdsp6v2/q6asm.c
+++ b/sound/soc/msm/qdsp6v2/q6asm.c
@@ -47,6 +47,7 @@
#define FALSE 0x00
#define SESSION_MAX 9
#define ASM_MAX_CHANNELS 8
+
enum {
ASM_TOPOLOGY_CAL = 0,
ASM_CUSTOM_TOP_CAL,
@@ -1159,7 +1160,9 @@ int q6asm_send_stream_cmd(struct audio_client *ac,
{
char *asm_params = NULL;
struct apr_hdr hdr;
- int sz, rc;
+ int rc;
+ uint32_t sz = 0;
+ uint64_t actual_sz = 0;
if (!data || !ac) {
pr_err("%s: %s is NULL\n", __func__,
@@ -1176,7 +1179,15 @@ int q6asm_send_stream_cmd(struct audio_client *ac,
goto done;
}
- sz = sizeof(struct apr_hdr) + data->payload_len;
+ actual_sz = sizeof(struct apr_hdr) + data->payload_len;
+ if (actual_sz > U32_MAX) {
+ pr_err("%s: payload size 0x%X exceeds limit\n",
+ __func__, data->payload_len);
+ rc = -EINVAL;
+ goto done;
+ }
+
+ sz = (uint32_t)actual_sz;
asm_params = kzalloc(sz, GFP_KERNEL);
if (!asm_params) {
rc = -ENOMEM;