msm: adsprpc: Validate sessions of process are of same pd type on same dsp.

Currently, a single process can create multiple sessions of different pd types.
 Now, force all sessions of a process to be of same pd type on same dsp. Also,
allow untrusted apps to create multiple sessions on dsp.

Signed-off-by: Krishna Dogney <quic_kdogney@quicinc.com>
Change-Id:I98c97c1ceeefa303cee4909ccca280a2430da908
这个提交包含在:
Krishna Dogney
2023-06-05 15:53:29 -07:00
父节点 b0308ca14e
当前提交 49d8960d0c

查看文件

@@ -3943,9 +3943,12 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl,
struct smq_phy_page pages[PAGESLEN_WITH_SHAREDBUF];
struct fastrpc_mmap *file = NULL;
struct fastrpc_buf *imem = NULL;
unsigned long imem_dma_attr = 0;
unsigned long imem_dma_attr = 0, irq_flags = 0;
remote_arg_t ra[6];
int fds[6];
struct fastrpc_apps *me = &gfa;
struct hlist_node *n = NULL;
struct fastrpc_file *fl_curr = NULL;
unsigned int gid = 0, one_mb = 1024*1024;
unsigned int dsp_userpd_memlen = 0;
struct fastrpc_buf *init_mem;
@@ -3993,6 +3996,20 @@ static int fastrpc_init_create_dynamic_process(struct fastrpc_file *fl,
if (uproc->attrs & FASTRPC_MODE_UNSIGNED_MODULE)
fl->is_unsigned_pd = true;
/* Validate that any existing sessions of process are of same pd type */
spin_lock_irqsave(&me->hlock, irq_flags);
hlist_for_each_entry_safe(fl_curr, n, &me->drivers, hn) {
if ((fl != fl_curr) && (fl->tgid == fl_curr->tgid) && (fl->cid == fl_curr->cid)) {
err = (fl->is_unsigned_pd != fl_curr->is_unsigned_pd) ? -ECONNREFUSED : 0;
break;
}
}
spin_unlock_irqrestore(&me->hlock, irq_flags);
if (err) {
ADSPRPC_ERR("existing session pd type %u not same as requested pd type %u \n",
fl_curr->is_unsigned_pd, fl->is_unsigned_pd);
goto bail;
}
/* Check if file memory passed by userspace is valid */
VERIFY(err, access_ok((void __user *)init->file, init->filelen));
if (err)
@@ -6765,12 +6782,6 @@ int fastrpc_setmode(unsigned long ioctl_param,
fl->profile = (uint32_t)ioctl_param;
break;
case FASTRPC_MODE_SESSION:
if (fl->untrusted_process) {
err = -EPERM;
ADSPRPC_ERR(
"multiple sessions not allowed for untrusted apps\n");
goto bail;
}
if (!fl->multi_session_support)
fl->sessionid = 1;
break;
@@ -6778,7 +6789,6 @@ int fastrpc_setmode(unsigned long ioctl_param,
err = -ENOTTY;
break;
}
bail:
return err;
}