Skip to content

Commit e1bc113

Browse files
committed
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
2 parents 394f33f + 2374bf7 commit e1bc113

File tree

3 files changed

+37
-30
lines changed

3 files changed

+37
-30
lines changed

drivers/char/xillybus/xillyusb.c

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ MODULE_LICENSE("GPL v2");
5050
static const char xillyname[] = "xillyusb";
5151

5252
static unsigned int fifo_buf_order;
53+
static struct workqueue_struct *wakeup_wq;
5354

5455
#define USB_VENDOR_ID_XILINX 0x03fd
5556
#define USB_VENDOR_ID_ALTERA 0x09fb
@@ -569,10 +570,6 @@ static void cleanup_dev(struct kref *kref)
569570
* errors if executed. The mechanism relies on that xdev->error is assigned
570571
* a non-zero value by report_io_error() prior to queueing wakeup_all(),
571572
* which prevents bulk_in_work() from calling process_bulk_in().
572-
*
573-
* The fact that wakeup_all() and bulk_in_work() are queued on the same
574-
* workqueue makes their concurrent execution very unlikely, however the
575-
* kernel's API doesn't seem to ensure this strictly.
576573
*/
577574

578575
static void wakeup_all(struct work_struct *work)
@@ -627,7 +624,7 @@ static void report_io_error(struct xillyusb_dev *xdev,
627624

628625
if (do_once) {
629626
kref_get(&xdev->kref); /* xdev is used by work item */
630-
queue_work(xdev->workq, &xdev->wakeup_workitem);
627+
queue_work(wakeup_wq, &xdev->wakeup_workitem);
631628
}
632629
}
633630

@@ -1906,6 +1903,13 @@ static const struct file_operations xillyusb_fops = {
19061903

19071904
static int xillyusb_setup_base_eps(struct xillyusb_dev *xdev)
19081905
{
1906+
struct usb_device *udev = xdev->udev;
1907+
1908+
/* Verify that device has the two fundamental bulk in/out endpoints */
1909+
if (usb_pipe_type_check(udev, usb_sndbulkpipe(udev, MSG_EP_NUM)) ||
1910+
usb_pipe_type_check(udev, usb_rcvbulkpipe(udev, IN_EP_NUM)))
1911+
return -ENODEV;
1912+
19091913
xdev->msg_ep = endpoint_alloc(xdev, MSG_EP_NUM | USB_DIR_OUT,
19101914
bulk_out_work, 1, 2);
19111915
if (!xdev->msg_ep)
@@ -1935,14 +1939,15 @@ static int setup_channels(struct xillyusb_dev *xdev,
19351939
__le16 *chandesc,
19361940
int num_channels)
19371941
{
1938-
struct xillyusb_channel *chan;
1942+
struct usb_device *udev = xdev->udev;
1943+
struct xillyusb_channel *chan, *new_channels;
19391944
int i;
19401945

19411946
chan = kcalloc(num_channels, sizeof(*chan), GFP_KERNEL);
19421947
if (!chan)
19431948
return -ENOMEM;
19441949

1945-
xdev->channels = chan;
1950+
new_channels = chan;
19461951

19471952
for (i = 0; i < num_channels; i++, chan++) {
19481953
unsigned int in_desc = le16_to_cpu(*chandesc++);
@@ -1971,6 +1976,15 @@ static int setup_channels(struct xillyusb_dev *xdev,
19711976
*/
19721977

19731978
if ((out_desc & 0x80) && i < 14) { /* Entry is valid */
1979+
if (usb_pipe_type_check(udev,
1980+
usb_sndbulkpipe(udev, i + 2))) {
1981+
dev_err(xdev->dev,
1982+
"Missing BULK OUT endpoint %d\n",
1983+
i + 2);
1984+
kfree(new_channels);
1985+
return -ENODEV;
1986+
}
1987+
19741988
chan->writable = 1;
19751989
chan->out_synchronous = !!(out_desc & 0x40);
19761990
chan->out_seekable = !!(out_desc & 0x20);
@@ -1980,6 +1994,7 @@ static int setup_channels(struct xillyusb_dev *xdev,
19801994
}
19811995
}
19821996

1997+
xdev->channels = new_channels;
19831998
return 0;
19841999
}
19852000

@@ -2096,9 +2111,11 @@ static int xillyusb_discovery(struct usb_interface *interface)
20962111
* just after responding with the IDT, there is no reason for any
20972112
* work item to be running now. To be sure that xdev->channels
20982113
* is updated on anything that might run in parallel, flush the
2099-
* workqueue, which rarely does anything.
2114+
* device's workqueue and the wakeup work item. This rarely
2115+
* does anything.
21002116
*/
21012117
flush_workqueue(xdev->workq);
2118+
flush_work(&xdev->wakeup_workitem);
21022119

21032120
xdev->num_channels = num_channels;
21042121

@@ -2258,19 +2275,28 @@ static int __init xillyusb_init(void)
22582275
{
22592276
int rc = 0;
22602277

2278+
wakeup_wq = alloc_workqueue(xillyname, 0, 0);
2279+
if (!wakeup_wq)
2280+
return -ENOMEM;
2281+
22612282
if (LOG2_INITIAL_FIFO_BUF_SIZE > PAGE_SHIFT)
22622283
fifo_buf_order = LOG2_INITIAL_FIFO_BUF_SIZE - PAGE_SHIFT;
22632284
else
22642285
fifo_buf_order = 0;
22652286

22662287
rc = usb_register(&xillyusb_driver);
22672288

2289+
if (rc)
2290+
destroy_workqueue(wakeup_wq);
2291+
22682292
return rc;
22692293
}
22702294

22712295
static void __exit xillyusb_exit(void)
22722296
{
22732297
usb_deregister(&xillyusb_driver);
2298+
2299+
destroy_workqueue(wakeup_wq);
22742300
}
22752301

22762302
module_init(xillyusb_init);

drivers/misc/fastrpc.c

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

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-
20982088
static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
20992089
unsigned long arg)
21002090
{
@@ -2107,19 +2097,13 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
21072097
err = fastrpc_invoke(fl, argp);
21082098
break;
21092099
case FASTRPC_IOCTL_INIT_ATTACH:
2110-
err = is_attach_rejected(fl);
2111-
if (!err)
2112-
err = fastrpc_init_attach(fl, ROOT_PD);
2100+
err = fastrpc_init_attach(fl, ROOT_PD);
21132101
break;
21142102
case FASTRPC_IOCTL_INIT_ATTACH_SNS:
2115-
err = is_attach_rejected(fl);
2116-
if (!err)
2117-
err = fastrpc_init_attach(fl, SENSORS_PD);
2103+
err = fastrpc_init_attach(fl, SENSORS_PD);
21182104
break;
21192105
case FASTRPC_IOCTL_INIT_CREATE_STATIC:
2120-
err = is_attach_rejected(fl);
2121-
if (!err)
2122-
err = fastrpc_init_create_static_process(fl, argp);
2106+
err = fastrpc_init_create_static_process(fl, argp);
21232107
break;
21242108
case FASTRPC_IOCTL_INIT_CREATE:
21252109
err = fastrpc_init_create_process(fl, argp);

include/uapi/misc/fastrpc.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
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 */
1211
#define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4)
1312
#define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create)
1413
#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap)
1514
#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap)
16-
/* This ioctl is only supported with secure device nodes */
1715
#define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)
18-
/* This ioctl is only supported with secure device nodes */
1916
#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static)
2017
#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map)
2118
#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap)

0 commit comments

Comments
 (0)