Merge SCSI_IOCTL_SEND_COMMAND cleanup branch.
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 Aug 2018 17:54:25 +0000 (10:54 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 Aug 2018 17:54:25 +0000 (10:54 -0700)
Nobody commented on this patch back in July. So now it gets merged.

* SCSI_IOCTL_SEND_COMMAND cleanup:
  scsi sg: remove incorrect scsi command checking logic

1  2 
drivers/scsi/sg.c

diff --combined drivers/scsi/sg.c
@@@ -1103,15 -1103,6 +1103,6 @@@ sg_ioctl(struct file *filp, unsigned in
        case SCSI_IOCTL_SEND_COMMAND:
                if (atomic_read(&sdp->detaching))
                        return -ENODEV;
-               if (read_only) {
-                       unsigned char opcode = WRITE_6;
-                       Scsi_Ioctl_Command __user *siocp = p;
-                       if (copy_from_user(&opcode, siocp->data, 1))
-                               return -EFAULT;
-                       if (sg_allow_access(filp, &opcode))
-                               return -EPERM;
-               }
                return sg_scsi_ioctl(sdp->device->request_queue, NULL, filp->f_mode, p);
        case SG_SET_DEBUG:
                result = get_user(val, ip);
@@@ -1741,11 -1732,15 +1732,11 @@@ sg_start_req(Sg_request *srp, unsigned 
         *
         * With scsi-mq enabled, there are a fixed number of preallocated
         * requests equal in number to shost->can_queue.  If all of the
 -       * preallocated requests are already in use, then using GFP_ATOMIC with
 -       * blk_get_request() will return -EWOULDBLOCK, whereas using GFP_KERNEL
 -       * will cause blk_get_request() to sleep until an active command
 -       * completes, freeing up a request.  Neither option is ideal, but
 -       * GFP_KERNEL is the better choice to prevent userspace from getting an
 -       * unexpected EWOULDBLOCK.
 -       *
 -       * With scsi-mq disabled, blk_get_request() with GFP_KERNEL usually
 -       * does not sleep except under memory pressure.
 +       * preallocated requests are already in use, then blk_get_request()
 +       * will sleep until an active command completes, freeing up a request.
 +       * Although waiting in an asynchronous interface is less than ideal, we
 +       * do not want to use BLK_MQ_REQ_NOWAIT here because userspace might
 +       * not expect an EWOULDBLOCK from this condition.
         */
        rq = blk_get_request(q, hp->dxfer_direction == SG_DXFER_TO_DEV ?
                        REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0);
@@@ -2181,7 -2176,6 +2172,7 @@@ sg_add_sfp(Sg_device * sdp
        write_lock_irqsave(&sdp->sfd_lock, iflags);
        if (atomic_read(&sdp->detaching)) {
                write_unlock_irqrestore(&sdp->sfd_lock, iflags);
 +              kfree(sfp);
                return ERR_PTR(-ENODEV);
        }
        list_add_tail(&sfp->sfd_siblings, &sdp->sfds);