Merge tag 'char-misc-6.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char / misc fixes from Greg KH:
"Here are some small char/misc fixes for 6.11-rc4 to resolve reported
problems. Included in here are:

- fastrpc revert of a change that broke userspace

- xillybus fixes for reported issues

Half of these have been in linux-next this week with no reported
problems, I don't know if the last bit of xillybus driver changes made
it in, but they are 'obviously correct' so will be safe :)"

* tag 'char-misc-6.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
char: xillybus: Check USB endpoints when probing device
char: xillybus: Refine workqueue handling
Revert "misc: fastrpc: Restrict untrusted app to attach to privileged PD"
char: xillybus: Don't destroy workqueue from work item running on it

Changed files
+37 -30
drivers
char
xillybus
misc
include
uapi
misc
+34 -8
drivers/char/xillybus/xillyusb.c
··· 50 50 static const char xillyname[] = "xillyusb"; 51 51 52 52 static unsigned int fifo_buf_order; 53 + static struct workqueue_struct *wakeup_wq; 53 54 54 55 #define USB_VENDOR_ID_XILINX 0x03fd 55 56 #define USB_VENDOR_ID_ALTERA 0x09fb ··· 570 569 * errors if executed. The mechanism relies on that xdev->error is assigned 571 570 * a non-zero value by report_io_error() prior to queueing wakeup_all(), 572 571 * which prevents bulk_in_work() from calling process_bulk_in(). 573 - * 574 - * The fact that wakeup_all() and bulk_in_work() are queued on the same 575 - * workqueue makes their concurrent execution very unlikely, however the 576 - * kernel's API doesn't seem to ensure this strictly. 577 572 */ 578 573 579 574 static void wakeup_all(struct work_struct *work) ··· 624 627 625 628 if (do_once) { 626 629 kref_get(&xdev->kref); /* xdev is used by work item */ 627 - queue_work(xdev->workq, &xdev->wakeup_workitem); 630 + queue_work(wakeup_wq, &xdev->wakeup_workitem); 628 631 } 629 632 } 630 633 ··· 1903 1906 1904 1907 static int xillyusb_setup_base_eps(struct xillyusb_dev *xdev) 1905 1908 { 1909 + struct usb_device *udev = xdev->udev; 1910 + 1911 + /* Verify that device has the two fundamental bulk in/out endpoints */ 1912 + if (usb_pipe_type_check(udev, usb_sndbulkpipe(udev, MSG_EP_NUM)) || 1913 + usb_pipe_type_check(udev, usb_rcvbulkpipe(udev, IN_EP_NUM))) 1914 + return -ENODEV; 1915 + 1906 1916 xdev->msg_ep = endpoint_alloc(xdev, MSG_EP_NUM | USB_DIR_OUT, 1907 1917 bulk_out_work, 1, 2); 1908 1918 if (!xdev->msg_ep) ··· 1939 1935 __le16 *chandesc, 1940 1936 int num_channels) 1941 1937 { 1942 - struct xillyusb_channel *chan; 1938 + struct usb_device *udev = xdev->udev; 1939 + struct xillyusb_channel *chan, *new_channels; 1943 1940 int i; 1944 1941 1945 1942 chan = kcalloc(num_channels, sizeof(*chan), GFP_KERNEL); 1946 1943 if (!chan) 1947 1944 return -ENOMEM; 1948 1945 1949 - xdev->channels = chan; 1946 + new_channels = chan; 1950 1947 1951 1948 for (i = 0; i < num_channels; i++, chan++) { 1952 1949 unsigned int in_desc = le16_to_cpu(*chandesc++); ··· 1976 1971 */ 1977 1972 1978 1973 if ((out_desc & 0x80) && i < 14) { /* Entry is valid */ 1974 + if (usb_pipe_type_check(udev, 1975 + usb_sndbulkpipe(udev, i + 2))) { 1976 + dev_err(xdev->dev, 1977 + "Missing BULK OUT endpoint %d\n", 1978 + i + 2); 1979 + kfree(new_channels); 1980 + return -ENODEV; 1981 + } 1982 + 1979 1983 chan->writable = 1; 1980 1984 chan->out_synchronous = !!(out_desc & 0x40); 1981 1985 chan->out_seekable = !!(out_desc & 0x20); ··· 1994 1980 } 1995 1981 } 1996 1982 1983 + xdev->channels = new_channels; 1997 1984 return 0; 1998 1985 } 1999 1986 ··· 2111 2096 * just after responding with the IDT, there is no reason for any 2112 2097 * work item to be running now. To be sure that xdev->channels 2113 2098 * is updated on anything that might run in parallel, flush the 2114 - * workqueue, which rarely does anything. 2099 + * device's workqueue and the wakeup work item. This rarely 2100 + * does anything. 2115 2101 */ 2116 2102 flush_workqueue(xdev->workq); 2103 + flush_work(&xdev->wakeup_workitem); 2117 2104 2118 2105 xdev->num_channels = num_channels; 2119 2106 ··· 2275 2258 { 2276 2259 int rc = 0; 2277 2260 2261 + wakeup_wq = alloc_workqueue(xillyname, 0, 0); 2262 + if (!wakeup_wq) 2263 + return -ENOMEM; 2264 + 2278 2265 if (LOG2_INITIAL_FIFO_BUF_SIZE > PAGE_SHIFT) 2279 2266 fifo_buf_order = LOG2_INITIAL_FIFO_BUF_SIZE - PAGE_SHIFT; 2280 2267 else ··· 2286 2265 2287 2266 rc = usb_register(&xillyusb_driver); 2288 2267 2268 + if (rc) 2269 + destroy_workqueue(wakeup_wq); 2270 + 2289 2271 return rc; 2290 2272 } 2291 2273 2292 2274 static void __exit xillyusb_exit(void) 2293 2275 { 2294 2276 usb_deregister(&xillyusb_driver); 2277 + 2278 + destroy_workqueue(wakeup_wq); 2295 2279 } 2296 2280 2297 2281 module_init(xillyusb_init);
+3 -19
drivers/misc/fastrpc.c
··· 2085 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 2088 static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, 2099 2089 unsigned long arg) 2100 2090 { ··· 2097 2107 err = fastrpc_invoke(fl, argp); 2098 2108 break; 2099 2109 case FASTRPC_IOCTL_INIT_ATTACH: 2100 - err = is_attach_rejected(fl); 2101 - if (!err) 2102 - err = fastrpc_init_attach(fl, ROOT_PD); 2110 + err = fastrpc_init_attach(fl, ROOT_PD); 2103 2111 break; 2104 2112 case FASTRPC_IOCTL_INIT_ATTACH_SNS: 2105 - err = is_attach_rejected(fl); 2106 - if (!err) 2107 - err = fastrpc_init_attach(fl, SENSORS_PD); 2113 + err = fastrpc_init_attach(fl, SENSORS_PD); 2108 2114 break; 2109 2115 case FASTRPC_IOCTL_INIT_CREATE_STATIC: 2110 - err = is_attach_rejected(fl); 2111 - if (!err) 2112 - err = fastrpc_init_create_static_process(fl, argp); 2116 + err = fastrpc_init_create_static_process(fl, argp); 2113 2117 break; 2114 2118 case FASTRPC_IOCTL_INIT_CREATE: 2115 2119 err = fastrpc_init_create_process(fl, argp);
-3
include/uapi/misc/fastrpc.h
··· 8 8 #define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf) 9 9 #define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32) 10 10 #define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke) 11 - /* This ioctl is only supported with secure device nodes */ 12 11 #define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4) 13 12 #define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create) 14 13 #define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap) 15 14 #define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap) 16 - /* This ioctl is only supported with secure device nodes */ 17 15 #define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8) 18 - /* This ioctl is only supported with secure device nodes */ 19 16 #define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static) 20 17 #define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map) 21 18 #define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap)