1. 21 4月, 2017 1 次提交
  2. 06 4月, 2017 1 次提交
  3. 25 2月, 2017 1 次提交
  4. 20 2月, 2017 1 次提交
  5. 01 2月, 2017 1 次提交
    • C
      block: fold cmd_type into the REQ_OP_ space · aebf526b
      Christoph Hellwig 提交于
      Instead of keeping two levels of indirection for requests types, fold it
      all into the operations.  The little caveat here is that previously
      cmd_type only applied to struct request, while the request and bio op
      fields were set to plain REQ_OP_READ/WRITE even for passthrough
      operations.
      
      Instead this patch adds new REQ_OP_* for SCSI passthrough and driver
      private requests, althought it has to add two for each so that we
      can communicate the data in/out nature of the request.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      aebf526b
  6. 28 1月, 2017 1 次提交
  7. 23 12月, 2016 1 次提交
  8. 31 8月, 2016 2 次提交
    • P
      scsi: sg: Use mult_frac, drop MULDIV macro · f8630bd7
      Paul Burton 提交于
      The MULDIV macro is essentially a duplicate of the more standard
      mult_frac macro. Replace use of MULDIV with mult_frac & drop the
      duplication.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Acked-by: NDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      f8630bd7
    • P
      scsi: sg: Avoid overflow when USER_HZ > HZ · b9b6e80a
      Paul Burton 提交于
      Calculating the maximum timeout that a user can set via the
      SG_SET_TIMEOUT ioctl involves multiplying INT_MAX by USER_HZ/HZ. If
      USER_HZ is larger than HZ then this results in an overflow when
      performed as a 32 bit integer calculation, resulting in compiler
      warnings such as the following:
      
        drivers/scsi/sg.c: In function 'sg_ioctl':
        drivers/scsi/sg.c:91:67: warning: integer overflow in expression [-Woverflow]
         #define MULDIV(X,MUL,DIV) ((((X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
                                                                           ^
        drivers/scsi/sg.c:887:14: note: in expansion of macro 'MULDIV'
           if (val >= MULDIV (INT_MAX, USER_HZ, HZ))
                      ^
        drivers/scsi/sg.c:91:67: warning: integer overflow in expression [-Woverflow]
         #define MULDIV(X,MUL,DIV) ((((X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
                                                                           ^
        drivers/scsi/sg.c:888:13: note: in expansion of macro 'MULDIV'
               val = MULDIV (INT_MAX, USER_HZ, HZ);
                     ^
      
      Avoid this overflow by performing the (constant) arithmetic on 64 bit
      integers, which ensures that overflow from multiplying the 32 bit values
      cannot occur. When converting the result back to a 32 bit integer use
      min_t to ensure that we don't simply truncate a value beyond INT_MAX to
      a 32 bit integer, but instead use INT_MAX where the result was larger
      than it. As the values are all compile time constant the 64 bit
      arithmetic should have no runtime cost.
      Signed-off-by: NPaul Burton <paul.burton@imgtec.com>
      Acked-by: NDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      b9b6e80a
  9. 15 3月, 2016 1 次提交
    • D
      sg: fix dxferp in from_to case · f6a695cf
      Douglas Gilbert 提交于
      One of the strange things that the original sg driver did was let the
      user provide both a data-out buffer (it followed the sg_header+cdb)
      _and_ specify a reply length greater than zero. What happened was that
      the user data-out buffer was copied into some kernel buffers and then
      the mid level was told a read type operation would take place with the
      data from the device overwriting the same kernel buffers. The user would
      then read those kernel buffers back into the user space.
      
      From what I can tell, the above action was broken by commit fad7f01e
      ("sg: set dxferp to NULL for READ with the older SG interface") in 2008
      and syzkaller found that out recently.
      
      Make sure that a user space pointer is passed through when data follows
      the sg_header structure and command.  Fix the abnormal case when a
      non-zero reply_len is also given.
      
      Fixes: fad7f01e
      Cc: <stable@vger.kernel.org> #v2.6.28+
      Signed-off-by: NDouglas Gilbert <dgilbert@interlog.com>
      Reviewed-by: NEwan Milne <emilne@redhat.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      f6a695cf
  10. 10 3月, 2016 1 次提交
    • D
      sg: fix dxferp in from_to case · 5ecee0a3
      Douglas Gilbert 提交于
      One of the strange things that the original sg driver did was let the
      user provide both a data-out buffer (it followed the sg_header+cdb)
      _and_ specify a reply length greater than zero. What happened was that
      the user data-out buffer was copied into some kernel buffers and then
      the mid level was told a read type operation would take place with the
      data from the device overwriting the same kernel buffers. The user would
      then read those kernel buffers back into the user space.
      
      From what I can tell, the above action was broken by commit fad7f01e
      ("sg: set dxferp to NULL for READ with the older SG interface") in 2008
      and syzkaller found that out recently.
      
      Make sure that a user space pointer is passed through when data follows
      the sg_header structure and command.  Fix the abnormal case when a
      non-zero reply_len is also given.
      
      Fixes: fad7f01e
      Cc: <stable@vger.kernel.org> #v2.6.28+
      Signed-off-by: NDouglas Gilbert <dgilbert@interlog.com>
      Reviewed-by: NEwan Milne <emilne@redhat.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      5ecee0a3
  11. 04 2月, 2016 1 次提交
    • K
      drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration · 461c7fa1
      Kirill A. Shutemov 提交于
      Reduced testcase:
      
          #include <fcntl.h>
          #include <unistd.h>
          #include <sys/mman.h>
          #include <numaif.h>
      
          #define SIZE 0x2000
      
          int main()
          {
              int fd;
              void *p;
      
              fd = open("/dev/sg0", O_RDWR);
              p = mmap(NULL, SIZE, PROT_EXEC, MAP_PRIVATE | MAP_LOCKED, fd, 0);
              mbind(p, SIZE, 0, NULL, 0, MPOL_MF_MOVE);
              return 0;
          }
      
      We shouldn't try to migrate pages in sg VMA as we don't have a way to
      update Sg_scatter_hold::pages accordingly from mm core.
      
      Let's mark the VMA as VM_IO to indicate to mm core that the VMA is not
      migratable.
      Signed-off-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Reported-by: NDmitry Vyukov <dvyukov@google.com>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Cc: Doug Gilbert <dgilbert@interlog.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Shiraz Hashim <shashim@codeaurora.org>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Sasha Levin <sasha.levin@oracle.com>
      Cc: syzkaller <syzkaller@googlegroups.com>
      Cc: Kostya Serebryany <kcc@google.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      461c7fa1
  12. 03 11月, 2015 1 次提交
    • C
      sg: Fix double-free when drives detach during SG_IO · f3951a37
      Calvin Owens 提交于
      In sg_common_write(), we free the block request and return -ENODEV if
      the device is detached in the middle of the SG_IO ioctl().
      
      Unfortunately, sg_finish_rem_req() also tries to free srp->rq, so we
      end up freeing rq->cmd in the already free rq object, and then free
      the object itself out from under the current user.
      
      This ends up corrupting random memory via the list_head on the rq
      object. The most common crash trace I saw is this:
      
        ------------[ cut here ]------------
        kernel BUG at block/blk-core.c:1420!
        Call Trace:
        [<ffffffff81281eab>] blk_put_request+0x5b/0x80
        [<ffffffffa0069e5b>] sg_finish_rem_req+0x6b/0x120 [sg]
        [<ffffffffa006bcb9>] sg_common_write.isra.14+0x459/0x5a0 [sg]
        [<ffffffff8125b328>] ? selinux_file_alloc_security+0x48/0x70
        [<ffffffffa006bf95>] sg_new_write.isra.17+0x195/0x2d0 [sg]
        [<ffffffffa006cef4>] sg_ioctl+0x644/0xdb0 [sg]
        [<ffffffff81170f80>] do_vfs_ioctl+0x90/0x520
        [<ffffffff81258967>] ? file_has_perm+0x97/0xb0
        [<ffffffff811714a1>] SyS_ioctl+0x91/0xb0
        [<ffffffff81602afb>] tracesys+0xdd/0xe2
          RIP [<ffffffff81281e04>] __blk_put_request+0x154/0x1a0
      
      The solution is straightforward: just set srp->rq to NULL in the
      failure branch so that sg_finish_rem_req() doesn't attempt to re-free
      it.
      
      Additionally, since sg_rq_end_io() will never be called on the object
      when this happens, we need to free memory backing ->cmd if it isn't
      embedded in the object itself.
      
      KASAN was extremely helpful in finding the root cause of this bug.
      Signed-off-by: NCalvin Owens <calvinowens@fb.com>
      Acked-by: NDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      f3951a37
  13. 12 4月, 2015 2 次提交
  14. 26 3月, 2015 1 次提交
  15. 17 2月, 2015 2 次提交
  16. 16 2月, 2015 1 次提交
  17. 06 2月, 2015 1 次提交
  18. 03 2月, 2015 1 次提交
  19. 12 11月, 2014 5 次提交
  20. 29 8月, 2014 1 次提交
    • J
      block,scsi: fixup blk_get_request dead queue scenarios · a492f075
      Joe Lawrence 提交于
      The blk_get_request function may fail in low-memory conditions or during
      device removal (even if __GFP_WAIT is set). To distinguish between these
      errors, modify the blk_get_request call stack to return the appropriate
      ERR_PTR. Verify that all callers check the return status and consider
      IS_ERR instead of a simple NULL pointer check.
      
      For consistency, make a similar change to the blk_mq_alloc_request leg
      of blk_get_request.  It may fail if the queue is dead, or the caller was
      unwilling to wait.
      Signed-off-by: NJoe Lawrence <joe.lawrence@stratus.com>
      Acked-by: Jiri Kosina <jkosina@suse.cz> [for pktdvd]
      Acked-by: Boaz Harrosh <bharrosh@panasas.com> [for osd]
      Reviewed-by: NJeff Moyer <jmoyer@redhat.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      a492f075
  21. 25 7月, 2014 1 次提交
  22. 18 7月, 2014 6 次提交
  23. 06 6月, 2014 1 次提交
    • J
      block: add blk_rq_set_block_pc() · f27b087b
      Jens Axboe 提交于
      With the optimizations around not clearing the full request at alloc
      time, we are leaving some of the needed init for REQ_TYPE_BLOCK_PC
      up to the user allocating the request.
      
      Add a blk_rq_set_block_pc() that sets the command type to
      REQ_TYPE_BLOCK_PC, and properly initializes the members associated
      with this type of request. Update callers to use this function instead
      of manipulating rq->cmd_type directly.
      
      Includes fixes from Christoph Hellwig <hch@lst.de> for my half-assed
      attempt.
      Signed-off-by: NJens Axboe <axboe@fb.com>
      f27b087b
  24. 25 10月, 2013 4 次提交
  25. 03 9月, 2013 1 次提交