[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250909225111.3740029-1-samasth.norway.ananda@oracle.com>
Date: Tue, 9 Sep 2025 15:51:11 -0700
From: Samasth Norway Ananda <samasth.norway.ananda@...cle.com>
To: peter.ujfalusi@...ux.intel.com, yung-chuan.liao@...ux.intel.com,
ranjani.sridharan@...ux.intel.com, broonie@...nel.org,
linux-sound@...r.kernel.org, sound-open-firmware@...a-project.org
Cc: linux-kernel@...r.kernel.org, lgirdwood@...il.com, daniel.baluta@....com
Subject: [PATCH] ASoC: SOF: ipc3-dtrace: fix potential integer overflow in allocation
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@...cle.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
Powered by blists - more mailing lists