sound/soc/sof/ipc3-dtrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Fix a potential integer overflow vulnerability in trace_filter_parse()
where the allocation size calculation could overflow.
The issue occurs when:
1. capacity is calculated by adding TRACE_FILTER_ELEMENTS_PER_ENTRY in a
loop for each entry found in the input string.
2. capacity * sizeof(**out) multiplication could overflow if many
entries are present in the input.
3. This results in a smaller allocation than expected, leading to
potential buffer overflow.
Replace kmalloc() with kmalloc_array() which provides built-in overflow
checking and will safely fail the allocation if overflow would occur,
preventing memory corruption.
Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@oracle.com>
---
sound/soc/sof/ipc3-dtrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/sof/ipc3-dtrace.c b/sound/soc/sof/ipc3-dtrace.c
index e5c8fec173c4..6ec391fd39a9 100644
--- a/sound/soc/sof/ipc3-dtrace.c
+++ b/sound/soc/sof/ipc3-dtrace.c
@@ -126,7 +126,7 @@ static int trace_filter_parse(struct snd_sof_dev *sdev, char *string,
capacity += TRACE_FILTER_ELEMENTS_PER_ENTRY;
entry = strchr(entry + 1, entry_delimiter[0]);
}
- *out = kmalloc(capacity * sizeof(**out), GFP_KERNEL);
+ *out = kmalloc_array(capacity, sizeof(**out), GFP_KERNEL);
if (!*out)
return -ENOMEM;
--
2.50.1
On Tue, 09 Sep 2025 15:51:11 -0700, Samasth Norway Ananda wrote: > Fix a potential integer overflow vulnerability in trace_filter_parse() > where the allocation size calculation could overflow. > > The issue occurs when: > 1. capacity is calculated by adding TRACE_FILTER_ELEMENTS_PER_ENTRY in a > loop for each entry found in the input string. > 2. capacity * sizeof(**out) multiplication could overflow if many > entries are present in the input. > 3. This results in a smaller allocation than expected, leading to > potential buffer overflow. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/1] ASoC: SOF: ipc3-dtrace: fix potential integer overflow in allocation commit: ce2335cd14b6585d57dc05a4375a506079adba81 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
© 2016 - 2025 Red Hat, Inc.