ASoC: wm_adsp: Prevent negative string length in wm_adsp_control_add()
Subsystems (3)
PATCH 1/1 ASoC: wm_adsp: Prevent negative string length in wm_adsp_control_add()
Check that avail does not become < 1 in wm_adsp_control_add(). This prevents overflows during subsequent operations.
The main aim is to trap a negative value in avail, but a zero length would mean that the control ends up without a name, so 1 is the smallest valid value.
--- sound/soc/codecs/wm_adsp.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/soc/codecs/wm_adsp.c +10 -0
@@ -46,6 +46,9 @@#define adsp_dbg (_dsp, fmt, ...) \ dev_dbg(_dsp->cs_dsp.dev, "%s: " fmt, _dsp->cs_dsp.name, ##__VA_ARGS__) +#define adsp_warn_once (_dsp, fmt, ...) \ + dev_warn_once(_dsp->cs_dsp.dev, "%s: " fmt, _dsp->cs_dsp.name, ##__VA_ARGS__) +#define compr_err (_obj, fmt, ...) \ adsp_err(_obj->dsp, "%s: " fmt, _obj->name ? _obj->name : "legacy", \ ##__VA_ARGS__)
@@ -625,6 +628,13 @@ int wm_adsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl)if (dsp->component->name_prefix) avail -=strlen (dsp->component->name_prefix) +1 ; +if (avail <1 ) { +adsp_warn_once (dsp, +"%.*s: ALSA prefix too long: control not created\n" , + cs_ctl->subname_len, cs_ctl->subname); +return -EINVAL ; + } +/* Truncate the subname from the start if it is too long */ if (cs_ctl->subname_len > avail) skip = cs_ctl->subname_len - avail;
Signature · 1 line
2.47.3
Mark Brown
maintainerQuoted 1 line · Richard Fitzgerald
ASoC:
wm_adsp: Prevent negative string length inwm_adsp_control_add()
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[1/1] ASoC: wm_adsp: Prevent negative string length in wm_adsp_control_add()
https://git.kernel.org/broonie/sound/c/4d07af76ca41
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