linux/sound/soc
Hui Wang 0b3d5d2e35
ASoC: cs35l41: Fix a shift-out-of-bounds warning found by UBSAN
We enabled UBSAN in the ubuntu kernel, and the cs35l41 driver triggers
a warning calltrace like below:

cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: bitoffset= 8, word_offset=23, bit_sum mod 32=0, otp_map[i].size = 24
cs35l41-hda i2c-CSC3551:00-cs35l41-hda.0: bitoffset= 0, word_offset=24, bit_sum mod 32=24, otp_map[i].size = 0
================================================================================
UBSAN: shift-out-of-bounds in linux-kernel-src/sound/soc/codecs/cs35l41-lib.c:836:8
shift exponent 64 is too large for 64-bit type 'long unsigned int'
CPU: 10 PID: 595 Comm: systemd-udevd Not tainted 5.15.0-23-generic #23
Hardware name: LENOVO \x02MFG_IN_GO/\x02MFG_IN_GO, BIOS N3GET19W (1.00 ) 03/11/2022
Call Trace:
 <TASK>
 show_stack+0x52/0x58
 dump_stack_lvl+0x4a/0x5f
 dump_stack+0x10/0x12
 ubsan_epilogue+0x9/0x45
 __ubsan_handle_shift_out_of_bounds.cold+0x61/0xef
 ? regmap_unlock_mutex+0xe/0x10
 cs35l41_otp_unpack.cold+0x1c6/0x2b2 [snd_soc_cs35l41_lib]
 cs35l41_hda_probe+0x24f/0x33a [snd_hda_scodec_cs35l41]
 cs35l41_hda_i2c_probe+0x65/0x90 [snd_hda_scodec_cs35l41_i2c]

When both bitoffset and otp_map[i].size are 0, the line 836 will
result in GENMASK(-1, 0), this triggers the shift-out-of-bounds
calltrace.

Here add a checking, if both bitoffset and otp_map[i].size are 0,
do not run GENMASK() and directly set otp_val to 0, this will not
bring any function change on the driver but could avoid the calltrace.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Link: https://lore.kernel.org/r/20220324081839.62009-2-hui.wang@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-05 10:24:49 +01:00
..
adi
amd ASoC: Updates for v5.18 2022-03-21 16:19:21 +01:00
atmel ASoC: atmel: Remove system clock tree configuration for at91sam9g20ek 2022-04-04 14:24:03 +01:00
au1x ASoC: au1x: Convert to modern terminology for DAI clocking 2021-09-16 14:11:37 +01:00
bcm ASoC: bcm: Use platform_get_irq() to get the interrupt 2021-12-21 18:05:43 +00:00
cirrus ARM: SoC drivers for 5.16 2021-11-03 17:00:52 -07:00
codecs ASoC: cs35l41: Fix a shift-out-of-bounds warning found by UBSAN 2022-04-05 10:24:49 +01:00
dwc ASoC: dwc-i2s: Handle errors for clk_enable 2022-03-02 13:45:24 +00:00
fsl ASoC: Fixes for v5.18 2022-03-30 14:04:22 +02:00
generic ASoC: simple-card-utils: Don't reset clock of active DAI 2022-03-11 13:42:29 +00:00
hisilicon
img ASoC: img: Use dev_err_probe() helper 2021-12-20 12:47:16 +00:00
intel flexible-array transformations for 5.18-rc1 2022-03-24 11:39:32 -07:00
jz4740
kirkwood
mediatek ASoC: mediatek: mt8195: Fix error handling in mt8195_mt6359_rt1019_rt5682_dev_probe 2022-03-16 16:39:25 +00:00
meson ASoC: Merge fixes 2021-12-31 13:23:28 +00:00
mxs ASoC: mxs: Fix error handling in mxs_sgtl5000_probe 2022-03-08 13:41:15 +00:00
pxa ARM: pxa: remove Intel Imote2 and Stargate 2 boards 2022-02-28 15:08:14 +01:00
qcom ASoC: Updates for v5.18 2022-03-21 16:19:21 +01:00
rockchip ASoC: rockchip: i2s_tdm: Fixup config for SND_SOC_DAIFMT_DSP_A/B 2022-03-23 12:17:52 +00:00
samsung ASoC: samsung: i2s: check the return value of kstrdup() 2022-03-16 16:39:17 +00:00
sh ASoC: fsi: Add check for clk_enable 2022-03-07 13:14:56 +00:00
sof ASoC: SOF: topology: Fix memory leak of scontrol->name 2022-04-04 14:25:38 +01:00
spear
sprd ASoC: sprd: Use managed buffer allocation 2021-08-04 08:10:27 +02:00
sti ASoC: sti: Fix deadlock via snd_pcm_stop_xrun() call 2022-03-16 16:39:28 +00:00
stm ASoC: stm: Use dev_err_probe() helper 2021-12-20 12:47:23 +00:00
sunxi ASoC: sun4i-i2s: Add support for the R329/D1 variant 2022-02-03 11:30:57 +00:00
tegra ASoC: tegra20: spdif: make const array rates static 2022-02-15 12:52:44 +00:00
ti ASoC: ti: Fix spelling mistake "cant" -> "can't" 2022-03-16 16:39:21 +00:00
uniphier ASoC: uniphier: drop selecting non-existing SND_SOC_UNIPHIER_AIO_DMA 2021-11-25 11:54:30 +00:00
ux500 ASoC: ux500: mop500: Constify static snd_soc_ops 2021-09-29 13:06:38 +01:00
xilinx ASoC: xilinx: xlnx_i2s: Handle sysclk setting 2022-01-24 19:45:38 +00:00
xtensa
Kconfig
Makefile
soc-ac97.c ASoC: soc-ac97: cleanup cppcheck warning 2021-08-16 13:29:36 +01:00
soc-acpi.c ALSA: Replace acpi_bus_get_device() 2022-02-01 08:08:08 +01:00
soc-card.c
soc-component.c ASoC: soc-component: add snd_soc_pcm_component_delay() 2021-11-29 12:19:41 +00:00
soc-compress.c ASoC: soc-compress: Change the check for codec_dai 2022-03-14 08:29:11 +00:00
soc-core.c ASoC: Export DAI register and widget ctor and dctor functions 2022-03-11 16:23:53 +00:00
soc-dai.c ASoC: soc-dai: update snd_soc_dai_delay() to snd_soc_pcm_dai_delay() 2021-11-29 12:19:40 +00:00
soc-dapm.c ASoC: soc-dapm: fix two incorrect uses of list iterator 2022-04-05 10:24:44 +01:00
soc-devres.c
soc-generic-dmaengine-pcm.c ASoC: dmaengine: do not use a NULL prepare_slave_config() callback 2022-03-08 13:38:56 +00:00
soc-jack.c ASoC: soc-jack: cleanup cppcheck warning for CONFIG_GPIOLIB 2021-08-16 13:29:34 +01:00
soc-link.c
soc-ops.c ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min 2022-02-16 16:33:48 +00:00
soc-pcm.c ASoC: soc-pcm: use GFP_KERNEL when the code is sleepable 2022-04-04 14:25:39 +01:00
soc-topology-test.c
soc-topology.c ASoC: topology: Correct error handling in soc_tplg_dapm_widget_create() 2022-04-04 14:25:36 +01:00
soc-utils.c ASoC: Stop dummy from overriding hwparams 2021-10-29 16:49:45 +01:00