This reverts commit bab2f5e8fd5d2f759db26b78d9db57412888f187. Joel reported that this commit breaks userspace and stops sensors in SDM845 from working. Also breaks other qcom SoC devices running postmarketOS.
Unified · Split
| @@ -2085,16 +2085,6 @@ err_invoke: · 2084 unmodified lines | |||
| 2085 | return err; | 2085 | return err; |
| 2086 | } | 2086 | } |
| 2087 | 2087 | ||
| 2088 | static int is_attach_rejected(struct fastrpc_user *fl) | ||
| 2089 | { | ||
| 2090 | /* Check if the device node is non-secure */ | ||
| 2091 | if (!fl->is_secure_dev) { | ||
| 2092 | dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n"); | ||
| 2093 | return -EACCES; | ||
| 2094 | } | ||
| 2095 | return 0; | ||
| 2096 | } | ||
| 2097 | |||
| 2098 | static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, | 2088 | static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, |
| 2099 | unsigned long arg) | 2089 | unsigned long arg) |
| 2100 | { | 2090 | { |
| @@ -2107,19 +2097,13 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, · 6 unmodified lines | |||
| 2107 | err = fastrpc_invoke(fl, argp); | 2097 | err = fastrpc_invoke(fl, argp); |
| 2108 | break; | 2098 | break; |
| 2109 | case FASTRPC_IOCTL_INIT_ATTACH: | 2099 | case FASTRPC_IOCTL_INIT_ATTACH: |
| 2110 | err = is_attach_rejected(fl); | 2100 | err = fastrpc_init_attach(fl, ROOT_PD); |
| 2111 | if (!err) | ||
| 2112 | err = fastrpc_init_attach(fl, ROOT_PD); | ||
| 2113 | break; | 2101 | break; |
| 2114 | case FASTRPC_IOCTL_INIT_ATTACH_SNS: | 2102 | case FASTRPC_IOCTL_INIT_ATTACH_SNS: |
| 2115 | err = is_attach_rejected(fl); | 2103 | err = fastrpc_init_attach(fl, SENSORS_PD); |
| 2116 | if (!err) | ||
| 2117 | err = fastrpc_init_attach(fl, SENSORS_PD); | ||
| 2118 | break; | 2104 | break; |
| 2119 | case FASTRPC_IOCTL_INIT_CREATE_STATIC: | 2105 | case FASTRPC_IOCTL_INIT_CREATE_STATIC: |
| 2120 | err = is_attach_rejected(fl); | 2106 | err = fastrpc_init_create_static_process(fl, argp); |
| 2121 | if (!err) | ||
| 2122 | err = fastrpc_init_create_static_process(fl, argp); | ||
| 2123 | break; | 2107 | break; |
| 2124 | case FASTRPC_IOCTL_INIT_CREATE: | 2108 | case FASTRPC_IOCTL_INIT_CREATE: |
| 2125 | err = fastrpc_init_create_process(fl, argp); | 2109 | err = fastrpc_init_create_process(fl, argp); |
| @@ -8,14 +8,11 @@ · 7 unmodified lines | |||
| 8 | #define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf) | 8 | #define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf) |
| 9 | #define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32) | 9 | #define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32) |
| 10 | #define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke) | 10 | #define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke) |
| 11 | /* This ioctl is only supported with secure device nodes */ | ||
| 12 | #define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4) | 11 | #define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4) |
| 13 | #define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create) | 12 | #define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create) |
| 14 | #define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap) | 13 | #define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap) |
| 15 | #define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap) | 14 | #define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap) |
| 16 | /* This ioctl is only supported with secure device nodes */ | ||
| 17 | #define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8) | 15 | #define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8) |
| 18 | /* This ioctl is only supported with secure device nodes */ | ||
| 19 | #define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static) | 16 | #define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static) |
| 20 | #define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map) | 17 | #define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map) |
| 21 | #define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap) | 18 | #define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap) |