Uh oh!
There was an error while loading. Please reload this page.
ASoC: rt1011: fix KASAN out-of-bounds bug in find_next_bit() - #2179
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
3fda7ee to
6e8604fCompareUh oh!
There was an error while loading. Please reload this page.
6e8604f to
1b09e4bCompareFor failure in device test in multiple-pipeline-capture.sh with CML_MANTIS_HDA, while multiple-pipeline-playback is passed. The test case was 3x arecord + 1x aplay, one of instance is not able to run, but there is no log to dig more. I don't think the failure is related with with this PR.
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
1b09e4b to
e076705Comparefredoh9
commented
Jun 10, 2020
@plbossart@ranj063 |
1970c6d to
bb90e6fComparefredoh9
commented
Jun 11, 2020
I worked on this in this morning. Just found I didn't push my last change. Sorry just pushed now. |
Uh oh!
There was an error while loading. Please reload this page.
bb90e6f to
971d7acCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
KASAN throws the following warning in rt1011.c: [ 170.777603] BUG: KASAN: stack-out-of-bounds in _find_next_bit.constprop.0+0x3e/0xf0 find_next_bit() relies on unsigned long pointer arguments, but this driver uses a type cast that generates the KASAN warning. Replace find_next_bit() and find_last_bit() with __ffs() and __fls() to pass the value and avoid casting pointers to make the warning go away. Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
971d7ac to
c9f7a3bComparekv2019i
commented
Jun 15, 2020
Thanks @fredoh9 ! |
find_next_bit() try to access out-of-bounds of unsigned int variables,
rx_mask and tx_mask. Replace with unsigned long variable to avoid
pointer casting. This is verified with KASAN.
Return value of find_next_bit() is unsigned long, this is irrelevant
with the KASAN bug. But when down casting happens, at least better match
with 'unsigned'.
KASAN bug fixed,
[ 170.777592] ==================================================================
[ 170.777603] BUG: KASAN: stack-out-of-bounds in _find_next_bit.constprop.0+0x3e/0xf0
[ 170.777608] Read of size 8 at addr ffff888202d6f530 by task aplay/1757
[ 170.777615] CPU: 0 PID: 1757 Comm: aplay Not tainted 5.7.0-rc7-test+ #3
[ 170.777617] Hardware name: Google Helios/Helios, BIOS 01/21/2020
[ 170.777618] Call Trace:
[ 170.777624] dump_stack+0x76/0xa0
[ 170.777629] print_address_description.constprop.0.cold+0xd3/0x43e
[ 170.777634] ? _raw_spin_lock_irqsave+0x7b/0xd0
[ 170.777637] ? _raw_spin_trylock_bh+0xf0/0xf0
[ 170.777640] ? _find_next_bit.constprop.0+0x3e/0xf0
[ 170.777643] __kasan_report.cold+0x37/0x86
[ 170.777647] ? regmap_readable+0xb0/0xc0
[ 170.777650] ? _find_next_bit.constprop.0+0x3e/0xf0
[ 170.777652] kasan_report+0x38/0x50
[ 170.777656] _find_next_bit.constprop.0+0x3e/0xf0
[ 170.777663] rt1011_set_tdm_slot+0x125/0x5d0 [snd_soc_rt1011]
[ 170.777669] ? rt1011_hw_params+0x2f0/0x2f0 [snd_soc_rt1011]
[ 170.777672] ? mutex_unlock+0x18/0x40
[ 170.777691] snd_soc_dai_set_tdm_slot+0x152/0x210 [snd_soc_core]
[ 170.777710] ? snd_soc_dai_set_fmt+0x80/0x80 [snd_soc_core]
[ 170.777717] cml_rt1011_hw_params+0x20c/0x320 [snd_soc_cml_rt1011_rt5682]
[ 170.777735] snd_soc_link_hw_params+0x59/0x90 [snd_soc_core]
[ 170.777752] soc_pcm_hw_params+0x42c/0xb10 [snd_soc_core]
[ 170.777771] ? soc_pcm_open+0xbd0/0xbd0 [snd_soc_core]
Signed-off-by: Fred Oh fred.oh@linux.intel.com
fixes: #2176