Skip to content

Commit bab2f5e

Browse files
Ekansh Guptagregkh
authored andcommitted
misc: fastrpc: Restrict untrusted app to attach to privileged PD
Untrusted application with access to only non-secure fastrpc device node can attach to root_pd or static PDs if it can make the respective init request. This can cause problems as the untrusted application can send bad requests to root_pd or static PDs. Add changes to reject attach to privileged PDs if the request is being made using non-secure fastrpc device node. Fixes: 0871561 ("misc: fastrpc: Add support for audiopd") Cc: stable <[email protected]> Signed-off-by: Ekansh Gupta <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a6f2f15 commit bab2f5e

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

drivers/misc/fastrpc.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,16 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
20872087
return err;
20882088
}
20892089

2090+
static int is_attach_rejected(struct fastrpc_user *fl)
2091+
{
2092+
/* Check if the device node is non-secure */
2093+
if (!fl->is_secure_dev) {
2094+
dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n");
2095+
return -EACCES;
2096+
}
2097+
return 0;
2098+
}
2099+
20902100
static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
20912101
unsigned long arg)
20922102
{
@@ -2099,13 +2109,19 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
20992109
err = fastrpc_invoke(fl, argp);
21002110
break;
21012111
case FASTRPC_IOCTL_INIT_ATTACH:
2102-
err = fastrpc_init_attach(fl, ROOT_PD);
2112+
err = is_attach_rejected(fl);
2113+
if (!err)
2114+
err = fastrpc_init_attach(fl, ROOT_PD);
21032115
break;
21042116
case FASTRPC_IOCTL_INIT_ATTACH_SNS:
2105-
err = fastrpc_init_attach(fl, SENSORS_PD);
2117+
err = is_attach_rejected(fl);
2118+
if (!err)
2119+
err = fastrpc_init_attach(fl, SENSORS_PD);
21062120
break;
21072121
case FASTRPC_IOCTL_INIT_CREATE_STATIC:
2108-
err = fastrpc_init_create_static_process(fl, argp);
2122+
err = is_attach_rejected(fl);
2123+
if (!err)
2124+
err = fastrpc_init_create_static_process(fl, argp);
21092125
break;
21102126
case FASTRPC_IOCTL_INIT_CREATE:
21112127
err = fastrpc_init_create_process(fl, argp);

include/uapi/misc/fastrpc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
#define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf)
99
#define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32)
1010
#define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke)
11+
/* This ioctl is only supported with secure device nodes */
1112
#define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4)
1213
#define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create)
1314
#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap)
1415
#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap)
16+
/* This ioctl is only supported with secure device nodes */
1517
#define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)
18+
/* This ioctl is only supported with secure device nodes */
1619
#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static)
1720
#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map)
1821
#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap)

0 commit comments

Comments
 (0)