diff mbox series

[12/14] ASoC: SOF: VirtIO: check guest component IDs

Message ID 20200312144429.17959-13-guennadi.liakhovetski@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series ASoC: SOF DSP virtualisation | expand

Commit Message

Guennadi Liakhovetski March 12, 2020, 2:44 p.m. UTC
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@linux.intel.com>
---
 sound/soc/sof/vhost-be.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Mark Brown March 13, 2020, 6:39 p.m. UTC | #1
On Thu, Mar 12, 2020 at 03:44:27PM +0100, Guennadi Liakhovetski wrote:
> Each VirtIO SOF guest has a component ID range, assigned to it. Add a
> check to make sure, that guests stay within their ranges.

Just squash this into the change introducing the code being fixed.
diff mbox series

Patch

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;