aboutsummaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorrazorloves <razorloves@gmail.com>2019-07-06 20:23:40 -0500
committerrazorloves <razorloves@gmail.com>2019-07-06 20:23:40 -0500
commit935c8dd0f5a4c5df3b447dbfb40427275fe9c12d (patch)
tree0344050ec72839114cf97779783570e32c29f7ae /sound/soc
parent4f3ee8b00b044ab6c07d624bf662e1daa4c5f00d (diff)
parenta2426c4f8f23a3c14d387d50251de176be4d5b1a (diff)
Merge aosp tag 'android-9.0.0_r0.95' into lineage-16.0HEADp9.0
July 2019 PQ3A.190705.001 2a53f55 dsp: asm: Add check for num_channels before calling q6asm_map_channels b9e963d qcacld-2.0: Fix possible OOB access in limProcessDisassocFrame 0da2144 qcacld-2.0: Fix possible integer underflow in cfg80211_rx_mgmt 29f93f4 dsp: validate token before usage as array index 6ef3b69 qcacld-2.0: Fix OOB read in sme_RrmProcessBeaconReportReqInd
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/msm/qdsp6v2/q6afe.c31
-rw-r--r--sound/soc/msm/qdsp6v2/q6asm.c52
2 files changed, 76 insertions, 7 deletions
diff --git a/sound/soc/msm/qdsp6v2/q6afe.c b/sound/soc/msm/qdsp6v2/q6afe.c
index 025b3dee611..a57459521db 100644
--- a/sound/soc/msm/qdsp6v2/q6afe.c
+++ b/sound/soc/msm/qdsp6v2/q6afe.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, 2019 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
@@ -263,6 +263,15 @@ static int32_t sp_make_afe_callback(uint32_t *payload, uint32_t payload_size)
return 0;
}
+static bool afe_token_is_valid(uint32_t token)
+{
+ if (token >= AFE_MAX_PORTS) {
+ pr_err("%s: token %d is invalid.\n", __func__, token);
+ return false;
+ }
+ return true;
+}
+
static int32_t afe_callback(struct apr_client_data *data, void *priv)
{
if (!data) {
@@ -327,7 +336,10 @@ static int32_t afe_callback(struct apr_client_data *data, void *priv)
if (sp_make_afe_callback(data->payload, data->payload_size))
return -EINVAL;
- wake_up(&this_afe.wait[data->token]);
+ if (afe_token_is_valid(data->token))
+ wake_up(&this_afe.wait[data->token]);
+ else
+ return -EINVAL;
} else if (data->payload_size) {
uint32_t *payload;
uint16_t port_id = 0;
@@ -357,7 +369,10 @@ static int32_t afe_callback(struct apr_client_data *data, void *priv)
case AFE_PORTS_CMD_DTMF_CTL:
case AFE_SVC_CMD_SET_PARAM:
atomic_set(&this_afe.state, 0);
- wake_up(&this_afe.wait[data->token]);
+ if (afe_token_is_valid(data->token))
+ wake_up(&this_afe.wait[data->token]);
+ else
+ return -EINVAL;
break;
case AFE_SERVICE_CMD_REGISTER_RT_PORT_DRIVER:
break;
@@ -369,7 +384,10 @@ static int32_t afe_callback(struct apr_client_data *data, void *priv)
break;
case AFE_CMD_ADD_TOPOLOGIES:
atomic_set(&this_afe.state, 0);
- wake_up(&this_afe.wait[data->token]);
+ if (afe_token_is_valid(data->token))
+ wake_up(&this_afe.wait[data->token]);
+ else
+ return -EINVAL;
pr_debug("%s: AFE_CMD_ADD_TOPOLOGIES cmd 0x%x\n",
__func__, payload[1]);
break;
@@ -391,7 +409,10 @@ static int32_t afe_callback(struct apr_client_data *data, void *priv)
else
this_afe.mmap_handle = payload[0];
atomic_set(&this_afe.state, 0);
- wake_up(&this_afe.wait[data->token]);
+ if (afe_token_is_valid(data->token))
+ wake_up(&this_afe.wait[data->token]);
+ else
+ return -EINVAL;
} else if (data->opcode == AFE_EVENT_RT_PROXY_PORT_STATUS) {
port_id = (uint16_t)(0x0000FFFF & payload[0]);
}
diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c
index b3614532d4e..d77b5c8fbe8 100644
--- a/sound/soc/msm/qdsp6v2/q6asm.c
+++ b/sound/soc/msm/qdsp6v2/q6asm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016, 2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2016, 2018-2019 The Linux Foundation. All rights reserved.
* Author: Brian Swetland <swetland@google.com>
*
* This software is licensed under the terms of the GNU General Public
@@ -3215,6 +3215,12 @@ int q6asm_open_shared_io(struct audio_client *ac,
if (!ac || !config)
return -EINVAL;
+ if (config->channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__,
+ config->channels);
+ return -EINVAL;
+ }
+
bufsz = config->bufsz;
bufcnt = config->bufcnt;
num_watermarks = 0;
@@ -3679,6 +3685,13 @@ int q6asm_set_encdec_chan_map(struct audio_client *ac,
int rc = 0;
pr_debug("%s: Session %d, num_channels = %d\n",
__func__, ac->session, num_channels);
+
+ if (num_channels > MAX_CHAN_MAP_CHANNELS) {
+ pr_err("%s: Invalid channel count %d\n", __func__,
+ num_channels);
+ return -EINVAL;
+ }
+
q6asm_add_hdr(ac, &chan_map.hdr, sizeof(chan_map), TRUE);
atomic_set(&ac->cmd_state, -1);
chan_map.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
@@ -3754,6 +3767,12 @@ int q6asm_enc_cfg_blk_pcm_v3(struct audio_client *ac,
goto fail_cmd;
}
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ rc = -EINVAL;
+ goto fail_cmd;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
ac->session, rate, channels,
bits_per_sample, sample_word_size);
@@ -3836,6 +3855,11 @@ int q6asm_enc_cfg_blk_pcm_v2(struct audio_client *ac,
return -EINVAL;
}
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__,
ac->session, rate, channels);
@@ -3954,9 +3978,13 @@ int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
struct asm_multi_channel_pcm_enc_cfg_v2 enc_cfg;
u8 *channel_mapping;
u32 frames_per_buf = 0;
-
int rc = 0;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__,
ac->session, rate, channels);
@@ -4429,6 +4457,11 @@ static int __q6asm_media_format_block_pcm(struct audio_client *ac,
u8 *channel_mapping;
int rc = 0;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate,
channels);
@@ -4507,6 +4540,11 @@ static int __q6asm_media_format_block_pcm_v3(struct audio_client *ac,
u8 *channel_mapping;
int rc;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
ac->session, rate, channels,
bits_per_sample, sample_word_size);
@@ -4652,6 +4690,11 @@ static int __q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
u8 *channel_mapping;
int rc = 0;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate,
channels);
@@ -4719,6 +4762,11 @@ static int __q6asm_media_format_block_multi_ch_pcm_v3(struct audio_client *ac,
u8 *channel_mapping;
int rc;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
ac->session, rate, channels,
bits_per_sample, sample_word_size);