Pārlūkot izejas kodu

dsp-kernel: Validate the CID before accessing the channel mutex

In the early stages of fastrpc_internal_invoke, we validate the user CID
and handle failure cases. However, in the error scenario, an invalid CID
can lead to issues when accessing the channel mutex. To prevent this, we
should validate the CID before accessing the channel mutex via fastrpc
user structure.

Change-Id: Ic1f7ae01a749b57c9b9e69210314d694ebcf300b
Signed-off-by: Santosh <[email protected]>
Santosh 8 mēneši atpakaļ
vecāks
revīzija
a4afa6832a
1 mainītis faili ar 2 papildinājumiem un 3 dzēšanām
  1. 2 3
      dsp/adsprpc.c

+ 2 - 3
dsp/adsprpc.c

@@ -3499,10 +3499,9 @@ int fastrpc_internal_invoke(struct fastrpc_file *fl, uint32_t mode,
 		context_free(ctx);
 		trace_fastrpc_msg("context_free: end");
 	}
-	if (!kernel) {
+	if (!kernel && VALID_FASTRPC_CID(cid)) {
 		mutex_lock(&fl->apps->channel[cid].smd_mutex);
-		if (VALID_FASTRPC_CID(cid)
-			&& (fl->ssrcount != fl->apps->channel[cid].ssrcount))
+		if (fl->ssrcount != fl->apps->channel[cid].ssrcount)
 			err = -ECONNRESET;
 		mutex_unlock(&fl->apps->channel[cid].smd_mutex);
 	}