Skip to content

Commit b08c3ce

Browse files
author
Jyri Sarha
committed
plugin: tplg: bound pipeline_list against TPLG_MAX_PCM_PIPELINES
plug_prepare_widget() appends each new pipeline referenced by a PCM into the fixed-size pipeline_list->pipelines[] array: pipeline_list->pipelines[pipeline_list->count] = comp_info->pipe_info; pipeline_list->count++; The array has only TPLG_MAX_PCM_PIPELINES entries, but the number of pipelines bound to a PCM is dictated by the topology graph, which comes from the .tplg file loaded by the SOF ALSA plugin. With no upper-bound check, a topology that binds more than TPLG_MAX_PCM_PIPELINES pipelines to a single PCM writes past the end of the array. Reject the store with -EINVAL once the list is full, before writing past the end of the array. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 3f7738d commit b08c3ce

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tools/plugin/alsaplug/tplg.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,12 @@ static int plug_prepare_widget(snd_sof_plug_t *plug, struct tplg_pcm_info *pcm_i
999999
}
10001000

10011001
if (i == pipeline_list->count) {
1002+
if (pipeline_list->count >= TPLG_MAX_PCM_PIPELINES) {
1003+
SNDERR("error: too many pipelines for PCM, max %d\n",
1004+
TPLG_MAX_PCM_PIPELINES);
1005+
return -EINVAL;
1006+
}
1007+
10021008
pipeline_list->pipelines[pipeline_list->count] = comp_info->pipe_info;
10031009
pipeline_list->count++;
10041010
}

0 commit comments

Comments
 (0)