lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BYAPR11MB26324BC70657061DA849A384FF950@BYAPR11MB2632.namprd11.prod.outlook.com>
Date:   Wed, 24 Jun 2020 08:59:40 +0000
From:   "Zhang, Qiang" <Qiang.Zhang@...driver.com>
To:     Greg KH <gregkh@...uxfoundation.org>
CC:     "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Felipe Balbi <balbi@...nel.org>
Subject: 回复: [PATCH] usb: gadget: function: printer: Add gadget dev interface status judgment

Hello, Greg KH
Please have you review the patch?

thanks
Zqiang
________________________________________
发件人: linux-usb-owner@...r.kernel.org <linux-usb-owner@...r.kernel.org> 代表 qiang.zhang@...driver.com <qiang.zhang@...driver.com>
发送时间: 2020年6月15日 17:46
收件人: balbi@...nel.org
抄送: gregkh@...uxfoundation.org; linux-usb@...r.kernel.org; linux-kernel@...r.kernel.org
主题: [PATCH] usb: gadget: function: printer: Add gadget dev interface status judgment

From: Zqiang <qiang.zhang@...driver.com>

After the interface of gadget printer device was disabled,
We should not continue operate the device.

Signed-off-by: Zqiang <qiang.zhang@...driver.com>
---
 drivers/usb/gadget/function/f_printer.c | 36 +++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 9c7ed2539ff7..2b45a61e4213 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -338,6 +338,11 @@ printer_open(struct inode *inode, struct file *fd)

        spin_lock_irqsave(&dev->lock, flags);

+       if (dev->interface < 0) {
+               spin_unlock_irqrestore(&dev->lock, flags);
+               return -ENODEV;
+       }
+
        if (!dev->printer_cdev_open) {
                dev->printer_cdev_open = 1;
                fd->private_data = dev;
@@ -430,6 +435,12 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
        mutex_lock(&dev->lock_printer_io);
        spin_lock_irqsave(&dev->lock, flags);

+       if (dev->interface < 0) {
+               spin_unlock_irqrestore(&dev->lock, flags);
+               mutex_unlock(&dev->lock_printer_io);
+               return -ENODEV;
+       }
+
        /* We will use this flag later to check if a printer reset happened
         * after we turn interrupts back on.
         */
@@ -561,6 +572,12 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
        mutex_lock(&dev->lock_printer_io);
        spin_lock_irqsave(&dev->lock, flags);

+       if (dev->interface < 0) {
+               spin_unlock_irqrestore(&dev->lock, flags);
+               mutex_unlock(&dev->lock_printer_io);
+               return -ENODEV;
+       }
+
        /* Check if a printer reset happens while we have interrupts on */
        dev->reset_printer = 0;

@@ -667,6 +684,13 @@ printer_fsync(struct file *fd, loff_t start, loff_t end, int datasync)

        inode_lock(inode);
        spin_lock_irqsave(&dev->lock, flags);
+
+       if (dev->interface < 0) {
+               spin_unlock_irqrestore(&dev->lock, flags);
+               inode_unlock(inode);
+               return -ENODEV;
+       }
+
        tx_list_empty = (likely(list_empty(&dev->tx_reqs)));
        spin_unlock_irqrestore(&dev->lock, flags);

@@ -689,6 +713,13 @@ printer_poll(struct file *fd, poll_table *wait)

        mutex_lock(&dev->lock_printer_io);
        spin_lock_irqsave(&dev->lock, flags);
+
+       if (dev->interface < 0) {
+               spin_unlock_irqrestore(&dev->lock, flags);
+               mutex_unlock(&dev->lock_printer_io);
+               return EPOLLERR | EPOLLHUP;
+       }
+
        setup_rx_reqs(dev);
        spin_unlock_irqrestore(&dev->lock, flags);
        mutex_unlock(&dev->lock_printer_io);
@@ -722,6 +753,11 @@ printer_ioctl(struct file *fd, unsigned int code, unsigned long arg)

        spin_lock_irqsave(&dev->lock, flags);

+       if (dev->interface < 0) {
+               spin_unlock_irqrestore(&dev->lock, flags);
+               return -ENODEV;
+       }
+
        switch (code) {
        case GADGET_GET_PRINTER_STATUS:
                status = (int)dev->printer_status;
--
2.24.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ