Each VirtIO SOF guest has a component ID range, assigned to it. Add a check to make sure, that guests stay within their ranges. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@xxxxxxxxxxxxxxx> --- sound/soc/sof/vhost-be.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sound/soc/sof/vhost-be.c b/sound/soc/sof/vhost-be.c index b3d7cfc..e1dede9 100644 --- a/sound/soc/sof/vhost-be.c +++ b/sound/soc/sof/vhost-be.c @@ -386,8 +386,6 @@ static int dsp_sof_ipc_stream(struct snd_sof_dev *sdev, u32 cmd = hdr->cmd & SOF_CMD_TYPE_MASK; struct snd_soc_dpcm *dpcm; - /* TODO validate host comp id range based on vm_id */ - switch (cmd) { case SOF_IPC_STREAM_PCM_PARAMS: ret = dsp_sof_pcm_open(sdev, hdr); @@ -538,6 +536,10 @@ static int dsp_sof_ipc_tplg_comp_new(struct dsp_sof_client *client, int vq_idx, struct sof_ipc_comp_host *host; struct dsp_pipeline_connect *conn; + if (comp->id < client->comp_id_begin || + comp->id >= client->comp_id_end) + return -EINVAL; + switch (comp->type) { case SOF_COMP_VIRT_CON: list_for_each_entry(conn, &sdev->connector_list, list) @@ -714,7 +716,6 @@ static int dsp_sof_ipc_tplg(struct dsp_sof_client *client, int vq_idx, struct sof_ipc_cmd_hdr *hdr, void *reply_buf, size_t reply_sz) { - /* TODO validate host comp id range based on vm_id */ u32 cmd = hdr->cmd & SOF_CMD_TYPE_MASK; int ret; @@ -784,8 +785,6 @@ static int dsp_sof_ipc_stream_codec(struct snd_sof_dev *sdev, unsigned int i; int direction; - /* TODO validate host comp id range based on vm_id */ - if (!dsp_sof_find_spcm_comp(sdev, stream->comp_id, &direction)) return -ENODEV; -- 1.9.3