linux/sound/soc/fsl
Silvio Cesare c407cd008f
ASoC: imx-audmux: change snprintf to scnprintf for possible overflow
Change snprintf to scnprintf. There are generally two cases where using
snprintf causes problems.

1) Uses of size += snprintf(buf, SIZE - size, fmt, ...)
In this case, if snprintf would have written more characters than what the
buffer size (SIZE) is, then size will end up larger than SIZE. In later
uses of snprintf, SIZE - size will result in a negative number, leading
to problems. Note that size might already be too large by using
size = snprintf before the code reaches a case of size += snprintf.

2) If size is ultimately used as a length parameter for a copy back to user
space, then it will potentially allow for a buffer overflow and information
disclosure when size is greater than SIZE. When the size is used to index
the buffer directly, we can have memory corruption. This also means when
size = snprintf... is used, it may also cause problems since size may become
large.  Copying to userspace is mitigated by the HARDENED_USERCOPY kernel
configuration.

The solution to these issues is to use scnprintf which returns the number of
characters actually written to the buffer, so the size variable will never
exceed SIZE.

Signed-off-by: Silvio Cesare <silvio.cesare@gmail.com>
Cc: Timur Tabi <timur@kernel.org>
Cc: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Xiubo Li <Xiubo.Lee@gmail.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-15 19:06:08 +00:00
..
efika-audio-fabric.c ASoC: mpc5200_psc_ac97: Remove unused DAI ID defines 2017-01-10 18:45:26 +00:00
eukrea-tlv320.c ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h 2017-12-04 18:06:36 +00:00
fsl_asrc_dma.c ASoC: add for_each_dpcm_be() macro 2018-09-20 10:31:20 -07:00
fsl_asrc.c ASoC: fsl_asrc: Switch to SPDX identifier 2018-07-24 16:58:59 +01:00
fsl_asrc.h ASoC: fsl_asrc: Switch to SPDX identifier 2018-07-24 16:58:59 +01:00
fsl_dma.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2018-04-05 11:56:35 -07:00
fsl_dma.h ASoC: multi-component - ASoC Multi-Component Support 2010-08-12 14:00:00 +01:00
fsl_esai.c ASoC: Convert to using %pOFn instead of device_node.name 2018-08-28 19:07:00 +01:00
fsl_esai.h ASoC: fsl_esai: Switch to SPDX identifier 2018-05-03 10:29:05 +09:00
fsl_sai.c ASoC: fsl_sai: Switch to SPDX identifier 2018-05-03 10:28:59 +09:00
fsl_sai.h ASoC: fsl_sai: Switch to SPDX identifier 2018-05-03 10:28:59 +09:00
fsl_spdif.c ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit 2018-07-05 11:07:59 +01:00
fsl_spdif.h ASoC: fsl_spdif: Switch to SPDX identifier 2018-05-03 10:29:14 +09:00
fsl_ssi_dbg.c ASoC: fsl_ssi: Change to use DEFINE_SHOW_ATTRIBUTE macro 2018-11-07 14:59:37 +00:00
fsl_ssi.c ASoC: fsl_ssi: Switch to SPDX identifier 2018-05-03 10:28:43 +09:00
fsl_ssi.h ASoC: fsl_ssi: Switch to SPDX identifier 2018-05-03 10:28:43 +09:00
fsl_utils.c ASoC: Convert to using %pOFn instead of device_node.name 2018-08-28 19:07:00 +01:00
fsl_utils.h ASoC: fsl_utils: Switch to SPDX identifier 2018-07-24 16:59:03 +01:00
fsl-asoc-card.c ASoC: Use of_node_name_eq for node name comparisons 2018-12-06 12:56:39 +00:00
imx-audmux.c ASoC: imx-audmux: change snprintf to scnprintf for possible overflow 2019-01-15 19:06:08 +00:00
imx-audmux.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
imx-es8328.c ASoC: fsl: Remove superfluous snd_soc_jack_free_gpios() call 2017-08-22 13:38:39 +01:00
imx-mc13783.c ASoC: fsl: constify snd_soc_ops structures 2017-03-15 13:34:32 +00:00
imx-pcm-dma.c ASoC: imx-pcm-dma: simplify pcm_config 2017-03-08 10:58:42 +01:00
imx-pcm-fiq.c ASoC: fsl: imx: replace platform to component 2018-02-12 11:45:24 +00:00
imx-pcm.h ASoC: fsl: Add dedicated DMA buffer size for each cpu dai 2015-07-07 13:16:12 +01:00
imx-sgtl5000.c ASoC: imx-sgtl5000: Switch to SPDX identifier 2018-07-24 16:59:07 +01:00
imx-spdif.c ASoC: imx-spdif: Fix crash on suspend 2016-01-27 11:30:02 +00:00
imx-ssi.c ASoC: imx-ssi: add check on platform_get_irq return value 2017-07-07 13:50:43 +01:00
imx-ssi.h ASoC: fsl: imx-ssi: omit ssi counter to avoid harm in unbalanced situation 2013-12-02 11:57:02 +00:00
Kconfig ASoC: fsl: Fix SND_SOC_EUKREA_TLV320 build error on i.MX8M 2018-12-13 11:01:51 +00:00
Makefile ASoC: imx-wm8962: Remove machine driver 2018-02-27 10:40:08 +00:00
mpc5200_dma.c ASoC: fsl: mpc5200: replace platform to component 2018-02-12 11:45:25 +00:00
mpc5200_dma.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mpc5200_psc_ac97.c ASoC: mpc5200_psc_ac97: Remove unused DAI ID defines 2017-01-10 18:45:26 +00:00
mpc5200_psc_i2s.c ASoC: fsl: constify of_device_id array 2015-03-22 18:02:56 +00:00
mpc8610_hpcd.c ASoC: fsl: constify snd_soc_ops structures 2017-03-15 13:34:32 +00:00
mx27vis-aic32x4.c ASoC: fsl: constify snd_soc_ops structures 2017-03-15 13:34:32 +00:00
p1022_ds.c ASoC: fsl: constify snd_soc_ops structures 2017-03-15 13:34:32 +00:00
p1022_rdk.c ASoC: fsl: constify snd_soc_ops structures 2017-03-15 13:34:32 +00:00
pcm030-audio-fabric.c ASoC: add for_each_card_prelinks() macro 2018-09-20 10:18:34 -07:00
phycore-ac97.c ASoC: fsl: constify snd_soc_ops structures 2017-03-15 13:34:32 +00:00
wm1133-ev1.c ASoC: wm8350: replace codec to component 2018-02-12 09:39:59 +00:00