1. 20 1月, 2022 1 次提交
    • Z
      md: Fix undefined behaviour in is_mddev_idle · 406295a3
      zhangwensheng 提交于
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I4QXS1?from=project-issue
      CVE: NA
      
      --------------------------------
      
      UBSAN reports this problem:
      
      [ 5984.281385] UBSAN: Undefined behaviour in drivers/md/md.c:8175:15
      [ 5984.281390] signed integer overflow:
      [ 5984.281393] -2147483291 - 2072033152 cannot be represented in type 'int'
      [ 5984.281400] CPU: 25 PID: 1854 Comm: md101_resync Kdump: loaded Not tainted 4.19.90
      [ 5984.281404] Hardware name: Huawei TaiShan 200 (Model 5280)/BC82AMDDA
      [ 5984.281406] Call trace:
      [ 5984.281415]  dump_backtrace+0x0/0x310
      [ 5984.281418]  show_stack+0x28/0x38
      [ 5984.281425]  dump_stack+0xec/0x15c
      [ 5984.281430]  ubsan_epilogue+0x18/0x84
      [ 5984.281434]  handle_overflow+0x14c/0x19c
      [ 5984.281439]  __ubsan_handle_sub_overflow+0x34/0x44
      [ 5984.281445]  is_mddev_idle+0x338/0x3d8
      [ 5984.281449]  md_do_sync+0x1bb8/0x1cf8
      [ 5984.281452]  md_thread+0x220/0x288
      [ 5984.281457]  kthread+0x1d8/0x1e0
      [ 5984.281461]  ret_from_fork+0x10/0x18
      
      When the stat aacum of the disk is greater than INT_MAX, its value
      becomes negative after casting to 'int', which may lead to overflow
      after subtracting a positive number. In the same way, when the value
      of sync_io is greater than INT_MAX,overflow may also occur. These
      situations will lead to undefined behavior.
      
      Otherwise, if the stat accum of the disk is close to INT_MAX when
      creating raid arrays, the initial value of last_events would be set
      close to INT_MAX when mddev initializes IO event counters.
      'curr_events - rdev->last_events > 64' will always false during
      synchronization. If all the disks of mddev are in this case,
      is_mddev_idle() will always return 1, which may cause non-sync IO
      is very slow.
      
      To address these problems, need to use 64bit signed integer type
      for sync_io,last_events, and curr_events.
      Signed-off-by: Nzhangwensheng <zhangwensheng5@huawei.com>
      Reviewed-by: NTao Hou <houtao1@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      406295a3
  2. 31 12月, 2021 1 次提交
  3. 12 10月, 2021 1 次提交
  4. 03 7月, 2021 1 次提交
  5. 13 11月, 2020 1 次提交
  6. 24 9月, 2020 1 次提交
  7. 10 9月, 2020 2 次提交
  8. 02 9月, 2020 6 次提交
  9. 18 7月, 2020 1 次提交
    • B
      blk-cgroup: show global disk stats in root cgroup io.stat · ef45fe47
      Boris Burkov 提交于
      In order to improve consistency and usability in cgroup stat accounting,
      we would like to support the root cgroup's io.stat.
      
      Since the root cgroup has processes doing io even if the system has no
      explicitly created cgroups, we need to be careful to avoid overhead in
      that case.  For that reason, the rstat algorithms don't handle the root
      cgroup, so just turning the file on wouldn't give correct statistics.
      
      To get around this, we simulate flushing the iostat struct by filling it
      out directly from global disk stats. The result is a root cgroup io.stat
      file consistent with both /proc/diskstats and io.stat.
      
      Note that in order to collect the disk stats, we needed to iterate over
      devices. To facilitate that, we had to change the linkage of a disk_type
      to external so that it can be used from blk-cgroup.c to iterate over
      disks.
      Suggested-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NBoris Burkov <boris@bur.io>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      ef45fe47
  10. 24 6月, 2020 2 次提交
  11. 27 5月, 2020 2 次提交
  12. 13 5月, 2020 2 次提交
  13. 05 5月, 2020 1 次提交
  14. 21 4月, 2020 1 次提交
  15. 27 3月, 2020 1 次提交
  16. 25 3月, 2020 7 次提交
  17. 24 3月, 2020 5 次提交
  18. 19 3月, 2020 1 次提交
  19. 12 3月, 2020 2 次提交
    • S
      block: Fix partition support for host aware zoned block devices · b53df2e7
      Shin'ichiro Kawasaki 提交于
      Commit b7205307 ("block: allow partitions on host aware zone
      devices") introduced the helper function disk_has_partitions() to check
      if a given disk has valid partitions. However, since this function result
      directly depends on the disk partition table length rather than the
      actual existence of valid partitions in the table, it returns true even
      after all partitions are removed from the disk. For host aware zoned
      block devices, this results in zone management support to be kept
      disabled even after removing all partitions.
      
      Fix this by changing disk_has_partitions() to walk through the partition
      table entries and return true if and only if a valid non-zero size
      partition is found.
      
      Fixes: b7205307 ("block: allow partitions on host aware zone devices")
      Cc: stable@vger.kernel.org # 5.5
      Reviewed-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      b53df2e7
    • S
      block: Document genhd capability flags · 9243c6f3
      Stephen Kitt 提交于
      The kernel documentation includes a brief section about genhd
      capabilities, but it turns out that the only documented
      capability (GENHD_FL_MEDIA_CHANGE_NOTIFY) isn't used any more.
      
      This patch removes that flag, and documents the rest, based on my
      understanding of the current uses of these flags in the kernel. The
      documentation is kept in the header file, alongside the declarations,
      in the hope that it will be kept up-to-date in future; the kernel
      documentation is changed to include the documentation generated from
      the header file.
      
      Because the ultimate goal is to provide some end-user
      documentation (or end-administrator documentation), the comments are
      perhaps more user-oriented than might be expected. Since the values
      are shown to users in hexadecimal, the documentation lists them in
      hexadecimal, and the constant declarations are adjusted to match.
      Reviewed-by: NMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: NStephen Kitt <steve@sk2.org>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      9243c6f3
  20. 27 1月, 2020 1 次提交