1. 31 7月, 2019 1 次提交
    • J
      loop: Fix mount(2) failure due to race with LOOP_SET_FD · 89e524c0
      Jan Kara 提交于
      Commit 33ec3e53 ("loop: Don't change loop device under exclusive
      opener") made LOOP_SET_FD ioctl acquire exclusive block device reference
      while it updates loop device binding. However this can make perfectly
      valid mount(2) fail with EBUSY due to racing LOOP_SET_FD holding
      temporarily the exclusive bdev reference in cases like this:
      
      for i in {a..z}{a..z}; do
              dd if=/dev/zero of=$i.image bs=1k count=0 seek=1024
              mkfs.ext2 $i.image
              mkdir mnt$i
      done
      
      echo "Run"
      for i in {a..z}{a..z}; do
              mount -o loop -t ext2 $i.image mnt$i &
      done
      
      Fix the problem by not getting full exclusive bdev reference in
      LOOP_SET_FD but instead just mark the bdev as being claimed while we
      update the binding information. This just blocks new exclusive openers
      instead of failing them with EBUSY thus fixing the problem.
      
      Fixes: 33ec3e53 ("loop: Don't change loop device under exclusive opener")
      Cc: stable@vger.kernel.org
      Tested-by: NKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      89e524c0
  2. 30 7月, 2019 1 次提交
    • G
      ataflop: Mark expected switch fall-through · 7be21763
      Gustavo A. R. Silva 提交于
      Mark switch cases where we are expecting to fall through.
      
      This patch fixes the following warning (Building: m68k):
      
      drivers/block/ataflop.c: In function ‘fd_locked_ioctl’:
      drivers/block/ataflop.c:1728:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
         set_capacity(floppy->disk, MAX_DISK_SIZE * 2);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/block/ataflop.c:1729:2: note: here
        case FDFMTEND:
        ^~~~
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      7be21763
  3. 23 7月, 2019 1 次提交
  4. 18 7月, 2019 4 次提交
    • D
      floppy: fix out-of-bounds read in copy_buffer · da99466a
      Denis Efremov 提交于
      This fixes a global out-of-bounds read access in the copy_buffer
      function of the floppy driver.
      
      The FDDEFPRM ioctl allows one to set the geometry of a disk.  The sect
      and head fields (unsigned int) of the floppy_drive structure are used to
      compute the max_sector (int) in the make_raw_rw_request function.  It is
      possible to overflow the max_sector.  Next, max_sector is passed to the
      copy_buffer function and used in one of the memcpy calls.
      
      An unprivileged user could trigger the bug if the device is accessible,
      but requires a floppy disk to be inserted.
      
      The patch adds the check for the .sect * .head multiplication for not
      overflowing in the set_geometry function.
      
      The bug was found by syzkaller.
      Signed-off-by: NDenis Efremov <efremov@ispras.ru>
      Tested-by: NWilly Tarreau <w@1wt.eu>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      da99466a
    • D
      floppy: fix invalid pointer dereference in drive_name · 9b04609b
      Denis Efremov 提交于
      This fixes the invalid pointer dereference in the drive_name function of
      the floppy driver.
      
      The native_format field of the struct floppy_drive_params is used as
      floppy_type array index in the drive_name function.  Thus, the field
      should be checked the same way as the autodetect field.
      
      To trigger the bug, one could use a value out of range and set the drive
      parameters with the FDSETDRVPRM ioctl.  Next, FDGETDRVTYP ioctl should
      be used to call the drive_name.  A floppy disk is not required to be
      inserted.
      
      CAP_SYS_ADMIN is required to call FDSETDRVPRM.
      
      The patch adds the check for a value of the native_format field to be in
      the '0 <= x < ARRAY_SIZE(floppy_type)' range of the floppy_type array
      indices.
      
      The bug was found by syzkaller.
      Signed-off-by: NDenis Efremov <efremov@ispras.ru>
      Tested-by: NWilly Tarreau <w@1wt.eu>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9b04609b
    • D
      floppy: fix out-of-bounds read in next_valid_format · 5635f897
      Denis Efremov 提交于
      This fixes a global out-of-bounds read access in the next_valid_format
      function of the floppy driver.
      
      The values from autodetect field of the struct floppy_drive_params are
      used as indices for the floppy_type array in the next_valid_format
      function 'floppy_type[DP->autodetect[probed_format]].sect'.
      
      To trigger the bug, one could use a value out of range and set the drive
      parameters with the FDSETDRVPRM ioctl.  A floppy disk is not required to
      be inserted.
      
      CAP_SYS_ADMIN is required to call FDSETDRVPRM.
      
      The patch adds the check for values of the autodetect field to be in the
      '0 <= x < ARRAY_SIZE(floppy_type)' range of the floppy_type array indices.
      
      The bug was found by syzkaller.
      Signed-off-by: NDenis Efremov <efremov@ispras.ru>
      Tested-by: NWilly Tarreau <w@1wt.eu>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5635f897
    • D
      floppy: fix div-by-zero in setup_format_params · f3554aeb
      Denis Efremov 提交于
      This fixes a divide by zero error in the setup_format_params function of
      the floppy driver.
      
      Two consecutive ioctls can trigger the bug: The first one should set the
      drive geometry with such .sect and .rate values for the F_SECT_PER_TRACK
      to become zero.  Next, the floppy format operation should be called.
      
      A floppy disk is not required to be inserted.  An unprivileged user
      could trigger the bug if the device is accessible.
      
      The patch checks F_SECT_PER_TRACK for a non-zero value in the
      set_geometry function.  The proper check should involve a reasonable
      upper limit for the .sect and .rate fields, but it could change the
      UAPI.
      
      The patch also checks F_SECT_PER_TRACK in the setup_format_params, and
      cancels the formatting operation in case of zero.
      
      The bug was found by syzkaller.
      Signed-off-by: NDenis Efremov <efremov@ispras.ru>
      Tested-by: NWilly Tarreau <w@1wt.eu>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f3554aeb
  5. 15 7月, 2019 2 次提交
  6. 12 7月, 2019 2 次提交
  7. 11 7月, 2019 2 次提交
  8. 08 7月, 2019 18 次提交
  9. 29 6月, 2019 4 次提交
  10. 20 6月, 2019 3 次提交
    • G
      block: drbd: no need to check return value of debugfs_create functions · d27e84a3
      Greg Kroah-Hartman 提交于
      When calling debugfs functions, there is no need to ever check the
      return value.  The function can work or not, but the code logic should
      never do something different based on this.
      
      Cc: Philipp Reisner <philipp.reisner@linbit.com>
      Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: drbd-dev@lists.linbit.com
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      d27e84a3
    • C
      null_blk: remove duplicate 0 initialization · 8c54803b
      Chaitanya Kulkarni 提交于
      In function null_add_dev() struct nullb *nullb member is allocated
      using kzalloc_node() which returns 0red memory.
      
      In function setup_queues() which is called from the null_add_dev(), on
      successful queue allocation we set the nullb->nr_queues = 0 which is not
      needed due to earlier use of kzalloc_node().
      Signed-off-by: NChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      8c54803b
    • A
      floppy: fix harmless clang build warning · 2af47c10
      Arnd Bergmann 提交于
      clang warns about unusual code in floppy.c that looks like it
      was intended to be a bit mask operation, checking for a specific
      bit in the UDP->cmos variable (FLOPPY1_TYPE expands to '4' on
      ARM):
      
      drivers/block/floppy.c:3902:17: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand]
              if (!UDP->cmos && FLOPPY1_TYPE)
                             ^  ~~~~~~~~~~~~
      drivers/block/floppy.c:3902:17: note: use '&' for a bitwise operation
              if (!UDP->cmos && FLOPPY1_TYPE)
      
      The check here is redundant anyway, if FLOPPY1_TYPE is zero, then
      assigning it to a zero UDP->cmos field does not change anything,
      so removing the extra check here has no effect other than shutting
      up the warning.
      
      On x86, this will no longer read a hardware register, as the
      FLOPPY1_TYPE macro is not expanded if UDP->cmos is already
      zero, but the result is the same.
      
      Cc: Robert Elliott <elliott@hpe.com>
      Cc: Keith Busch <kbusch@kernel.org>
      Link: https://patchwork.kernel.org/patch/10851841/Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      2af47c10
  11. 19 6月, 2019 2 次提交