* [PATCH 0/3] ASoC: sdm845: array out of bound issues
@ 2021-03-09 10:16 Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 1/3] ASoC: qcom: sdm845: Fix array out of bounds access Srinivas Kandagatla
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2021-03-09 10:16 UTC (permalink / raw)
To: broonie
Cc: amit.pundir, alsa-devel, bjorn.andersson, lgirdwood,
linux-kernel, john.stultz, Srinivas Kandagatla
During testing John Stultz and Amit reported few array our bound issues
after enabling bound sanitizer
This patch series attempts to fix those!
Srinivas Kandagatla (3):
ASoC: qcom: sdm845: Fix array out of bounds access
ASoC: qcom: sdm845: Fix array out of range on rx slim channels
ASoC: codecs: wcd934x: add a sanity check in set channel map
sound/soc/codecs/wcd934x.c | 6 ++++++
sound/soc/qcom/sdm845.c | 6 +++---
2 files changed, 9 insertions(+), 3 deletions(-)
--
2.21.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] ASoC: qcom: sdm845: Fix array out of bounds access
2021-03-09 10:16 [PATCH 0/3] ASoC: sdm845: array out of bound issues Srinivas Kandagatla
@ 2021-03-09 10:16 ` Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 2/3] ASoC: qcom: sdm845: Fix array out of range on rx slim channels Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 3/3] ASoC: codecs: wcd934x: add a sanity check in set channel map Srinivas Kandagatla
2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2021-03-09 10:16 UTC (permalink / raw)
To: broonie
Cc: amit.pundir, alsa-devel, bjorn.andersson, lgirdwood,
linux-kernel, john.stultz, Srinivas Kandagatla
Static analysis Coverity had detected a potential array out-of-bounds
write issue due to the fact that MAX AFE port Id was set to 16 instead
of using AFE_PORT_MAX macro.
Fix this by properly using AFE_PORT_MAX macro.
Fixes: 1b93a8843147 ("ASoC: qcom: sdm845: handle soundwire stream")
Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
sound/soc/qcom/sdm845.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index 6c2760e27ea6..1e2c2d0902ea 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -33,12 +33,12 @@
struct sdm845_snd_data {
struct snd_soc_jack jack;
bool jack_setup;
- bool stream_prepared[SLIM_MAX_RX_PORTS];
+ bool stream_prepared[AFE_PORT_MAX];
struct snd_soc_card *card;
uint32_t pri_mi2s_clk_count;
uint32_t sec_mi2s_clk_count;
uint32_t quat_tdm_clk_count;
- struct sdw_stream_runtime *sruntime[SLIM_MAX_RX_PORTS];
+ struct sdw_stream_runtime *sruntime[AFE_PORT_MAX];
};
static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] ASoC: qcom: sdm845: Fix array out of range on rx slim channels
2021-03-09 10:16 [PATCH 0/3] ASoC: sdm845: array out of bound issues Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 1/3] ASoC: qcom: sdm845: Fix array out of bounds access Srinivas Kandagatla
@ 2021-03-09 10:16 ` Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 3/3] ASoC: codecs: wcd934x: add a sanity check in set channel map Srinivas Kandagatla
2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2021-03-09 10:16 UTC (permalink / raw)
To: broonie
Cc: amit.pundir, alsa-devel, bjorn.andersson, lgirdwood,
linux-kernel, john.stultz, Srinivas Kandagatla
WCD934x has only 13 RX SLIM ports however we are setting it as 16
in set_channel_map, this will lead to array out of bounds error!
Orignally caught by enabling USBAN array out of bounds check:
Fixes: 5caf64c633a3 ("ASoC: qcom: sdm845: add support to DB845c and Lenovo Yoga")
Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
sound/soc/qcom/sdm845.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
index 1e2c2d0902ea..153e9b2de0b5 100644
--- a/sound/soc/qcom/sdm845.c
+++ b/sound/soc/qcom/sdm845.c
@@ -27,7 +27,7 @@
#define SPK_TDM_RX_MASK 0x03
#define NUM_TDM_SLOTS 8
#define SLIM_MAX_TX_PORTS 16
-#define SLIM_MAX_RX_PORTS 16
+#define SLIM_MAX_RX_PORTS 13
#define WCD934X_DEFAULT_MCLK_RATE 9600000
struct sdm845_snd_data {
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] ASoC: codecs: wcd934x: add a sanity check in set channel map
2021-03-09 10:16 [PATCH 0/3] ASoC: sdm845: array out of bound issues Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 1/3] ASoC: qcom: sdm845: Fix array out of bounds access Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 2/3] ASoC: qcom: sdm845: Fix array out of range on rx slim channels Srinivas Kandagatla
@ 2021-03-09 10:16 ` Srinivas Kandagatla
2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2021-03-09 10:16 UTC (permalink / raw)
To: broonie
Cc: amit.pundir, alsa-devel, bjorn.andersson, lgirdwood,
linux-kernel, john.stultz, Srinivas Kandagatla
set channel map can be passed with a channel maps, however if
the number of channels that are passed are more than the actual
supported channels then we would be accessing array out of bounds.
So add a sanity check to validate these numbers!
Fixes: a61f3b4f476e ("ASoC: wcd934x: add support to wcd9340/wcd9341 codec")
Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
sound/soc/codecs/wcd934x.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index 40f682f5dab8..1d27cdf5277d 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -1871,6 +1871,12 @@ static int wcd934x_set_channel_map(struct snd_soc_dai *dai,
struct wcd934x_codec *wcd;
int i;
+ if (tx_num > WCD934X_TX_MAX || rx_num > WCD934X_RX_MAX) {
+ dev_err(wcd->dev, "Invalid tx %d or rx %d channel count\n",
+ tx_num, rx_num);
+ return -EINVAL;
+ }
+
wcd = snd_soc_component_get_drvdata(dai->component);
if (!tx_slot || !rx_slot) {
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-09 10:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 10:16 [PATCH 0/3] ASoC: sdm845: array out of bound issues Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 1/3] ASoC: qcom: sdm845: Fix array out of bounds access Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 2/3] ASoC: qcom: sdm845: Fix array out of range on rx slim channels Srinivas Kandagatla
2021-03-09 10:16 ` [PATCH 3/3] ASoC: codecs: wcd934x: add a sanity check in set channel map Srinivas Kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).