* [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
@ 2023-03-03 12:57 Ravulapati Vishnu Vardhan Rao
2023-03-03 14:07 ` Mark Brown
2023-03-03 14:15 ` Srinivas Kandagatla
0 siblings, 2 replies; 8+ messages in thread
From: Ravulapati Vishnu Vardhan Rao @ 2023-03-03 12:57 UTC (permalink / raw)
Cc: quic_visr, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai,
moderated list:QCOM AUDIO (ASoC) DRIVERS, open list
From: visr <quic_visr@quicinc.com>
When we run syzkaller we get below Out of Bound.
"KASAN: slab-out-of-bounds Read in regcache_flat_read"
Below is the backtrace of the issue:
dump_backtrace+0x0/0x4c8
show_stack+0x34/0x44
dump_stack_lvl+0xd8/0x118
print_address_description+0x30/0x2d8
kasan_report+0x158/0x198
__asan_report_load4_noabort+0x44/0x50
regcache_flat_read+0x10c/0x110
regcache_read+0xf4/0x180
_regmap_read+0xc4/0x278
_regmap_update_bits+0x130/0x290
regmap_update_bits_base+0xc0/0x15c
snd_soc_component_update_bits+0xa8/0x22c
snd_soc_component_write_field+0x68/0xd4
tx_macro_digital_mute+0xec/0x140
Actually There is no need to have decimator with 32 bits.
By limiting the variable with short type u8 issue is resolved.
Signed-off-by: RAVULAPATI VISHNUVARDHAN RAO <quic_visr@quicinc.com>
---
sound/soc/codecs/lpass-tx-macro.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index bf27bdd5be20..73014fa6e4b8 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -242,7 +242,7 @@ enum {
struct tx_mute_work {
struct tx_macro *tx;
- u32 decimator;
+ u8 decimator;
struct delayed_work dwork;
};
@@ -635,7 +635,7 @@ static int tx_macro_mclk_enable(struct tx_macro *tx,
return 0;
}
-static bool is_amic_enabled(struct snd_soc_component *component, int decimator)
+static bool is_amic_enabled(struct snd_soc_component *component, u8 decimator)
{
u16 adc_mux_reg, adc_reg, adc_n;
@@ -849,7 +849,7 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- unsigned int decimator;
+ u8 decimator;
u16 tx_vol_ctl_reg, dec_cfg_reg, hpf_gate_reg, tx_gain_ctl_reg;
u8 hpf_cut_off_freq;
int hpf_delay = TX_MACRO_DMIC_HPF_DELAY_MS;
@@ -1064,9 +1064,10 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
- u32 decimator, sample_rate;
+ u32 sample_rate;
int tx_fs_rate;
struct tx_macro *tx = snd_soc_component_get_drvdata(component);
+ u8 decimator = 0;
sample_rate = params_rate(params);
switch (sample_rate) {
@@ -1128,7 +1129,7 @@ static int tx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
{
struct snd_soc_component *component = dai->component;
struct tx_macro *tx = snd_soc_component_get_drvdata(component);
- u16 decimator;
+ u8 decimator;
/* active decimator not set yet */
if (tx->active_decimator[dai->id] == -1)
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
2023-03-03 12:57 [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds Ravulapati Vishnu Vardhan Rao
@ 2023-03-03 14:07 ` Mark Brown
2023-03-03 14:15 ` Srinivas Kandagatla
1 sibling, 0 replies; 8+ messages in thread
From: Mark Brown @ 2023-03-03 14:07 UTC (permalink / raw)
To: Ravulapati Vishnu Vardhan Rao
Cc: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai,
moderated list:QCOM AUDIO (ASoC) DRIVERS, open list
[-- Attachment #1: Type: text/plain, Size: 231 bytes --]
On Fri, Mar 03, 2023 at 06:27:16PM +0530, Ravulapati Vishnu Vardhan Rao wrote:
> From: visr <quic_visr@quicinc.com>
> Signed-off-by: RAVULAPATI VISHNUVARDHAN RAO <quic_visr@quicinc.com>
Now the From doesn't match the signoff...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
2023-03-03 12:57 [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds Ravulapati Vishnu Vardhan Rao
2023-03-03 14:07 ` Mark Brown
@ 2023-03-03 14:15 ` Srinivas Kandagatla
2023-03-03 17:32 ` VISHNUVARDHAN RAO RAVULAPATI
1 sibling, 1 reply; 8+ messages in thread
From: Srinivas Kandagatla @ 2023-03-03 14:15 UTC (permalink / raw)
To: Ravulapati Vishnu Vardhan Rao
Cc: Banajit Goswami, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, moderated list:QCOM AUDIO (ASoC) DRIVERS,
open list
On 03/03/2023 12:57, Ravulapati Vishnu Vardhan Rao wrote:
> @@ -1064,9 +1064,10 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream,
> struct snd_soc_dai *dai)
> {
> struct snd_soc_component *component = dai->component;
> - u32 decimator, sample_rate;
> + u32 sample_rate;
> int tx_fs_rate;
> struct tx_macro *tx = snd_soc_component_get_drvdata(component);
> + u8 decimator = 0;
Minor nit, any reason why decimator is intialized as part of this change.
--srini
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
2023-03-03 14:15 ` Srinivas Kandagatla
@ 2023-03-03 17:32 ` VISHNUVARDHAN RAO RAVULAPATI
0 siblings, 0 replies; 8+ messages in thread
From: VISHNUVARDHAN RAO RAVULAPATI @ 2023-03-03 17:32 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Banajit Goswami, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, moderated list:QCOM AUDIO (ASoC) DRIVERS,
open list
On 3/3/2023 7:45 PM, Srinivas Kandagatla wrote:
>
>
> On 03/03/2023 12:57, Ravulapati Vishnu Vardhan Rao wrote:
>> @@ -1064,9 +1064,10 @@ static int tx_macro_hw_params(struct
>> snd_pcm_substream *substream,
>> struct snd_soc_dai *dai)
>> {
>> struct snd_soc_component *component = dai->component;
>> - u32 decimator, sample_rate;
>> + u32 sample_rate;
>> int tx_fs_rate;
>> struct tx_macro *tx = snd_soc_component_get_drvdata(component);
>> + u8 decimator = 0;
> Minor nit, any reason why decimator is intialized as part of this change.
>
> --srini
Will Remove that..Thanks for review
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
@ 2023-03-04 8:07 Ravulapati Vishnu Vardhan Rao
2023-03-06 12:45 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Ravulapati Vishnu Vardhan Rao @ 2023-03-04 8:07 UTC (permalink / raw)
Cc: quic_visr, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai,
moderated list:QCOM AUDIO (ASoC) DRIVERS, open list
When we run syzkaller we get below Out of Bound.
"KASAN: slab-out-of-bounds Read in regcache_flat_read"
Below is the backtrace of the issue:
dump_backtrace+0x0/0x4c8
show_stack+0x34/0x44
dump_stack_lvl+0xd8/0x118
print_address_description+0x30/0x2d8
kasan_report+0x158/0x198
__asan_report_load4_noabort+0x44/0x50
regcache_flat_read+0x10c/0x110
regcache_read+0xf4/0x180
_regmap_read+0xc4/0x278
_regmap_update_bits+0x130/0x290
regmap_update_bits_base+0xc0/0x15c
snd_soc_component_update_bits+0xa8/0x22c
snd_soc_component_write_field+0x68/0xd4
tx_macro_digital_mute+0xec/0x140
Actually There is no need to have decimator with 32 bits.
By limiting the variable with short type u8 issue is resolved.
Signed-off-by: Ravulapati Vishnu Vardhan Rao <quic_visr@quicinc.com>
---
sound/soc/codecs/lpass-tx-macro.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index bf27bdd5be20..473d3cd39554 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -242,7 +242,7 @@ enum {
struct tx_mute_work {
struct tx_macro *tx;
- u32 decimator;
+ u8 decimator;
struct delayed_work dwork;
};
@@ -635,7 +635,7 @@ static int tx_macro_mclk_enable(struct tx_macro *tx,
return 0;
}
-static bool is_amic_enabled(struct snd_soc_component *component, int decimator)
+static bool is_amic_enabled(struct snd_soc_component *component, u8 decimator)
{
u16 adc_mux_reg, adc_reg, adc_n;
@@ -849,7 +849,7 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- unsigned int decimator;
+ u8 decimator;
u16 tx_vol_ctl_reg, dec_cfg_reg, hpf_gate_reg, tx_gain_ctl_reg;
u8 hpf_cut_off_freq;
int hpf_delay = TX_MACRO_DMIC_HPF_DELAY_MS;
@@ -1064,7 +1064,8 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
- u32 decimator, sample_rate;
+ u32 sample_rate;
+ u8 decimator;
int tx_fs_rate;
struct tx_macro *tx = snd_soc_component_get_drvdata(component);
@@ -1128,7 +1129,7 @@ static int tx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
{
struct snd_soc_component *component = dai->component;
struct tx_macro *tx = snd_soc_component_get_drvdata(component);
- u16 decimator;
+ u8 decimator;
/* active decimator not set yet */
if (tx->active_decimator[dai->id] == -1)
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
2023-03-04 8:07 Ravulapati Vishnu Vardhan Rao
@ 2023-03-06 12:45 ` Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2023-03-06 12:45 UTC (permalink / raw)
To: Ravulapati Vishnu Vardhan Rao
Cc: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai,
moderated list:QCOM AUDIO (ASoC) DRIVERS, open list
On Sat, 04 Mar 2023 13:37:02 +0530, Ravulapati Vishnu Vardhan Rao wrote:
> When we run syzkaller we get below Out of Bound.
> "KASAN: slab-out-of-bounds Read in regcache_flat_read"
>
> Below is the backtrace of the issue:
>
> dump_backtrace+0x0/0x4c8
> show_stack+0x34/0x44
> dump_stack_lvl+0xd8/0x118
> print_address_description+0x30/0x2d8
> kasan_report+0x158/0x198
> __asan_report_load4_noabort+0x44/0x50
> regcache_flat_read+0x10c/0x110
> regcache_read+0xf4/0x180
> _regmap_read+0xc4/0x278
> _regmap_update_bits+0x130/0x290
> regmap_update_bits_base+0xc0/0x15c
> snd_soc_component_update_bits+0xa8/0x22c
> snd_soc_component_write_field+0x68/0xd4
> tx_macro_digital_mute+0xec/0x140
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
commit: e5e7e398f6bb7918dab0612eb6991f7bae95520d
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
@ 2023-03-03 12:12 Ravulapati Vishnu Vardhan Rao
2023-03-03 12:41 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Ravulapati Vishnu Vardhan Rao @ 2023-03-03 12:12 UTC (permalink / raw)
Cc: quic_visr, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai,
moderated list:QCOM AUDIO (ASoC) DRIVERS, open list
From: visr <quic_visr@quicinc.com>
When we run syzkaller we get below Out of Bound.
"KASAN: slab-out-of-bounds Read in regcache_flat_read"
Below is the backtrace of the issue:
dump_backtrace+0x0/0x4c8
show_stack+0x34/0x44
dump_stack_lvl+0xd8/0x118
print_address_description+0x30/0x2d8
kasan_report+0x158/0x198
__asan_report_load4_noabort+0x44/0x50
regcache_flat_read+0x10c/0x110
regcache_read+0xf4/0x180
_regmap_read+0xc4/0x278
_regmap_update_bits+0x130/0x290
regmap_update_bits_base+0xc0/0x15c
snd_soc_component_update_bits+0xa8/0x22c
snd_soc_component_write_field+0x68/0xd4
tx_macro_digital_mute+0xec/0x140
Actually There is no need to have decimator with 32 bytes.
By limiting the variable with short type u8 issue is resolved.
Signed-off-by: visr <quic_visr@quicinc.com>
---
sound/soc/codecs/lpass-tx-macro.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index bf27bdd5be20..73014fa6e4b8 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -242,7 +242,7 @@ enum {
struct tx_mute_work {
struct tx_macro *tx;
- u32 decimator;
+ u8 decimator;
struct delayed_work dwork;
};
@@ -635,7 +635,7 @@ static int tx_macro_mclk_enable(struct tx_macro *tx,
return 0;
}
-static bool is_amic_enabled(struct snd_soc_component *component, int decimator)
+static bool is_amic_enabled(struct snd_soc_component *component, u8 decimator)
{
u16 adc_mux_reg, adc_reg, adc_n;
@@ -849,7 +849,7 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- unsigned int decimator;
+ u8 decimator;
u16 tx_vol_ctl_reg, dec_cfg_reg, hpf_gate_reg, tx_gain_ctl_reg;
u8 hpf_cut_off_freq;
int hpf_delay = TX_MACRO_DMIC_HPF_DELAY_MS;
@@ -1064,9 +1064,10 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
- u32 decimator, sample_rate;
+ u32 sample_rate;
int tx_fs_rate;
struct tx_macro *tx = snd_soc_component_get_drvdata(component);
+ u8 decimator = 0;
sample_rate = params_rate(params);
switch (sample_rate) {
@@ -1128,7 +1129,7 @@ static int tx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
{
struct snd_soc_component *component = dai->component;
struct tx_macro *tx = snd_soc_component_get_drvdata(component);
- u16 decimator;
+ u8 decimator;
/* active decimator not set yet */
if (tx->active_decimator[dai->id] == -1)
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds
2023-03-03 12:12 Ravulapati Vishnu Vardhan Rao
@ 2023-03-03 12:41 ` Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2023-03-03 12:41 UTC (permalink / raw)
To: Ravulapati Vishnu Vardhan Rao
Cc: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai,
moderated list:QCOM AUDIO (ASoC) DRIVERS, open list
[-- Attachment #1: Type: text/plain, Size: 508 bytes --]
On Fri, Mar 03, 2023 at 05:42:06PM +0530, Ravulapati Vishnu Vardhan Rao wrote:
> From: visr <quic_visr@quicinc.com>
You're using a different name here compared to in your email and while
it's the same mail address it's hard to relate it to your name from the
sender. "visr" sounds a bit like it might be a bot too. Could you
please supply a more clear signoff?
> Actually There is no need to have decimator with 32 bytes.
> By limiting the variable with short type u8 issue is resolved.
Bits not bytes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-03-06 12:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 12:57 [PATCH] ASoC: codecs: tx-macro: Fix for KASAN: slab-out-of-bounds Ravulapati Vishnu Vardhan Rao
2023-03-03 14:07 ` Mark Brown
2023-03-03 14:15 ` Srinivas Kandagatla
2023-03-03 17:32 ` VISHNUVARDHAN RAO RAVULAPATI
-- strict thread matches above, loose matches on Subject: below --
2023-03-04 8:07 Ravulapati Vishnu Vardhan Rao
2023-03-06 12:45 ` Mark Brown
2023-03-03 12:12 Ravulapati Vishnu Vardhan Rao
2023-03-03 12:41 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®