Skip to content
Snippets Groups Projects
  1. Dec 19, 2021
  2. Dec 15, 2021
  3. Dec 14, 2021
    • Tejun Heo's avatar
      iocost: Fix divide-by-zero on donation from low hweight cgroup · edaa2633
      Tejun Heo authored
      
      The donation calculation logic assumes that the donor has non-zero
      after-donation hweight, so the lowest active hweight a donating cgroup can
      have is 2 so that it can donate 1 while keeping the other 1 for itself.
      Earlier, we only donated from cgroups with sizable surpluses so this
      condition was always true. However, with the precise donation algorithm
      implemented, f1de2439 ("blk-iocost: revamp donation amount
      determination") made the donation amount calculation exact enabling even low
      hweight cgroups to donate.
      
      This means that in rare occasions, a cgroup with active hweight of 1 can
      enter donation calculation triggering the following warning and then a
      divide-by-zero oops.
      
       WARNING: CPU: 4 PID: 0 at block/blk-iocost.c:1928 transfer_surpluses.cold+0x0/0x53 [884/94867]
       ...
       RIP: 0010:transfer_surpluses.cold+0x0/0x53
       Code: 92 ff 48 c7 c7 28 d1 ab b5 65 48 8b 34 25 00 ae 01 00 48 81 c6 90 06 00 00 e8 8b 3f fe ff 48 c7 c0 ea ff ff ff e9 95 ff 92 ff <0f> 0b 48 c7 c7 30 da ab b5 e8 71 3f fe ff 4c 89 e8 4d 85 ed 74 0
      4
       ...
       Call Trace:
        <IRQ>
        ioc_timer_fn+0x1043/0x1390
        call_timer_fn+0xa1/0x2c0
        __run_timers.part.0+0x1ec/0x2e0
        run_timer_softirq+0x35/0x70
       ...
       iocg: invalid donation weights in /a/b: active=1 donating=1 after=0
      
      Fix it by excluding cgroups w/ active hweight < 2 from donating. Excluding
      these extreme low hweight donations shouldn't affect work conservation in
      any meaningful way.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Fixes: f1de2439 ("blk-iocost: revamp donation amount determination")
      Cc: stable@vger.kernel.org # v5.10+
      Link: https://lore.kernel.org/r/Ybfh86iSvpWKxhVM@slm.duckdns.org
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      edaa2633
  4. Dec 10, 2021
  5. Dec 07, 2021
    • Pavel Begunkov's avatar
      block: fix single bio async DIO error handling · 75feae73
      Pavel Begunkov authored
      
      BUG: KASAN: use-after-free in io_submit_one+0x496/0x2fe0 fs/aio.c:1882
      CPU: 2 PID: 15100 Comm: syz-executor873 Not tainted 5.16.0-rc1-syzk #1
      Hardware name: Red Hat KVM, BIOS 1.13.0-2.module+el8.3.0+7860+a7792d29
      04/01/2014
      Call Trace:
        [...]
        refcount_dec_and_test include/linux/refcount.h:333 [inline]
        iocb_put fs/aio.c:1161 [inline]
        io_submit_one+0x496/0x2fe0 fs/aio.c:1882
        __do_sys_io_submit fs/aio.c:1938 [inline]
        __se_sys_io_submit fs/aio.c:1908 [inline]
        __x64_sys_io_submit+0x1c7/0x4a0 fs/aio.c:1908
        do_syscall_x64 arch/x86/entry/common.c:50 [inline]
        do_syscall_64+0x3a/0x80 arch/x86/entry/common.c:80
        entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      __blkdev_direct_IO_async() returns errors from bio_iov_iter_get_pages()
      directly, in which case upper layers won't be expecting ->ki_complete
      to be called by the block layer and will terminate the request. However,
      there is also bio_endio() leading to a second ->ki_complete and a double
      free.
      
      Fixes: 54a88eb8 ("block: add single bio async direct IO helper")
      Reported-by: default avatarGeorge Kennedy <george.kennedy@oracle.com>
      Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
      Link: https://lore.kernel.org/r/c9eb786f6cef041e159e6287de131bec0719ad5c.1638907997.git.asml.silence@gmail.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      75feae73
  6. Dec 03, 2021
  7. Nov 26, 2021
  8. Nov 25, 2021
  9. Nov 23, 2021
  10. Nov 19, 2021
  11. Nov 17, 2021
  12. Nov 16, 2021
    • Ming Lei's avatar
      blk-mq: cancel blk-mq dispatch work in both blk_cleanup_queue and disk_release() · 2a19b28f
      Ming Lei authored
      
      For avoiding to slow down queue destroy, we don't call
      blk_mq_quiesce_queue() in blk_cleanup_queue(), instead of delaying to
      cancel dispatch work in blk_release_queue().
      
      However, this way has caused kernel oops[1], reported by Changhui. The log
      shows that scsi_device can be freed before running blk_release_queue(),
      which is expected too since scsi_device is released after the scsi disk
      is closed and the scsi_device is removed.
      
      Fixes the issue by canceling blk-mq dispatch work in both blk_cleanup_queue()
      and disk_release():
      
      1) when disk_release() is run, the disk has been closed, and any sync
      dispatch activities have been done, so canceling dispatch work is enough to
      quiesce filesystem I/O dispatch activity.
      
      2) in blk_cleanup_queue(), we only focus on passthrough request, and
      passthrough request is always explicitly allocated & freed by
      its caller, so once queue is frozen, all sync dispatch activity
      for passthrough request has been done, then it is enough to just cancel
      dispatch work for avoiding any dispatch activity.
      
      [1] kernel panic log
      [12622.769416] BUG: kernel NULL pointer dereference, address: 0000000000000300
      [12622.777186] #PF: supervisor read access in kernel mode
      [12622.782918] #PF: error_code(0x0000) - not-present page
      [12622.788649] PGD 0 P4D 0
      [12622.791474] Oops: 0000 [#1] PREEMPT SMP PTI
      [12622.796138] CPU: 10 PID: 744 Comm: kworker/10:1H Kdump: loaded Not tainted 5.15.0+ #1
      [12622.804877] Hardware name: Dell Inc. PowerEdge R730/0H21J3, BIOS 1.5.4 10/002/2015
      [12622.813321] Workqueue: kblockd blk_mq_run_work_fn
      [12622.818572] RIP: 0010:sbitmap_get+0x75/0x190
      [12622.823336] Code: 85 80 00 00 00 41 8b 57 08 85 d2 0f 84 b1 00 00 00 45 31 e4 48 63 cd 48 8d 1c 49 48 c1 e3 06 49 03 5f 10 4c 8d 6b 40 83 f0 01 <48> 8b 33 44 89 f2 4c 89 ef 0f b6 c8 e8 fa f3 ff ff 83 f8 ff 75 58
      [12622.844290] RSP: 0018:ffffb00a446dbd40 EFLAGS: 00010202
      [12622.850120] RAX: 0000000000000001 RBX: 0000000000000300 RCX: 0000000000000004
      [12622.858082] RDX: 0000000000000006 RSI: 0000000000000082 RDI: ffffa0b7a2dfe030
      [12622.866042] RBP: 0000000000000004 R08: 0000000000000001 R09: ffffa0b742721334
      [12622.874003] R10: 0000000000000008 R11: 0000000000000008 R12: 0000000000000000
      [12622.881964] R13: 0000000000000340 R14: 0000000000000000 R15: ffffa0b7a2dfe030
      [12622.889926] FS:  0000000000000000(0000) GS:ffffa0baafb40000(0000) knlGS:0000000000000000
      [12622.898956] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [12622.905367] CR2: 0000000000000300 CR3: 0000000641210001 CR4: 00000000001706e0
      [12622.913328] Call Trace:
      [12622.916055]  <TASK>
      [12622.918394]  scsi_mq_get_budget+0x1a/0x110
      [12622.922969]  __blk_mq_do_dispatch_sched+0x1d4/0x320
      [12622.928404]  ? pick_next_task_fair+0x39/0x390
      [12622.933268]  __blk_mq_sched_dispatch_requests+0xf4/0x140
      [12622.939194]  blk_mq_sched_dispatch_requests+0x30/0x60
      [12622.944829]  __blk_mq_run_hw_queue+0x30/0xa0
      [12622.949593]  process_one_work+0x1e8/0x3c0
      [12622.954059]  worker_thread+0x50/0x3b0
      [12622.958144]  ? rescuer_thread+0x370/0x370
      [12622.962616]  kthread+0x158/0x180
      [12622.966218]  ? set_kthread_struct+0x40/0x40
      [12622.970884]  ret_from_fork+0x22/0x30
      [12622.974875]  </TASK>
      [12622.977309] Modules linked in: scsi_debug rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd grace fscache netfs sunrpc dm_multipath intel_rapl_msr intel_rapl_common dell_wmi_descriptor sb_edac rfkill video x86_pkg_temp_thermal intel_powerclamp dcdbas coretemp kvm_intel kvm mgag200 irqbypass i2c_algo_bit rapl drm_kms_helper ipmi_ssif intel_cstate intel_uncore syscopyarea sysfillrect sysimgblt fb_sys_fops pcspkr cec mei_me lpc_ich mei ipmi_si ipmi_devintf ipmi_msghandler acpi_power_meter drm fuse xfs libcrc32c sr_mod cdrom sd_mod t10_pi sg ixgbe ahci libahci crct10dif_pclmul crc32_pclmul crc32c_intel libata megaraid_sas ghash_clmulni_intel tg3 wdat_wdt mdio dca wmi dm_mirror dm_region_hash dm_log dm_mod [last unloaded: scsi_debug]
      
      Reported-by: default avatarChanghuiZhong <czhong@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Bart Van Assche <bvanassche@acm.org>
      Cc: linux-scsi@vger.kernel.org
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20211116014343.610501-1-ming.lei@redhat.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      2a19b28f
    • Jens Axboe's avatar
      block: fix missing queue put in error path · 95febeb6
      Jens Axboe authored
      If we fail the submission queue checks, we don't put the queue afterwards.
      This can cause various issues like stalls on scheduler switch or failure
      to remove the device, or like in the original bug report, timeout waiting
      for the device on reboot/restart.
      
      While in there, fix a few whitespace discrepancies in the surrounding
      code.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=215039
      
      
      Fixes: b637108a ("blk-mq: fix filesystem I/O request allocation")
      Reported-and-tested-by: default avatarStephen Smith <stephenmsmith@blueyonder.co.uk>
      Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      95febeb6
  13. Nov 15, 2021
  14. Nov 12, 2021
    • Ming Lei's avatar
      blk-mq: fix filesystem I/O request allocation · b637108a
      Ming Lei authored
      
      submit_bio_checks() may update bio->bi_opf, so we have to initialize
      blk_mq_alloc_data.cmd_flags with bio->bi_opf after submit_bio_checks()
      returns when allocating new request.
      
      In case of using cached request, fallback to allocate new request if
      cached rq isn't compatible with the incoming bio, otherwise change
      rq->cmd_flags with incoming bio->bi_opf.
      
      Fixes: 900e0807 ("block: move queue enter logic into blk_mq_submit_bio()")
      Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Tested-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      b637108a
    • Laibin Qiu's avatar
      blkcg: Remove extra blkcg_bio_issue_init · b781d8db
      Laibin Qiu authored
      
      KASAN reports a use-after-free report when doing block test:
      
      ==================================================================
      [10050.967049] BUG: KASAN: use-after-free in
      submit_bio_checks+0x1539/0x1550
      
      [10050.977638] Call Trace:
      [10050.978190]  dump_stack+0x9b/0xce
      [10050.979674]  print_address_description.constprop.6+0x3e/0x60
      [10050.983510]  kasan_report.cold.9+0x22/0x3a
      [10050.986089]  submit_bio_checks+0x1539/0x1550
      [10050.989576]  submit_bio_noacct+0x83/0xc80
      [10050.993714]  submit_bio+0xa7/0x330
      [10050.994435]  mpage_readahead+0x380/0x500
      [10050.998009]  read_pages+0x1c1/0xbf0
      [10051.002057]  page_cache_ra_unbounded+0x4c2/0x6f0
      [10051.007413]  do_page_cache_ra+0xda/0x110
      [10051.008207]  force_page_cache_ra+0x23d/0x3d0
      [10051.009087]  page_cache_sync_ra+0xca/0x300
      [10051.009970]  generic_file_buffered_read+0xbea/0x2130
      [10051.012685]  generic_file_read_iter+0x315/0x490
      [10051.014472]  blkdev_read_iter+0x113/0x1b0
      [10051.015300]  aio_read+0x2ad/0x450
      [10051.023786]  io_submit_one+0xc8e/0x1d60
      [10051.029855]  __se_sys_io_submit+0x125/0x350
      [10051.033442]  do_syscall_64+0x2d/0x40
      [10051.034156]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      [10051.048733] Allocated by task 18598:
      [10051.049482]  kasan_save_stack+0x19/0x40
      [10051.050263]  __kasan_kmalloc.constprop.1+0xc1/0xd0
      [10051.051230]  kmem_cache_alloc+0x146/0x440
      [10051.052060]  mempool_alloc+0x125/0x2f0
      [10051.052818]  bio_alloc_bioset+0x353/0x590
      [10051.053658]  mpage_alloc+0x3b/0x240
      [10051.054382]  do_mpage_readpage+0xddf/0x1ef0
      [10051.055250]  mpage_readahead+0x264/0x500
      [10051.056060]  read_pages+0x1c1/0xbf0
      [10051.056758]  page_cache_ra_unbounded+0x4c2/0x6f0
      [10051.057702]  do_page_cache_ra+0xda/0x110
      [10051.058511]  force_page_cache_ra+0x23d/0x3d0
      [10051.059373]  page_cache_sync_ra+0xca/0x300
      [10051.060198]  generic_file_buffered_read+0xbea/0x2130
      [10051.061195]  generic_file_read_iter+0x315/0x490
      [10051.062189]  blkdev_read_iter+0x113/0x1b0
      [10051.063015]  aio_read+0x2ad/0x450
      [10051.063686]  io_submit_one+0xc8e/0x1d60
      [10051.064467]  __se_sys_io_submit+0x125/0x350
      [10051.065318]  do_syscall_64+0x2d/0x40
      [10051.066082]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      [10051.067455] Freed by task 13307:
      [10051.068136]  kasan_save_stack+0x19/0x40
      [10051.068931]  kasan_set_track+0x1c/0x30
      [10051.069726]  kasan_set_free_info+0x1b/0x30
      [10051.070621]  __kasan_slab_free+0x111/0x160
      [10051.071480]  kmem_cache_free+0x94/0x460
      [10051.072256]  mempool_free+0xd6/0x320
      [10051.072985]  bio_free+0xe0/0x130
      [10051.073630]  bio_put+0xab/0xe0
      [10051.074252]  bio_endio+0x3a6/0x5d0
      [10051.074984]  blk_update_request+0x590/0x1370
      [10051.075870]  scsi_end_request+0x7d/0x400
      [10051.076667]  scsi_io_completion+0x1aa/0xe50
      [10051.077503]  scsi_softirq_done+0x11b/0x240
      [10051.078344]  blk_mq_complete_request+0xd4/0x120
      [10051.079275]  scsi_mq_done+0xf0/0x200
      [10051.080036]  virtscsi_vq_done+0xbc/0x150
      [10051.080850]  vring_interrupt+0x179/0x390
      [10051.081650]  __handle_irq_event_percpu+0xf7/0x490
      [10051.082626]  handle_irq_event_percpu+0x7b/0x160
      [10051.083527]  handle_irq_event+0xcc/0x170
      [10051.084297]  handle_edge_irq+0x215/0xb20
      [10051.085122]  asm_call_irq_on_stack+0xf/0x20
      [10051.085986]  common_interrupt+0xae/0x120
      [10051.086830]  asm_common_interrupt+0x1e/0x40
      
      ==================================================================
      
      Bio will be checked at beginning of submit_bio_noacct(). If bio needs
      to be throttled, it will start the timer and stop submit bio directly.
      Bio will submit in blk_throtl_dispatch_work_fn() when the timer expires.
      But in the current process, if bio is throttled, it will still set bio
      issue->value by blkcg_bio_issue_init(). This is redundant and may cause
      the above use-after-free.
      
      CPU0                                   CPU1
      submit_bio
      submit_bio_noacct
        submit_bio_checks
          blk_throtl_bio()
            <=mod_timer(&sq->pending_timer
                                            blk_throtl_dispatch_work_fn
                                              submit_bio_noacct() <= bio have
                                              throttle tag, will throw directly
                                              and bio issue->value will be set
                                              here
      
                                            bio_endio()
                                            bio_put()
                                            bio_free() <= free this bio
      
          blkcg_bio_issue_init(bio)
            <= bio has been freed and
            will lead to UAF
        return BLK_QC_T_NONE
      
      Fix this by remove extra blkcg_bio_issue_init.
      
      Fixes: e439bedf (blkcg: consolidate bio_issue_init() to be a part of core)
      Signed-off-by: default avatarLaibin Qiu <qiulaibin@huawei.com>
      Link: https://lore.kernel.org/r/20211112093354.3581504-1-qiulaibin@huawei.com
      
      
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      b781d8db
  15. Nov 11, 2021
  16. Nov 10, 2021
  17. Nov 09, 2021
  18. Nov 08, 2021
    • Ye Bin's avatar
      blk-mq: don't free tags if the tag_set is used by other device in queue initialztion · a846a8e6
      Ye Bin authored
      
      We got UAF report on v5.10 as follows:
      [ 1446.674930] ==================================================================
      [ 1446.675970] BUG: KASAN: use-after-free in blk_mq_get_driver_tag+0x9a4/0xa90
      [ 1446.676902] Read of size 8 at addr ffff8880185afd10 by task kworker/1:2/12348
      [ 1446.677851]
      [ 1446.678073] CPU: 1 PID: 12348 Comm: kworker/1:2 Not tainted 5.10.0-10177-gc9c81b1e346a #2
      [ 1446.679168] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
      [ 1446.680692] Workqueue: kthrotld blk_throtl_dispatch_work_fn
      [ 1446.681448] Call Trace:
      [ 1446.681800]  dump_stack+0x9b/0xce
      [ 1446.682916]  print_address_description.constprop.6+0x3e/0x60
      [ 1446.685999]  kasan_report.cold.9+0x22/0x3a
      [ 1446.687186]  blk_mq_get_driver_tag+0x9a4/0xa90
      [ 1446.687785]  blk_mq_dispatch_rq_list+0x21a/0x1d40
      [ 1446.692576]  __blk_mq_do_dispatch_sched+0x394/0x830
      [ 1446.695758]  __blk_mq_sched_dispatch_requests+0x398/0x4f0
      [ 1446.698279]  blk_mq_sched_dispatch_requests+0xdf/0x140
      [ 1446.698967]  __blk_mq_run_hw_queue+0xc0/0x270
      [ 1446.699561]  __blk_mq_delay_run_hw_queue+0x4cc/0x550
      [ 1446.701407]  blk_mq_run_hw_queue+0x13b/0x2b0
      [ 1446.702593]  blk_mq_sched_insert_requests+0x1de/0x390
      [ 1446.703309]  blk_mq_flush_plug_list+0x4b4/0x760
      [ 1446.705408]  blk_flush_plug_list+0x2c5/0x480
      [ 1446.708471]  blk_finish_plug+0x55/0xa0
      [ 1446.708980]  blk_throtl_dispatch_work_fn+0x23b/0x2e0
      [ 1446.711236]  process_one_work+0x6d4/0xfe0
      [ 1446.711778]  worker_thread+0x91/0xc80
      [ 1446.713400]  kthread+0x32d/0x3f0
      [ 1446.714362]  ret_from_fork+0x1f/0x30
      [ 1446.714846]
      [ 1446.715062] Allocated by task 1:
      [ 1446.715509]  kasan_save_stack+0x19/0x40
      [ 1446.716026]  __kasan_kmalloc.constprop.1+0xc1/0xd0
      [ 1446.716673]  blk_mq_init_tags+0x6d/0x330
      [ 1446.717207]  blk_mq_alloc_rq_map+0x50/0x1c0
      [ 1446.717769]  __blk_mq_alloc_map_and_request+0xe5/0x320
      [ 1446.718459]  blk_mq_alloc_tag_set+0x679/0xdc0
      [ 1446.719050]  scsi_add_host_with_dma.cold.3+0xa0/0x5db
      [ 1446.719736]  virtscsi_probe+0x7bf/0xbd0
      [ 1446.720265]  virtio_dev_probe+0x402/0x6c0
      [ 1446.720808]  really_probe+0x276/0xde0
      [ 1446.721320]  driver_probe_device+0x267/0x3d0
      [ 1446.721892]  device_driver_attach+0xfe/0x140
      [ 1446.722491]  __driver_attach+0x13a/0x2c0
      [ 1446.723037]  bus_for_each_dev+0x146/0x1c0
      [ 1446.723603]  bus_add_driver+0x3fc/0x680
      [ 1446.724145]  driver_register+0x1c0/0x400
      [ 1446.724693]  init+0xa2/0xe8
      [ 1446.725091]  do_one_initcall+0x9e/0x310
      [ 1446.725626]  kernel_init_freeable+0xc56/0xcb9
      [ 1446.726231]  kernel_init+0x11/0x198
      [ 1446.726714]  ret_from_fork+0x1f/0x30
      [ 1446.727212]
      [ 1446.727433] Freed by task 26992:
      [ 1446.727882]  kasan_save_stack+0x19/0x40
      [ 1446.728420]  kasan_set_track+0x1c/0x30
      [ 1446.728943]  kasan_set_free_info+0x1b/0x30
      [ 1446.729517]  __kasan_slab_free+0x111/0x160
      [ 1446.730084]  kfree+0xb8/0x520
      [ 1446.730507]  blk_mq_free_map_and_requests+0x10b/0x1b0
      [ 1446.731206]  blk_mq_realloc_hw_ctxs+0x8cb/0x15b0
      [ 1446.731844]  blk_mq_init_allocated_queue+0x374/0x1380
      [ 1446.732540]  blk_mq_init_queue_data+0x7f/0xd0
      [ 1446.733155]  scsi_mq_alloc_queue+0x45/0x170
      [ 1446.733730]  scsi_alloc_sdev+0x73c/0xb20
      [ 1446.734281]  scsi_probe_and_add_lun+0x9a6/0x2d90
      [ 1446.734916]  __scsi_scan_target+0x208/0xc50
      [ 1446.735500]  scsi_scan_channel.part.3+0x113/0x170
      [ 1446.736149]  scsi_scan_host_selected+0x25a/0x360
      [ 1446.736783]  store_scan+0x290/0x2d0
      [ 1446.737275]  dev_attr_store+0x55/0x80
      [ 1446.737782]  sysfs_kf_write+0x132/0x190
      [ 1446.738313]  kernfs_fop_write_iter+0x319/0x4b0
      [ 1446.738921]  new_sync_write+0x40e/0x5c0
      [ 1446.739429]  vfs_write+0x519/0x720
      [ 1446.739877]  ksys_write+0xf8/0x1f0
      [ 1446.740332]  do_syscall_64+0x2d/0x40
      [ 1446.740802]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [ 1446.741462]
      [ 1446.741670] The buggy address belongs to the object at ffff8880185afd00
      [ 1446.741670]  which belongs to the cache kmalloc-256 of size 256
      [ 1446.743276] The buggy address is located 16 bytes inside of
      [ 1446.743276]  256-byte region [ffff8880185afd00, ffff8880185afe00)
      [ 1446.744765] The buggy address belongs to the page:
      [ 1446.745416] page:ffffea0000616b00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x185ac
      [ 1446.746694] head:ffffea0000616b00 order:2 compound_mapcount:0 compound_pincount:0
      [ 1446.747719] flags: 0x1fffff80010200(slab|head)
      [ 1446.748337] raw: 001fffff80010200 ffffea00006a3208 ffffea000061bf08 ffff88801004f240
      [ 1446.749404] raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
      [ 1446.750455] page dumped because: kasan: bad access detected
      [ 1446.751227]
      [ 1446.751445] Memory state around the buggy address:
      [ 1446.752102]  ffff8880185afc00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      [ 1446.753090]  ffff8880185afc80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      [ 1446.754079] >ffff8880185afd00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [ 1446.755065]                          ^
      [ 1446.755589]  ffff8880185afd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [ 1446.756574]  ffff8880185afe00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      [ 1446.757566] ==================================================================
      
      Flag 'BLK_MQ_F_TAG_QUEUE_SHARED' will be set if the second device on the
      same host initializes it's queue successfully. However, if the second
      device failed to allocate memory in blk_mq_alloc_and_init_hctx() from
      blk_mq_realloc_hw_ctxs() from blk_mq_init_allocated_queue(),
      __blk_mq_free_map_and_rqs() will be called on error path, and if
      'BLK_MQ_TAG_HCTX_SHARED' is not set, 'tag_set->tags' will be freed
      while it's still used by the first device.
      
      To fix this issue we move release newly allocated hardware context from
      blk_mq_realloc_hw_ctxs to __blk_mq_update_nr_hw_queues. As there is needn't to
      release hardware context in blk_mq_init_allocated_queue.
      
      Fixes: 868f2f0b ("blk-mq: dynamic h/w context count")
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
      Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20211108074019.1058843-1-yebin10@huawei.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      a846a8e6
  19. Nov 05, 2021
  20. Nov 04, 2021
  21. Nov 03, 2021
  22. Nov 02, 2021
Loading