1. 22 May, 2015 10 commits
    • Tejun Heo's avatar
      writeback: use |1 instead of +1 to protect against div by zero · 66740325
      Tejun Heo authored
      commit 464d1387 upstream.
      
      mm/page-writeback.c has several places where 1 is added to the divisor
      to prevent division by zero exceptions; however, if the original
      divisor is equivalent to -1, adding 1 leads to division by zero.
      
      There are three places where +1 is used for this purpose - one in
      pos_ratio_polynom() and two in bdi_position_ratio().  The second one
      in bdi_position_ratio() actually triggered div-by-zero oops on a
      machine running a 3.10 kernel.  The divisor is
      
        x_intercept - bdi_setpoint + 1 == span + 1
      
      span is confirmed to be (u32)-1.  It isn't clear how it ended up that
      but it could be from write bandwidth calculation underflow fixed by
      c72efb65 ("writeback: fix possible underflow in write bandwidth
      calculation").
      
      At any rate, +1 isn't a proper protection against div-by-zero.  This
      patch converts all +1 protections to |1.  Note that
      bdi_update_dirty_ratelimit() was already using |1 before this patch.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJens Axboe <axboe@fb.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      66740325
    • Ming Lei's avatar
      blk-mq: fix CPU hotplug handling · 4766596e
      Ming Lei authored
      commit 2a34c087 upstream.
      
      hctx->tags has to be set as NULL in case that it is to be unmapped
      no matter if set->tags[hctx->queue_num] is NULL or not in blk_mq_map_swqueue()
      because shared tags can be freed already from another request queue.
      
      The same situation has to be considered during handling CPU online too.
      Unmapped hw queue can be remapped after CPU topo is changed, so we need
      to allocate tags for the hw queue in blk_mq_map_swqueue(). Then tags
      allocation for hw queue can be removed in hctx cpu online notifier, and it
      is reasonable to do that after mapping is updated.
      Reported-by: default avatarDongsu Park <dongsu.park@profitbricks.com>
      Tested-by: default avatarDongsu Park <dongsu.park@profitbricks.com>
      Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
      Signed-off-by: default avatarJens Axboe <axboe@fb.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      4766596e
    • Ming Lei's avatar
      blk-mq: fix race between timeout and CPU hotplug · 4d755b43
      Ming Lei authored
      commit f054b56c upstream.
      
      Firstly during CPU hotplug, even queue is freezed, timeout
      handler still may come and access hctx->tags, which may cause
      use after free, so this patch deactivates timeout handler
      inside CPU hotplug notifier.
      
      Secondly, tags can be shared by more than one queues, so we
      have to check if the hctx has been unmapped, otherwise
      still use-after-free on tags can be triggered.
      Reported-by: default avatarDongsu Park <dongsu.park@profitbricks.com>
      Tested-by: default avatarDongsu Park <dongsu.park@profitbricks.com>
      Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
      Signed-off-by: default avatarJens Axboe <axboe@fb.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      4d755b43
    • Roy Franz's avatar
      x86/efi: Store upper bits of command line buffer address in ext_cmd_line_ptr · 6115de41
      Roy Franz authored
      commit 98b228f5 upstream.
      
      Until now, the EFI stub was only setting the 32 bit cmd_line_ptr in
      the setup_header structure, so on 64 bit platforms this could be truncated.
      This patch adds setting the upper bits of the buffer address in
      ext_cmd_line_ptr.  This case was likely never hit, as the allocation
      for this buffer is done at the lowest available address.  Only
      x86_64 kernels have this problem, as the 1-1 mapping mandated
      by EFI ensures that all memory is 32 bit addressable on 32 bit
      platforms.  The EFI stub does not support mixed mode, so the
      32 bit kernel on 64 bit firmware case does not need to be handled.
      Signed-off-by: default avatarRoy Franz <roy.franz@linaro.org>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      6115de41
    • Ross Lagerwall's avatar
      efivarfs: Ensure VariableName is NUL-terminated · e5367189
      Ross Lagerwall authored
      commit c57dcb56 upstream.
      
      Some buggy firmware implementations update VariableNameSize on success
      such that it does not include the final NUL character which results in
      garbage in the efivarfs name entries.  Use kzalloc on the efivar_entry
      (as is done in efivars.c) to ensure that the name is always
      NUL-terminated.
      
      The buggy firmware is:
      BIOS Information
              Vendor: Intel Corp.
              Version: S1200RP.86B.02.02.0005.102320140911
              Release Date: 10/23/2014
              BIOS Revision: 4.6
      System Information
              Manufacturer: Intel Corporation
              Product Name: S1200RP_SE
      Signed-off-by: default avatarRoss Lagerwall <ross.lagerwall@citrix.com>
      Acked-by: default avatarMatthew Garrett <mjg59@coreos.com>
      Cc: Jeremy Kerr <jk@ozlabs.org>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      e5367189
    • Sam Bobroff's avatar
      powerpc/powernv: Restore non-volatile CRs after nap · 470b5964
      Sam Bobroff authored
      commit 0aab3747 upstream.
      
      Patches 7cba160a "powernv/cpuidle: Redesign idle states management"
      and 77b54e9f "powernv/powerpc: Add winkle support for offline cpus"
      use non-volatile condition registers (cr2, cr3 and cr4) early in the system
      reset interrupt handler (system_reset_pSeries()) before it has been determined
      if state loss has occurred. If state loss has not occurred, control returns via
      the power7_wakeup_noloss() path which does not restore those condition
      registers, leaving them corrupted.
      
      Fix this by restoring the condition registers in the power7_wakeup_noloss()
      case.
      
      This is apparent when running a KVM guest on hardware that does not
      support winkle or sleep and the guest makes use of secondary threads. In
      practice this means Power7 machines, though some early unreleased Power8
      machines may also be susceptible.
      
      The secondary CPUs are taken off line before the guest is started and
      they call pnv_smp_cpu_kill_self(). This checks support for sleep
      states (in this case there is no support) and power7_nap() is called.
      
      When the CPU is woken, power7_nap() returns and because the CPU is
      still off line, the main while loop executes again. The sleep states
      support test is executed again, but because the tested values cannot
      have changed, the compiler has optimized the test away and instead we
      rely on the result of the first test, which has been left in cr3
      and/or cr4. With the result overwritten, the wrong branch is taken and
      power7_winkle() is called on a CPU that does not support it, leading
      to it stalling.
      
      Fixes: 7cba160a ("powernv/cpuidle: Redesign idle states management")
      Fixes: 77b54e9f ("powernv/powerpc: Add winkle support for offline cpus")
      [mpe: Massage change log a bit more]
      Signed-off-by: default avatarSam Bobroff <sam.bobroff@au1.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      470b5964
    • Nathan Fontenot's avatar
      powerpc/pseries: Correct cpu affinity for dlpar added cpus · b8682332
      Nathan Fontenot authored
      commit f32393c9 upstream.
      
      The incorrect ordering of operations during cpu dlpar add results in invalid
      affinity for the cpu being added. The ibm,associativity property in the
      device tree is populated with all zeroes for the added cpu which results in
      invalid affinity mappings and all cpus appear to belong to node 0.
      
      This occurs because rtas configure-connector is called prior to making the
      rtas set-indicator calls. Phyp does not assign affinity information
      for a cpu until the rtas set-indicator calls are made to set the isolation
      and allocation state.
      
      Correct the order of operations to make the rtas set-indicator
      calls (done in dlpar_acquire_drc) before calling rtas configure-connector.
      
      Fixes: 1a8061c4 ("powerpc/pseries: Add kernel based CPU DLPAR handling")
      Signed-off-by: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      b8682332
    • Davide Italiano's avatar
      ext4: move check under lock scope to close a race. · d44520b8
      Davide Italiano authored
      commit 280227a7 upstream.
      
      fallocate() checks that the file is extent-based and returns
      EOPNOTSUPP in case is not. Other tasks can convert from and to
      indirect and extent so it's safe to check only after grabbing
      the inode mutex.
      Signed-off-by: default avatarDavide Italiano <dccitaliano@gmail.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      d44520b8
    • Lukas Czerner's avatar
      ext4: fix data corruption caused by unwritten and delayed extents · 89a04b3e
      Lukas Czerner authored
      commit d2dc317d upstream.
      
      Currently it is possible to lose whole file system block worth of data
      when we hit the specific interaction with unwritten and delayed extents
      in status extent tree.
      
      The problem is that when we insert delayed extent into extent status
      tree the only way to get rid of it is when we write out delayed buffer.
      However there is a limitation in the extent status tree implementation
      so that when inserting unwritten extent should there be even a single
      delayed block the whole unwritten extent would be marked as delayed.
      
      At this point, there is no way to get rid of the delayed extents,
      because there are no delayed buffers to write out. So when a we write
      into said unwritten extent we will convert it to written, but it still
      remains delayed.
      
      When we try to write into that block later ext4_da_map_blocks() will set
      the buffer new and delayed and map it to invalid block which causes
      the rest of the block to be zeroed loosing already written data.
      
      For now we can fix this by simply not allowing to set delayed status on
      written extent in the extent status tree. Also add WARN_ON() to make
      sure that we notice if this happens in the future.
      
      This problem can be easily reproduced by running the following xfs_io.
      
      xfs_io -f -c "pwrite -S 0xaa 4096 2048" \
                -c "falloc 0 131072" \
                -c "pwrite -S 0xbb 65536 2048" \
                -c "fsync" /mnt/test/fff
      
      echo 3 > /proc/sys/vm/drop_caches
      xfs_io -c "pwrite -S 0xdd 67584 2048" /mnt/test/fff
      
      This can be theoretically also reproduced by at random by running fsx,
      but it's not very reliable, though on machines with bigger page size
      (like ppc) this can be seen more often (especially xfstest generic/127)
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      89a04b3e
    • Ilya Dryomov's avatar
      rbd: end I/O the entire obj_request on error · bb8be14c
      Ilya Dryomov authored
      commit 082a75da upstream.
      
      When we end I/O struct request with error, we need to pass
      obj_request->length as @nr_bytes so that the entire obj_request worth
      of bytes is completed.  Otherwise block layer ends up confused and we
      trip on
      
          rbd_assert(more ^ (which == img_request->obj_request_count));
      
      in rbd_img_obj_callback() due to more being true no matter what.  We
      already do it in most cases but we are missing some, in particular
      those where we don't even get a chance to submit any obj_requests, due
      to an early -ENOMEM for example.
      
      A number of obj_request->xferred assignments seem to be redundant but
      I haven't touched any of obj_request->xferred stuff to keep this small
      and isolated.
      
      Cc: Alex Elder <elder@linaro.org>
      Reported-by: default avatarShawn Edwards <lesser.evil@gmail.com>
      Reviewed-by: default avatarSage Weil <sage@redhat.com>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      bb8be14c
  2. 21 May, 2015 30 commits