An error occurred fetching the project authors.
  1. 10 Jun, 2022 1 commit
  2. 26 Apr, 2022 3 commits
  3. 12 Apr, 2022 1 commit
    • Bart Van Assche's avatar
      Revert "scsi: scsi_debug: Address races following module load" · f19fe8f3
      Bart Van Assche authored
      Revert the patch mentioned in the subject since it blocks I/O after module
      unload has started while this is a legitimate use case. For e.g.  blktests
      test case srp/001 that patch causes a command timeout to be triggered for
      the following call stack:
      
      __schedule+0x4c3/0xd20
      schedule+0x82/0x110
      schedule_timeout+0x122/0x200
      io_schedule_timeout+0x7b/0xc0
      __wait_for_common+0x2bc/0x380
      wait_for_completion_io_timeout+0x1d/0x20
      blk_execute_rq+0x1db/0x200
      __scsi_execute+0x1fb/0x310
      sd_sync_cache+0x155/0x2c0 [sd_mod]
      sd_shutdown+0xbb/0x190 [sd_mod]
      sd_remove+0x5b/0x80 [sd_mod]
      device_remove+0x9a/0xb0
      device_release_driver_internal+0x2c5/0x360
      device_release_driver+0x12/0x20
      bus_remove_device+0x1aa/0x270
      device_del+0x2d4/0x640
      __scsi_remove_device+0x168/0x1a0
      scsi_forget_host+0xa8/0xb0
      scsi_remove_host+0x9b/0x150
      sdebug_driver_remove+0x3d/0x140 [scsi_debug]
      device_remove+0x6f/0xb0
      device_release_driver_internal+0x2c5/0x360
      device_release_driver+0x12/0x20
      bus_remove_device+0x1aa/0x270
      device_del+0x2d4/0x640
      device_unregister+0x18/0x70
      sdebug_do_remove_host+0x138/0x180 [scsi_debug]
      scsi_debug_exit+0x45/0xd5 [scsi_debug]
      __do_sys_delete_module.constprop.0+0x210/0x320
      __x64_sys_delete_module+0x1f/0x30
      do_syscall_64+0x35/0x80
      entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Link: https://lore.kernel.org/r/20220409043704.28573-1-bvanassche@acm.org
      Fixes: 2aad3cd8 ("scsi: scsi_debug: Address races following module load")
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Yi Zhang <yi.zhang@redhat.com>
      Cc: Bob Pearson <rpearsonhpe@gmail.com>
      Reported-by: default avatarYi Zhang <yi.zhang@redhat.com>
      Tested-by: default avatarYi Zhang <yi.zhang@redhat.com>
      Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      f19fe8f3
  4. 07 Apr, 2022 1 commit
  5. 09 Mar, 2022 2 commits
  6. 02 Feb, 2022 1 commit
  7. 25 Jan, 2022 7 commits
  8. 07 Dec, 2021 1 commit
  9. 23 Nov, 2021 2 commits
  10. 19 Nov, 2021 1 commit
    • George Kennedy's avatar
      scsi: scsi_debug: Fix type in min_t to avoid stack OOB · 36e07d7e
      George Kennedy authored
      Change min_t() to use type "u32" instead of type "int" to avoid stack out
      of bounds. With min_t() type "int" the values get sign extended and the
      larger value gets used causing stack out of bounds.
      
      BUG: KASAN: stack-out-of-bounds in memcpy include/linux/fortify-string.h:191 [inline]
      BUG: KASAN: stack-out-of-bounds in sg_copy_buffer+0x1de/0x240 lib/scatterlist.c:976
      Read of size 127 at addr ffff888072607128 by task syz-executor.7/18707
      
      CPU: 1 PID: 18707 Comm: syz-executor.7 Not tainted 5.15.0-syzk #1
      Hardware name: Red Hat KVM, BIOS 1.13.0-2
      Call Trace:
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x89/0xb5 lib/dump_stack.c:106
       print_address_description.constprop.9+0x28/0x160 mm/kasan/report.c:256
       __kasan_report mm/kasan/report.c:442 [inline]
       kasan_report.cold.14+0x7d/0x117 mm/kasan/report.c:459
       check_region_inline mm/kasan/generic.c:183 [inline]
       kasan_check_range+0x1a3/0x210 mm/kasan/generic.c:189
       memcpy+0x23/0x60 mm/kasan/shadow.c:65
       memcpy include/linux/fortify-string.h:191 [inline]
       sg_copy_buffer+0x1de/0x240 lib/scatterlist.c:976
       sg_copy_from_buffer+0x33/0x40 lib/scatterlist.c:1000
       fill_from_dev_buffer.part.34+0x82/0x130 drivers/scsi/scsi_debug.c:1162
       fill_from_dev_buffer drivers/scsi/scsi_debug.c:1888 [inline]
       resp_readcap16+0x365/0x3b0 drivers/scsi/scsi_debug.c:1887
       schedule_resp+0x4d8/0x1a70 drivers/scsi/scsi_debug.c:5478
       scsi_debug_queuecommand+0x8c9/0x1ec0 drivers/scsi/scsi_debug.c:7533
       scsi_dispatch_cmd drivers/scsi/scsi_lib.c:1520 [inline]
       scsi_queue_rq+0x16b0/0x2d40 drivers/scsi/scsi_lib.c:1699
       blk_mq_dispatch_rq_list+0xb9b/0x2700 block/blk-mq.c:1639
       __blk_mq_sched_dispatch_requests+0x28f/0x590 block/blk-mq-sched.c:325
       blk_mq_sched_dispatch_requests+0x105/0x190 block/blk-mq-sched.c:358
       __blk_mq_run_hw_queue+0xe5/0x150 block/blk-mq.c:1761
       __blk_mq_delay_run_hw_queue+0x4f8/0x5c0 block/blk-mq.c:1838
       blk_mq_run_hw_queue+0x18d/0x350 block/blk-mq.c:1891
       blk_mq_sched_insert_request+0x3db/0x4e0 block/blk-mq-sched.c:474
       blk_execute_rq_nowait+0x16b/0x1c0 block/blk-exec.c:62
       sg_common_write.isra.18+0xeb3/0x2000 drivers/scsi/sg.c:836
       sg_new_write.isra.19+0x570/0x8c0 drivers/scsi/sg.c:774
       sg_ioctl_common+0x14d6/0x2710 drivers/scsi/sg.c:939
       sg_ioctl+0xa2/0x180 drivers/scsi/sg.c:1165
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl fs/ioctl.c:860 [inline]
       __x64_sys_ioctl+0x19d/0x220 fs/ioctl.c:860
       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
      
      Link: https://lore.kernel.org/r/1636484247-21254-1-git-send-email-george.kennedy@oracle.comReported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
      Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: default avatarGeorge Kennedy <george.kennedy@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      36e07d7e
  11. 05 Nov, 2021 1 commit
    • George Kennedy's avatar
      scsi: scsi_debug: Don't call kcalloc() if size arg is zero · 3344b58b
      George Kennedy authored
      If the size arg to kcalloc() is zero, it returns ZERO_SIZE_PTR.  Because of
      that, for a following NULL pointer check to work on the returned pointer,
      kcalloc() must not be called with the size arg equal to zero. Return early
      without error before the kcalloc() call if size arg is zero.
      
      BUG: KASAN: null-ptr-deref in memcpy include/linux/fortify-string.h:191 [inline]
      BUG: KASAN: null-ptr-deref in sg_copy_buffer+0x138/0x240 lib/scatterlist.c:974
      Write of size 4 at addr 0000000000000010 by task syz-executor.1/22789
      
      CPU: 1 PID: 22789 Comm: syz-executor.1 Not tainted 5.15.0-syzk #1
      Hardware name: Red Hat KVM, BIOS 1.13.0-2
      Call Trace:
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x89/0xb5 lib/dump_stack.c:106
       __kasan_report mm/kasan/report.c:446 [inline]
       kasan_report.cold.14+0x112/0x117 mm/kasan/report.c:459
       check_region_inline mm/kasan/generic.c:183 [inline]
       kasan_check_range+0x1a3/0x210 mm/kasan/generic.c:189
       memcpy+0x3b/0x60 mm/kasan/shadow.c:66
       memcpy include/linux/fortify-string.h:191 [inline]
       sg_copy_buffer+0x138/0x240 lib/scatterlist.c:974
       do_dout_fetch drivers/scsi/scsi_debug.c:2954 [inline]
       do_dout_fetch drivers/scsi/scsi_debug.c:2946 [inline]
       resp_verify+0x49e/0x930 drivers/scsi/scsi_debug.c:4276
       schedule_resp+0x4d8/0x1a70 drivers/scsi/scsi_debug.c:5478
       scsi_debug_queuecommand+0x8c9/0x1ec0 drivers/scsi/scsi_debug.c:7533
       scsi_dispatch_cmd drivers/scsi/scsi_lib.c:1520 [inline]
       scsi_queue_rq+0x16b0/0x2d40 drivers/scsi/scsi_lib.c:1699
       blk_mq_dispatch_rq_list+0xb9b/0x2700 block/blk-mq.c:1639
       __blk_mq_sched_dispatch_requests+0x28f/0x590 block/blk-mq-sched.c:325
       blk_mq_sched_dispatch_requests+0x105/0x190 block/blk-mq-sched.c:358
       __blk_mq_run_hw_queue+0xe5/0x150 block/blk-mq.c:1761
       __blk_mq_delay_run_hw_queue+0x4f8/0x5c0 block/blk-mq.c:1838
       blk_mq_run_hw_queue+0x18d/0x350 block/blk-mq.c:1891
       blk_mq_sched_insert_request+0x3db/0x4e0 block/blk-mq-sched.c:474
       blk_execute_rq_nowait+0x16b/0x1c0 block/blk-exec.c:62
       blk_execute_rq+0xdb/0x360 block/blk-exec.c:102
       sg_scsi_ioctl drivers/scsi/scsi_ioctl.c:621 [inline]
       scsi_ioctl+0x8bb/0x15c0 drivers/scsi/scsi_ioctl.c:930
       sg_ioctl_common+0x172d/0x2710 drivers/scsi/sg.c:1112
       sg_ioctl+0xa2/0x180 drivers/scsi/sg.c:1165
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl fs/ioctl.c:860 [inline]
       __x64_sys_ioctl+0x19d/0x220 fs/ioctl.c:860
       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
      
      Link: https://lore.kernel.org/r/1636056397-13151-1-git-send-email-george.kennedy@oracle.comReported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
      Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: default avatarGeorge Kennedy <george.kennedy@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      3344b58b
  12. 19 Oct, 2021 2 commits
    • Ye Bin's avatar
      scsi: scsi_debug: Fix out-of-bound read in resp_report_tgtpgs() · f347c268
      Ye Bin authored
      The following issue was observed running syzkaller:
      
      BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:377 [inline]
      BUG: KASAN: slab-out-of-bounds in sg_copy_buffer+0x150/0x1c0 lib/scatterlist.c:831
      Read of size 2132 at addr ffff8880aea95dc8 by task syz-executor.0/9815
      
      CPU: 0 PID: 9815 Comm: syz-executor.0 Not tainted 4.19.202-00874-gfc0fe04215a9 #2
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0xe4/0x14a lib/dump_stack.c:118
       print_address_description+0x73/0x280 mm/kasan/report.c:253
       kasan_report_error mm/kasan/report.c:352 [inline]
       kasan_report+0x272/0x370 mm/kasan/report.c:410
       memcpy+0x1f/0x50 mm/kasan/kasan.c:302
       memcpy include/linux/string.h:377 [inline]
       sg_copy_buffer+0x150/0x1c0 lib/scatterlist.c:831
       fill_from_dev_buffer+0x14f/0x340 drivers/scsi/scsi_debug.c:1021
       resp_report_tgtpgs+0x5aa/0x770 drivers/scsi/scsi_debug.c:1772
       schedule_resp+0x464/0x12f0 drivers/scsi/scsi_debug.c:4429
       scsi_debug_queuecommand+0x467/0x1390 drivers/scsi/scsi_debug.c:5835
       scsi_dispatch_cmd+0x3fc/0x9b0 drivers/scsi/scsi_lib.c:1896
       scsi_request_fn+0x1042/0x1810 drivers/scsi/scsi_lib.c:2034
       __blk_run_queue_uncond block/blk-core.c:464 [inline]
       __blk_run_queue+0x1a4/0x380 block/blk-core.c:484
       blk_execute_rq_nowait+0x1c2/0x2d0 block/blk-exec.c:78
       sg_common_write.isra.19+0xd74/0x1dc0 drivers/scsi/sg.c:847
       sg_write.part.23+0x6e0/0xd00 drivers/scsi/sg.c:716
       sg_write+0x64/0xa0 drivers/scsi/sg.c:622
       __vfs_write+0xed/0x690 fs/read_write.c:485
      kill_bdev:block_device:00000000e138492c
       vfs_write+0x184/0x4c0 fs/read_write.c:549
       ksys_write+0x107/0x240 fs/read_write.c:599
       do_syscall_64+0xc2/0x560 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      We get 'alen' from command its type is int. If userspace passes a large
      length we will get a negative 'alen'.
      
      Switch n, alen, and rlen to u32.
      
      Link: https://lore.kernel.org/r/20211013033913.2551004-3-yebin10@huawei.comAcked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      f347c268
    • Ye Bin's avatar
      scsi: scsi_debug: Fix out-of-bound read in resp_readcap16() · 4e3ace00
      Ye Bin authored
      The following warning was observed running syzkaller:
      
      [ 3813.830724] sg_write: data in/out 65466/242 bytes for SCSI command 0x9e-- guessing data in;
      [ 3813.830724]    program syz-executor not setting count and/or reply_len properly
      [ 3813.836956] ==================================================================
      [ 3813.839465] BUG: KASAN: stack-out-of-bounds in sg_copy_buffer+0x157/0x1e0
      [ 3813.841773] Read of size 4096 at addr ffff8883cf80f540 by task syz-executor/1549
      [ 3813.846612] Call Trace:
      [ 3813.846995]  dump_stack+0x108/0x15f
      [ 3813.847524]  print_address_description+0xa5/0x372
      [ 3813.848243]  kasan_report.cold+0x236/0x2a8
      [ 3813.849439]  check_memory_region+0x240/0x270
      [ 3813.850094]  memcpy+0x30/0x80
      [ 3813.850553]  sg_copy_buffer+0x157/0x1e0
      [ 3813.853032]  sg_copy_from_buffer+0x13/0x20
      [ 3813.853660]  fill_from_dev_buffer+0x135/0x370
      [ 3813.854329]  resp_readcap16+0x1ac/0x280
      [ 3813.856917]  schedule_resp+0x41f/0x1630
      [ 3813.858203]  scsi_debug_queuecommand+0xb32/0x17e0
      [ 3813.862699]  scsi_dispatch_cmd+0x330/0x950
      [ 3813.863329]  scsi_request_fn+0xd8e/0x1710
      [ 3813.863946]  __blk_run_queue+0x10b/0x230
      [ 3813.864544]  blk_execute_rq_nowait+0x1d8/0x400
      [ 3813.865220]  sg_common_write.isra.0+0xe61/0x2420
      [ 3813.871637]  sg_write+0x6c8/0xef0
      [ 3813.878853]  __vfs_write+0xe4/0x800
      [ 3813.883487]  vfs_write+0x17b/0x530
      [ 3813.884008]  ksys_write+0x103/0x270
      [ 3813.886268]  __x64_sys_write+0x77/0xc0
      [ 3813.886841]  do_syscall_64+0x106/0x360
      [ 3813.887415]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      This issue can be reproduced with the following syzkaller log:
      
      r0 = openat(0xffffffffffffff9c, &(0x7f0000000040)='./file0\x00', 0x26e1, 0x0)
      r1 = syz_open_procfs(0xffffffffffffffff, &(0x7f0000000000)='fd/3\x00')
      open_by_handle_at(r1, &(0x7f00000003c0)=ANY=[@ANYRESHEX], 0x602000)
      r2 = syz_open_dev$sg(&(0x7f0000000000), 0x0, 0x40782)
      write$binfmt_aout(r2, &(0x7f0000000340)=ANY=[@ANYBLOB="00000000deff000000000000000000000000000000000000000000000000000047f007af9e107a41ec395f1bded7be24277a1501ff6196a83366f4e6362bc0ff2b247f68a972989b094b2da4fb3607fcf611a22dd04310d28c75039d"], 0x126)
      
      In resp_readcap16() we get "int alloc_len" value -1104926854, and then pass
      the huge arr_len to fill_from_dev_buffer(), but arr is only 32 bytes. This
      leads to OOB in sg_copy_buffer().
      
      To solve this issue, define alloc_len as u32.
      
      Link: https://lore.kernel.org/r/20211013033913.2551004-2-yebin10@huawei.comAcked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      4e3ace00
  13. 18 Oct, 2021 1 commit
  14. 17 Oct, 2021 1 commit
  15. 12 Aug, 2021 1 commit
  16. 21 Jul, 2021 3 commits
  17. 01 Jun, 2021 2 commits
  18. 15 May, 2021 1 commit
  19. 03 May, 2021 1 commit
  20. 04 Mar, 2021 3 commits
  21. 09 Feb, 2021 1 commit
  22. 23 Jan, 2021 1 commit
  23. 06 Jan, 2021 1 commit
  24. 06 Oct, 2020 1 commit