1. 13 2月, 2019 1 次提交
  2. 19 11月, 2018 1 次提交
  3. 17 11月, 2018 1 次提交
  4. 16 11月, 2018 1 次提交
  5. 10 11月, 2018 1 次提交
    • J
      floppy: fix race condition in __floppy_read_block_0() · de7b75d8
      Jens Axboe 提交于
      LKP recently reported a hang at bootup in the floppy code:
      
      [  245.678853] INFO: task mount:580 blocked for more than 120 seconds.
      [  245.679906]       Tainted: G                T 4.19.0-rc6-00172-ga9f38e1d #1
      [  245.680959] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [  245.682181] mount           D 6372   580      1 0x00000004
      [  245.683023] Call Trace:
      [  245.683425]  __schedule+0x2df/0x570
      [  245.683975]  schedule+0x2d/0x80
      [  245.684476]  schedule_timeout+0x19d/0x330
      [  245.685090]  ? wait_for_common+0xa5/0x170
      [  245.685735]  wait_for_common+0xac/0x170
      [  245.686339]  ? do_sched_yield+0x90/0x90
      [  245.686935]  wait_for_completion+0x12/0x20
      [  245.687571]  __floppy_read_block_0+0xfb/0x150
      [  245.688244]  ? floppy_resume+0x40/0x40
      [  245.688844]  floppy_revalidate+0x20f/0x240
      [  245.689486]  check_disk_change+0x43/0x60
      [  245.690087]  floppy_open+0x1ea/0x360
      [  245.690653]  __blkdev_get+0xb4/0x4d0
      [  245.691212]  ? blkdev_get+0x1db/0x370
      [  245.691777]  blkdev_get+0x1f3/0x370
      [  245.692351]  ? path_put+0x15/0x20
      [  245.692871]  ? lookup_bdev+0x4b/0x90
      [  245.693539]  blkdev_get_by_path+0x3d/0x80
      [  245.694165]  mount_bdev+0x2a/0x190
      [  245.694695]  squashfs_mount+0x10/0x20
      [  245.695271]  ? squashfs_alloc_inode+0x30/0x30
      [  245.695960]  mount_fs+0xf/0x90
      [  245.696451]  vfs_kern_mount+0x43/0x130
      [  245.697036]  do_mount+0x187/0xc40
      [  245.697563]  ? memdup_user+0x28/0x50
      [  245.698124]  ksys_mount+0x60/0xc0
      [  245.698639]  sys_mount+0x19/0x20
      [  245.699167]  do_int80_syscall_32+0x61/0x130
      [  245.699813]  entry_INT80_32+0xc7/0xc7
      
      showing that we never complete that read request. The reason is that
      the completion setup is racy - it initializes the completion event
      AFTER submitting the IO, which means that the IO could complete
      before/during the init. If it does, we are passing garbage to
      complete() and we may sleep forever waiting for the event to
      occur.
      
      Fixes: 7b7b68bb ("floppy: bail out in open() if drive is not responding to block0 read")
      Reviewed-by: NOmar Sandoval <osandov@fb.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      de7b75d8
  6. 16 10月, 2018 1 次提交
  7. 28 9月, 2018 1 次提交
  8. 20 9月, 2018 1 次提交
    • A
      floppy: Do not copy a kernel pointer to user memory in FDGETPRM ioctl · 65eea8ed
      Andy Whitcroft 提交于
      The final field of a floppy_struct is the field "name", which is a pointer
      to a string in kernel memory.  The kernel pointer should not be copied to
      user memory.  The FDGETPRM ioctl copies a floppy_struct to user memory,
      including this "name" field.  This pointer cannot be used by the user
      and it will leak a kernel address to user-space, which will reveal the
      location of kernel code and data and undermine KASLR protection.
      
      Model this code after the compat ioctl which copies the returned data
      to a previously cleared temporary structure on the stack (excluding the
      name pointer) and copy out to userspace from there.  As we already have
      an inparam union with an appropriate member and that memory is already
      cleared even for read only calls make use of that as a temporary store.
      
      Based on an initial patch by Brian Belleville.
      
      CVE-2018-7755
      Signed-off-by: NAndy Whitcroft <apw@canonical.com>
      
      Broke up long line.
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      65eea8ed
  9. 09 7月, 2018 1 次提交
  10. 25 5月, 2018 1 次提交
  11. 27 2月, 2018 1 次提交
  12. 15 11月, 2017 1 次提交
    • K
      block/floppy: Convert callback to pass timer_list · b1bf4210
      Kees Cook 提交于
      In preparation for unconditionally passing the struct timer_list pointer to
      all timer callbacks, switch to passing in the timer pointer explicitly.
      Calculate the drive from the offset of the timer in the timer list.
      
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Ming Lei <tom.leiming@gmail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Geliang Tang <geliangtang@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      b1bf4210
  13. 19 10月, 2017 1 次提交
  14. 24 8月, 2017 1 次提交
    • C
      block: replace bi_bdev with a gendisk pointer and partitions index · 74d46992
      Christoph Hellwig 提交于
      This way we don't need a block_device structure to submit I/O.  The
      block_device has different life time rules from the gendisk and
      request_queue and is usually only available when the block device node
      is open.  Other callers need to explicitly create one (e.g. the lightnvm
      passthrough code, or the new nvme multipathing code).
      
      For the actual I/O path all that we need is the gendisk, which exists
      once per block device.  But given that the block layer also does
      partition remapping we additionally need a partition index, which is
      used for said remapping in generic_make_request.
      
      Note that all the block drivers generally want request_queue or
      sometimes the gendisk, so this removes a layer of indirection all
      over the stack.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      74d46992
  15. 30 6月, 2017 1 次提交
  16. 28 6月, 2017 1 次提交
  17. 09 6月, 2017 2 次提交
    • C
      block: switch bios to blk_status_t · 4e4cbee9
      Christoph Hellwig 提交于
      Replace bi_error with a new bi_status to allow for a clear conversion.
      Note that device mapper overloaded bi_error with a private value, which
      we'll have to keep arround at least for now and thus propagate to a
      proper blk_status_t value.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      4e4cbee9
    • C
      block: introduce new block status code type · 2a842aca
      Christoph Hellwig 提交于
      Currently we use nornal Linux errno values in the block layer, and while
      we accept any error a few have overloaded magic meanings.  This patch
      instead introduces a new  blk_status_t value that holds block layer specific
      status codes and explicitly explains their meaning.  Helpers to convert from
      and to the previous special meanings are provided for now, but I suspect
      we want to get rid of them in the long run - those drivers that have a
      errno input (e.g. networking) usually get errnos that don't know about
      the special block layer overloads, and similarly returning them to userspace
      will usually return somethings that strictly speaking isn't correct
      for file system operations, but that's left as an exercise for later.
      
      For now the set of errors is a very limited set that closely corresponds
      to the previous overloaded errno values, but there is some low hanging
      fruite to improve it.
      
      blk_status_t (ab)uses the sparse __bitwise annotations to allow for sparse
      typechecking, so that we can easily catch places passing the wrong values.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      2a842aca
  18. 21 4月, 2017 1 次提交
  19. 24 3月, 2017 1 次提交
  20. 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
  21. 12 1月, 2017 1 次提交
  22. 22 11月, 2016 2 次提交
  23. 25 8月, 2016 2 次提交
  24. 05 8月, 2016 1 次提交
  25. 28 6月, 2016 1 次提交
    • D
      block: convert to device_add_disk() · 0d52c756
      Dan Williams 提交于
      For block drivers that specify a parent device, convert them to use
      device_add_disk().
      
      This conversion was done with the following semantic patch:
      
          @@
          struct gendisk *disk;
          expression E;
          @@
      
          - disk->driverfs_dev = E;
          ...
          - add_disk(disk);
          + device_add_disk(E, disk);
      
          @@
          struct gendisk *disk;
          expression E1, E2;
          @@
      
          - disk->driverfs_dev = E1;
          ...
          E2 = disk;
          ...
          - add_disk(E2);
          + device_add_disk(E1, E2);
      
      ...plus some manual fixups for a few missed conversions.
      
      Cc: Jens Axboe <axboe@fb.com>
      Cc: Keith Busch <keith.busch@intel.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
      Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      0d52c756
  26. 08 6月, 2016 2 次提交
  27. 07 2月, 2016 1 次提交
    • J
      floppy: refactor open() flags handling · 09954bad
      Jiri Kosina 提交于
      In case /dev/fdX is open with O_NDELAY / O_NONBLOCK, floppy_open() immediately
      succeeds, without performing any further media / controller preparations.
      That's "correct" wrt. the NODELAY flag, but is hardly correct wrt. the rest
      of the floppy driver, that is not really O_NONBLOCK ready, at all. Therefore
      it's not too surprising, that subsequent attempts to work with the
      filedescriptor produce bad results. Namely, syzkaller tool has been able
      to livelock mmap() on the returned fd to keep waiting on the page unlock
      bit forever.
      
      Quite frankly, I have trouble defining what non-blocking behavior would be for
      floppies. Is waiting ages for the driver to actually succeed reading a sector
      blocking operation? Is waiting for drive motor to start blocking operation? How
      about in case of virtualized floppies?
      
      One option would be returning EWOULDBLOCK in case O_NDLEAY / O_NONBLOCK is
      being passed to open(). That has a theoretical potential of breaking some
      arcane and archaic userspace though.
      
      Let's take a more conservative aproach, and accept the O_NDLEAY flag, and let
      the driver behave as usual.
      
      While at it, clean up a bit handling of !(mode & (FMODE_READ|FMODE_WRITE))
      case and return EINVAL instead of succeeding as well.
      
      Spotted by syzkaller tool.
      Reported-by: NDmitry Vyukov <dvyukov@google.com>
      Tested-by: NDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      09954bad
  28. 01 2月, 2016 1 次提交
    • J
      floppy: fix lock_fdc() signal handling · a0c80efe
      Jiri Kosina 提交于
      floppy_revalidate() doesn't perform any error handling on lock_fdc()
      result. lock_fdc() might actually be interrupted by a signal (it waits for
      fdc becoming non-busy interruptibly). In such case, floppy_revalidate()
      proceeds as if it had claimed the lock, but it fact it doesn't.
      
      In case of multiple threads trying to open("/dev/fdX"), this leads to
      serious corruptions all over the place, because all of a sudden there is
      no critical section protection (that'd otherwise be guaranteed by locked
      fd) whatsoever.
      
      While at this, fix the fact that the 'interruptible' parameter to
      lock_fdc() doesn't make any sense whatsoever, because we always wait
      interruptibly anyway.
      
      Most of the lock_fdc() callsites do properly handle error (and propagate
      EINTR), but floppy_revalidate() and floppy_check_events() don't. Fix this.
      
      Spotted by 'syzkaller' tool.
      Reported-by: NDmitry Vyukov <dvyukov@google.com>
      Tested-by: NDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      a0c80efe
  29. 08 12月, 2015 1 次提交
  30. 29 7月, 2015 1 次提交
    • C
      block: add a bi_error field to struct bio · 4246a0b6
      Christoph Hellwig 提交于
      Currently we have two different ways to signal an I/O error on a BIO:
      
       (1) by clearing the BIO_UPTODATE flag
       (2) by returning a Linux errno value to the bi_end_io callback
      
      The first one has the drawback of only communicating a single possible
      error (-EIO), and the second one has the drawback of not beeing persistent
      when bios are queued up, and are not passed along from child to parent
      bio in the ever more popular chaining scenario.  Having both mechanisms
      available has the additional drawback of utterly confusing driver authors
      and introducing bugs where various I/O submitters only deal with one of
      them, and the others have to add boilerplate code to deal with both kinds
      of error returns.
      
      So add a new bi_error field to store an errno value directly in struct
      bio and remove the existing mechanisms to clean all this up.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Reviewed-by: NNeilBrown <neilb@suse.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      4246a0b6
  31. 03 2月, 2015 1 次提交
  32. 18 6月, 2014 1 次提交
  33. 28 5月, 2014 1 次提交
    • J
      floppy: do not corrupt bio.bi_flags when reading block 0 · 6314a108
      Jiri Kosina 提交于
      Commit 41a55b4d ("floppy: silence warning during disk test") caused
      bio.bi_flags being overwritten, and its initialization to BIO_UPTODATE
      in bio_init() to be lost.
      
      This was unnoticed until 7b7b68bb ("floppy: bail out in open() if
      drive is not responding to block0 read"), because the error value wasn't
      checked for in the bio completion callback.
      
      Now we are actually looking at the error, and the loss of BIO_UPTODATE
      causes EIO to be wrongly passed to the callback, which confuses the
      FD_OPEN_SHOULD_FAIL_BIT logic.
      
      Fix this by not destroying previous value of bi_flags when setting
      BIO_QUIET.
      
      Cc: Stephen Hemminger <shemminger@vyatta.com>
      Reported-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      6314a108
  34. 05 5月, 2014 2 次提交
  35. 16 4月, 2014 1 次提交
    • J
      block: remove struct request buffer member · b4f42e28
      Jens Axboe 提交于
      This was used in the olden days, back when onions were proper
      yellow. Basically it mapped to the current buffer to be
      transferred. With highmem being added more than a decade ago,
      most drivers map pages out of a bio, and rq->buffer isn't
      pointing at anything valid.
      
      Convert old style drivers to just use bio_data().
      
      For the discard payload use case, just reference the page
      in the bio.
      Signed-off-by: NJens Axboe <axboe@fb.com>
      b4f42e28