* [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release
@ 2024-11-06 11:47 syzbot
2024-11-15 13:36 ` Suraj Sonawane
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: syzbot @ 2024-11-06 11:47 UTC (permalink / raw)
To: James.Bottomley, dgilbert, linux-kernel, linux-scsi, linux-usb,
martin.petersen, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 11066801dd4b Merge tag 'linux_kselftest-fixes-6.12-rc6' of..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16146aa7980000
kernel config: https://syzkaller.appspot.com/x/.config?x=672325e7ab17fdf7
dashboard link: https://syzkaller.appspot.com/bug?extid=7efb5850a17ba6ce098b
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14e8755f980000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d5100fe708c2/disk-11066801.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/581317b0fef2/vmlinux-11066801.xz
kernel image: https://storage.googleapis.com/syzbot-assets/c7571fdba64f/bzImage-11066801.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+7efb5850a17ba6ce098b@syzkaller.appspotmail.com
==================================================================
BUG: KASAN: slab-use-after-free in lock_release+0x151/0xa30 kernel/locking/lockdep.c:5838
Read of size 8 at addr ffff8880312a38c0 by task syz.2.335/8457
CPU: 1 UID: 0 PID: 8457 Comm: syz.2.335 Not tainted 6.12.0-rc5-syzkaller-00299-g11066801dd4b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:377 [inline]
print_report+0x169/0x550 mm/kasan/report.c:488
kasan_report+0x143/0x180 mm/kasan/report.c:601
lock_release+0x151/0xa30 kernel/locking/lockdep.c:5838
__mutex_unlock_slowpath+0xe2/0x750 kernel/locking/mutex.c:912
sg_release+0x1f4/0x2e0 drivers/scsi/sg.c:407
__fput+0x23f/0x880 fs/file_table.c:431
task_work_run+0x24f/0x310 kernel/task_work.c:239
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
__syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218
do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f312af7e719
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdb5d17628 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007f312b137a80 RCX: 00007f312af7e719
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 00007f312b137a80 R08: 0000000000000000 R09: 00007ffdb5d1791f
R10: 000000000003fdc8 R11: 0000000000000246 R12: 000000000005f4a4
R13: 00007ffdb5d17730 R14: 0000000000000032 R15: ffffffffffffffff
</TASK>
Allocated by task 7133:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
__kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:394
kasan_kmalloc include/linux/kasan.h:257 [inline]
__kmalloc_cache_noprof+0x19c/0x2c0 mm/slub.c:4295
kmalloc_noprof include/linux/slab.h:878 [inline]
kzalloc_noprof include/linux/slab.h:1014 [inline]
sg_alloc drivers/scsi/sg.c:1444 [inline]
sg_add_device+0x139/0xb10 drivers/scsi/sg.c:1518
device_add+0xa1f/0xbf0 drivers/base/core.c:3698
scsi_sysfs_add_sdev+0x306/0x5a0 drivers/scsi/scsi_sysfs.c:1435
scsi_sysfs_add_devices drivers/scsi/scsi_scan.c:1896 [inline]
scsi_finish_async_scan drivers/scsi/scsi_scan.c:1981 [inline]
do_scan_async+0x42a/0x7a0 drivers/scsi/scsi_scan.c:2024
async_run_entry_fn+0xa8/0x420 kernel/async.c:129
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f0/0x390 kernel/kthread.c:389
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
Freed by task 6000:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
poison_slab_object mm/kasan/common.c:247 [inline]
__kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:2342 [inline]
slab_free mm/slub.c:4579 [inline]
kfree+0x1a0/0x440 mm/slub.c:4727
kref_put include/linux/kref.h:65 [inline]
sg_remove_sfp_usercontext+0x331/0x4d0 drivers/scsi/sg.c:2238
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f0/0x390 kernel/kthread.c:389
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
The buggy address belongs to the object at ffff8880312a3800
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 192 bytes inside of
freed 512-byte region [ffff8880312a3800, ffff8880312a3a00)
The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880312a2000 pfn:0x312a0
head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000240 ffff88801ac41c80 ffffea00010c8910 ffffea0001fcb310
raw: ffff8880312a2000 000000000010000d 00000001f5000000 0000000000000000
head: 00fff00000000240 ffff88801ac41c80 ffffea00010c8910 ffffea0001fcb310
head: ffff8880312a2000 000000000010000d 00000001f5000000 0000000000000000
head: 00fff00000000002 ffffea0000c4a801 ffffffffffffffff 0000000000000000
head: ffff888000000004 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5224, tgid 5224 (udevd), ts 31207973672, free_ts 31004401902
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1537
prep_new_page mm/page_alloc.c:1545 [inline]
get_page_from_freelist+0x303f/0x3190 mm/page_alloc.c:3457
__alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4733
alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
alloc_slab_page+0x6a/0x120 mm/slub.c:2412
allocate_slab+0x5a/0x2f0 mm/slub.c:2578
new_slab mm/slub.c:2631 [inline]
___slab_alloc+0xcd1/0x14b0 mm/slub.c:3818
__slab_alloc+0x58/0xa0 mm/slub.c:3908
__slab_alloc_node mm/slub.c:3961 [inline]
slab_alloc_node mm/slub.c:4122 [inline]
__kmalloc_cache_noprof+0x1d5/0x2c0 mm/slub.c:4290
kmalloc_noprof include/linux/slab.h:878 [inline]
kzalloc_noprof include/linux/slab.h:1014 [inline]
kernfs_fop_open+0x3e0/0xd10 fs/kernfs/file.c:623
do_dentry_open+0x978/0x1460 fs/open.c:958
vfs_open+0x3e/0x330 fs/open.c:1088
do_open fs/namei.c:3774 [inline]
path_openat+0x2c84/0x3590 fs/namei.c:3933
do_filp_open+0x235/0x490 fs/namei.c:3960
do_sys_openat2+0x13e/0x1d0 fs/open.c:1415
do_sys_open fs/open.c:1430 [inline]
__do_sys_openat fs/open.c:1446 [inline]
__se_sys_openat fs/open.c:1441 [inline]
__x64_sys_openat+0x247/0x2a0 fs/open.c:1441
page last free pid 16 tgid 16 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
free_pages_prepare mm/page_alloc.c:1108 [inline]
free_unref_page+0xcfb/0xf20 mm/page_alloc.c:2638
rcu_do_batch kernel/rcu/tree.c:2567 [inline]
rcu_core+0xaaa/0x17a0 kernel/rcu/tree.c:2823
handle_softirqs+0x2c5/0x980 kernel/softirq.c:554
run_ksoftirqd+0xca/0x130 kernel/softirq.c:927
smpboot_thread_fn+0x544/0xa30 kernel/smpboot.c:164
kthread+0x2f0/0x390 kernel/kthread.c:389
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
Memory state around the buggy address:
ffff8880312a3780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880312a3800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880312a3880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880312a3900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880312a3980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release
2024-11-06 11:47 [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release syzbot
@ 2024-11-15 13:36 ` Suraj Sonawane
2024-11-15 13:56 ` syzbot
2024-11-15 18:00 ` Bart Van Assche
2024-11-20 8:19 ` Suraj Sonawane
2 siblings, 1 reply; 8+ messages in thread
From: Suraj Sonawane @ 2024-11-15 13:36 UTC (permalink / raw)
To: syzbot
Cc: James.Bottomley, dgilbert, linux-kernel, linux-scsi, linux-usb,
martin.petersen, syzkaller-bugs
[-- Attachment #1.1: Type: text/plain, Size: 10564 bytes --]
#syz test
On Wed, Nov 6, 2024 at 5:17 PM syzbot <
syzbot+7efb5850a17ba6ce098b@syzkaller.appspotmail.com> wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 11066801dd4b Merge tag 'linux_kselftest-fixes-6.12-rc6'
> of..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=16146aa7980000
> kernel config: https://syzkaller.appspot.com/x/.config?x=672325e7ab17fdf7
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=7efb5850a17ba6ce098b
> compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for
> Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14e8755f980000
>
> Downloadable assets:
> disk image:
> https://storage.googleapis.com/syzbot-assets/d5100fe708c2/disk-11066801.raw.xz
> vmlinux:
> https://storage.googleapis.com/syzbot-assets/581317b0fef2/vmlinux-11066801.xz
> kernel image:
> https://storage.googleapis.com/syzbot-assets/c7571fdba64f/bzImage-11066801.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the
> commit:
> Reported-by: syzbot+7efb5850a17ba6ce098b@syzkaller.appspotmail.com
>
> ==================================================================
> BUG: KASAN: slab-use-after-free in lock_release+0x151/0xa30
> kernel/locking/lockdep.c:5838
> Read of size 8 at addr ffff8880312a38c0 by task syz.2.335/8457
>
> CPU: 1 UID: 0 PID: 8457 Comm: syz.2.335 Not tainted
> 6.12.0-rc5-syzkaller-00299-g11066801dd4b #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 09/13/2024
> Call Trace:
> <TASK>
> __dump_stack lib/dump_stack.c:94 [inline]
> dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
> print_address_description mm/kasan/report.c:377 [inline]
> print_report+0x169/0x550 mm/kasan/report.c:488
> kasan_report+0x143/0x180 mm/kasan/report.c:601
> lock_release+0x151/0xa30 kernel/locking/lockdep.c:5838
> __mutex_unlock_slowpath+0xe2/0x750 kernel/locking/mutex.c:912
> sg_release+0x1f4/0x2e0 drivers/scsi/sg.c:407
> __fput+0x23f/0x880 fs/file_table.c:431
> task_work_run+0x24f/0x310 kernel/task_work.c:239
> resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
> exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
> exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
> __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
> syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218
> do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
> RIP: 0033:0x7f312af7e719
> Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7
> 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
> ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
> RSP: 002b:00007ffdb5d17628 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
> RAX: 0000000000000000 RBX: 00007f312b137a80 RCX: 00007f312af7e719
> RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
> RBP: 00007f312b137a80 R08: 0000000000000000 R09: 00007ffdb5d1791f
> R10: 000000000003fdc8 R11: 0000000000000246 R12: 000000000005f4a4
> R13: 00007ffdb5d17730 R14: 0000000000000032 R15: ffffffffffffffff
> </TASK>
>
> Allocated by task 7133:
> kasan_save_stack mm/kasan/common.c:47 [inline]
> kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
> poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
> __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:394
> kasan_kmalloc include/linux/kasan.h:257 [inline]
> __kmalloc_cache_noprof+0x19c/0x2c0 mm/slub.c:4295
> kmalloc_noprof include/linux/slab.h:878 [inline]
> kzalloc_noprof include/linux/slab.h:1014 [inline]
> sg_alloc drivers/scsi/sg.c:1444 [inline]
> sg_add_device+0x139/0xb10 drivers/scsi/sg.c:1518
> device_add+0xa1f/0xbf0 drivers/base/core.c:3698
> scsi_sysfs_add_sdev+0x306/0x5a0 drivers/scsi/scsi_sysfs.c:1435
> scsi_sysfs_add_devices drivers/scsi/scsi_scan.c:1896 [inline]
> scsi_finish_async_scan drivers/scsi/scsi_scan.c:1981 [inline]
> do_scan_async+0x42a/0x7a0 drivers/scsi/scsi_scan.c:2024
> async_run_entry_fn+0xa8/0x420 kernel/async.c:129
> process_one_work kernel/workqueue.c:3229 [inline]
> process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
> worker_thread+0x870/0xd30 kernel/workqueue.c:3391
> kthread+0x2f0/0x390 kernel/kthread.c:389
> ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
>
> Freed by task 6000:
> kasan_save_stack mm/kasan/common.c:47 [inline]
> kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
> kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
> poison_slab_object mm/kasan/common.c:247 [inline]
> __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
> kasan_slab_free include/linux/kasan.h:230 [inline]
> slab_free_hook mm/slub.c:2342 [inline]
> slab_free mm/slub.c:4579 [inline]
> kfree+0x1a0/0x440 mm/slub.c:4727
> kref_put include/linux/kref.h:65 [inline]
> sg_remove_sfp_usercontext+0x331/0x4d0 drivers/scsi/sg.c:2238
> process_one_work kernel/workqueue.c:3229 [inline]
> process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
> worker_thread+0x870/0xd30 kernel/workqueue.c:3391
> kthread+0x2f0/0x390 kernel/kthread.c:389
> ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
>
> The buggy address belongs to the object at ffff8880312a3800
> which belongs to the cache kmalloc-512 of size 512
> The buggy address is located 192 bytes inside of
> freed 512-byte region [ffff8880312a3800, ffff8880312a3a00)
>
> The buggy address belongs to the physical page:
> page: refcount:1 mapcount:0 mapping:0000000000000000
> index:0xffff8880312a2000 pfn:0x312a0
> head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
> flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
> page_type: f5(slab)
> raw: 00fff00000000240 ffff88801ac41c80 ffffea00010c8910 ffffea0001fcb310
> raw: ffff8880312a2000 000000000010000d 00000001f5000000 0000000000000000
> head: 00fff00000000240 ffff88801ac41c80 ffffea00010c8910 ffffea0001fcb310
> head: ffff8880312a2000 000000000010000d 00000001f5000000 0000000000000000
> head: 00fff00000000002 ffffea0000c4a801 ffffffffffffffff 0000000000000000
> head: ffff888000000004 0000000000000000 00000000ffffffff 0000000000000000
> page dumped because: kasan: bad access detected
> page_owner tracks the page as allocated
> page last allocated via order 2, migratetype Unmovable, gfp_mask
> 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC),
> pid 5224, tgid 5224 (udevd), ts 31207973672, free_ts 31004401902
> set_page_owner include/linux/page_owner.h:32 [inline]
> post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1537
> prep_new_page mm/page_alloc.c:1545 [inline]
> get_page_from_freelist+0x303f/0x3190 mm/page_alloc.c:3457
> __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4733
> alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
> alloc_slab_page+0x6a/0x120 mm/slub.c:2412
> allocate_slab+0x5a/0x2f0 mm/slub.c:2578
> new_slab mm/slub.c:2631 [inline]
> ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3818
> __slab_alloc+0x58/0xa0 mm/slub.c:3908
> __slab_alloc_node mm/slub.c:3961 [inline]
> slab_alloc_node mm/slub.c:4122 [inline]
> __kmalloc_cache_noprof+0x1d5/0x2c0 mm/slub.c:4290
> kmalloc_noprof include/linux/slab.h:878 [inline]
> kzalloc_noprof include/linux/slab.h:1014 [inline]
> kernfs_fop_open+0x3e0/0xd10 fs/kernfs/file.c:623
> do_dentry_open+0x978/0x1460 fs/open.c:958
> vfs_open+0x3e/0x330 fs/open.c:1088
> do_open fs/namei.c:3774 [inline]
> path_openat+0x2c84/0x3590 fs/namei.c:3933
> do_filp_open+0x235/0x490 fs/namei.c:3960
> do_sys_openat2+0x13e/0x1d0 fs/open.c:1415
> do_sys_open fs/open.c:1430 [inline]
> __do_sys_openat fs/open.c:1446 [inline]
> __se_sys_openat fs/open.c:1441 [inline]
> __x64_sys_openat+0x247/0x2a0 fs/open.c:1441
> page last free pid 16 tgid 16 stack trace:
> reset_page_owner include/linux/page_owner.h:25 [inline]
> free_pages_prepare mm/page_alloc.c:1108 [inline]
> free_unref_page+0xcfb/0xf20 mm/page_alloc.c:2638
> rcu_do_batch kernel/rcu/tree.c:2567 [inline]
> rcu_core+0xaaa/0x17a0 kernel/rcu/tree.c:2823
> handle_softirqs+0x2c5/0x980 kernel/softirq.c:554
> run_ksoftirqd+0xca/0x130 kernel/softirq.c:927
> smpboot_thread_fn+0x544/0xa30 kernel/smpboot.c:164
> kthread+0x2f0/0x390 kernel/kthread.c:389
> ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
>
> Memory state around the buggy address:
> ffff8880312a3780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8880312a3800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> >ffff8880312a3880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ^
> ffff8880312a3900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8880312a3980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ==================================================================
>
>
> ---
> This report is generated by a bot. It may contain errors.
> See https://goo.gl/tpsmEJ for more information about syzbot.
> syzbot engineers can be reached at syzkaller@googlegroups.com.
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
>
> If the report is already addressed, let syzbot know by replying with:
> #syz fix: exact-commit-title
>
> If you want syzbot to run the reproducer, reply with:
> #syz test: git://repo/address.git branch-or-commit-hash
> If you attach or paste a git patch, syzbot will apply it before testing.
>
> If you want to overwrite report's subsystems, reply with:
> #syz set subsystems: new-subsystem
> (See the list of subsystem names on the web dashboard)
>
> If the report is a duplicate of another one, reply with:
> #syz dup: exact-subject-of-another-report
>
> If you want to undo deduplication, reply with:
> #syz undup
>
> --
> You received this message because you are subscribed to the Google Groups
> "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/syzkaller-bugs/672b574b.050a0220.2edce.1523.GAE%40google.com
> .
>
[-- Attachment #1.2: Type: text/html, Size: 12737 bytes --]
[-- Attachment #2: 0001-KASAN-fix-slab-use-after-free-Read-in-sg_release.patch --]
[-- Type: text/x-patch, Size: 768 bytes --]
From 1907dd956515ede00f5c1aa7f90493eaa65cd52a Mon Sep 17 00:00:00 2001
From: Suraj Sonawane <surajsonawane0215@gmail.com>
Date: Fri, 15 Nov 2024 19:03:07 +0530
Subject: [PATCH] KASAN: fix slab-use-after-free Read in sg_release
syz test
Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
---
drivers/scsi/sg.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index f86be197f..630d15620 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -2234,6 +2234,7 @@ sg_remove_sfp_usercontext(struct work_struct *work)
SCSI_LOG_TIMEOUT(6, sg_printk(KERN_INFO, sdp,
"sg_remove_sfp: sfp=0x%p\n", sfp));
kfree(sfp);
+ sfp = NULL;
kref_put(&sdp->d_ref, sg_device_destroy);
scsi_device_put(device);
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release
2024-11-15 13:36 ` Suraj Sonawane
@ 2024-11-15 13:56 ` syzbot
0 siblings, 0 replies; 8+ messages in thread
From: syzbot @ 2024-11-15 13:56 UTC (permalink / raw)
To: dgilbert, james.bottomley, linux-kernel, linux-scsi, linux-usb,
martin.petersen, surajsonawane0215, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in sg_release
==================================================================
BUG: KASAN: slab-use-after-free in sg_release+0x2a4/0x2e0 drivers/scsi/sg.c:397
Read of size 4 at addr ffff88807eec5148 by task syz.0.33/7177
CPU: 1 UID: 0 PID: 7177 Comm: syz.0.33 Not tainted 6.12.0-rc7-syzkaller-00125-gcfaaa7d010d1-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:377 [inline]
print_report+0x169/0x550 mm/kasan/report.c:488
kasan_report+0x143/0x180 mm/kasan/report.c:601
sg_release+0x2a4/0x2e0 drivers/scsi/sg.c:397
__fput+0x23f/0x880 fs/file_table.c:431
task_work_run+0x24f/0x310 kernel/task_work.c:239
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
__syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218
do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f8726b7e719
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd5cfff398 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007f8726d37a80 RCX: 00007f8726b7e719
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 00007f8726d37a80 R08: 0000000000000000 R09: 00007ffd5cfff68f
R10: 000000000003fdc8 R11: 0000000000000246 R12: 000000000001fb17
R13: 00007ffd5cfff4a0 R14: 0000000000000032 R15: ffffffffffffffff
</TASK>
Allocated by task 12:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
__kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:394
kasan_kmalloc include/linux/kasan.h:257 [inline]
__kmalloc_cache_noprof+0x19c/0x2c0 mm/slub.c:4295
kmalloc_noprof include/linux/slab.h:878 [inline]
kzalloc_noprof include/linux/slab.h:1014 [inline]
sg_alloc drivers/scsi/sg.c:1444 [inline]
sg_add_device+0x139/0xb10 drivers/scsi/sg.c:1518
device_add+0xa1f/0xbf0 drivers/base/core.c:3695
scsi_sysfs_add_sdev+0x306/0x5a0 drivers/scsi/scsi_sysfs.c:1435
scsi_sysfs_add_devices drivers/scsi/scsi_scan.c:1896 [inline]
scsi_finish_async_scan drivers/scsi/scsi_scan.c:1981 [inline]
do_scan_async+0x42a/0x7a0 drivers/scsi/scsi_scan.c:2024
async_run_entry_fn+0xa8/0x420 kernel/async.c:129
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f0/0x390 kernel/kthread.c:389
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
Freed by task 3067:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
poison_slab_object mm/kasan/common.c:247 [inline]
__kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:2342 [inline]
slab_free mm/slub.c:4579 [inline]
kfree+0x1a0/0x440 mm/slub.c:4727
kref_put include/linux/kref.h:65 [inline]
sg_remove_sfp_usercontext+0x331/0x4d0 drivers/scsi/sg.c:2239
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f0/0x390 kernel/kthread.c:389
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
The buggy address belongs to the object at ffff88807eec5000
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 328 bytes inside of
freed 512-byte region [ffff88807eec5000, ffff88807eec5200)
The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807eec7800 pfn:0x7eec4
head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000240 ffff88801ac41c80 ffffea0000cae210 ffffea0000cb7810
raw: ffff88807eec7800 000000000010000a 00000001f5000000 0000000000000000
head: 00fff00000000240 ffff88801ac41c80 ffffea0000cae210 ffffea0000cb7810
head: ffff88807eec7800 000000000010000a 00000001f5000000 0000000000000000
head: 00fff00000000002 ffffea0001fbb101 ffffffffffffffff 0000000000000000
head: 0000000000000004 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 6550, tgid 6550 (syz-executor), ts 104531524508, free_ts 104299146915
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1556
prep_new_page mm/page_alloc.c:1564 [inline]
get_page_from_freelist+0x3649/0x3790 mm/page_alloc.c:3474
__alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4750
alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
alloc_slab_page+0x6a/0x140 mm/slub.c:2412
allocate_slab+0x5a/0x2f0 mm/slub.c:2578
new_slab mm/slub.c:2631 [inline]
___slab_alloc+0xcd1/0x14b0 mm/slub.c:3818
__slab_alloc+0x58/0xa0 mm/slub.c:3908
__slab_alloc_node mm/slub.c:3961 [inline]
slab_alloc_node mm/slub.c:4122 [inline]
__do_kmalloc_node mm/slub.c:4263 [inline]
__kmalloc_noprof+0x25a/0x400 mm/slub.c:4276
kmalloc_noprof include/linux/slab.h:882 [inline]
kzalloc_noprof include/linux/slab.h:1014 [inline]
__alloc_workqueue+0x10a/0x1f20 kernel/workqueue.c:5655
alloc_workqueue+0xd6/0x210 kernel/workqueue.c:5758
wg_newlink+0x1a8/0x640 drivers/net/wireguard/device.c:333
rtnl_newlink_create net/core/rtnetlink.c:3539 [inline]
__rtnl_newlink net/core/rtnetlink.c:3759 [inline]
rtnl_newlink+0x1591/0x20a0 net/core/rtnetlink.c:3772
rtnetlink_rcv_msg+0x73f/0xcf0 net/core/rtnetlink.c:6675
netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2536
netlink_unicast_kernel net/netlink/af_netlink.c:1316 [inline]
netlink_unicast+0x7f6/0x990 net/netlink/af_netlink.c:1342
page last free pid 12 tgid 12 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
free_pages_prepare mm/page_alloc.c:1127 [inline]
free_unref_page+0xdf9/0x1140 mm/page_alloc.c:2657
discard_slab mm/slub.c:2677 [inline]
__put_partials+0xeb/0x130 mm/slub.c:3145
put_cpu_partial+0x17c/0x250 mm/slub.c:3220
__slab_free+0x2ea/0x3d0 mm/slub.c:4449
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:329
kasan_slab_alloc include/linux/kasan.h:247 [inline]
slab_post_alloc_hook mm/slub.c:4085 [inline]
slab_alloc_node mm/slub.c:4134 [inline]
__kmalloc_cache_noprof+0x132/0x2c0 mm/slub.c:4290
kmalloc_noprof include/linux/slab.h:878 [inline]
kzalloc_noprof include/linux/slab.h:1014 [inline]
ipv6_add_addr+0x580/0x1090 net/ipv6/addrconf.c:1114
addrconf_add_linklocal+0x36c/0xa30 net/ipv6/addrconf.c:3317
addrconf_addr_gen+0x510/0xbb0
addrconf_dev_config net/ipv6/addrconf.c:3494 [inline]
addrconf_init_auto_addrs+0x96a/0xeb0 net/ipv6/addrconf.c:3572
addrconf_notify+0xaff/0x1020 net/ipv6/addrconf.c:3745
notifier_call_chain+0x19f/0x3e0 kernel/notifier.c:93
netdev_state_change+0x11f/0x1a0 net/core/dev.c:1378
linkwatch_do_dev+0x112/0x170 net/core/link_watch.c:177
Memory state around the buggy address:
ffff88807eec5000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807eec5080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807eec5100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807eec5180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807eec5200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
Tested on:
commit: cfaaa7d0 Merge tag 'net-6.12-rc8' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=118b82e8580000
kernel config: https://syzkaller.appspot.com/x/.config?x=d2aeec8c0b2e420c
dashboard link: https://syzkaller.appspot.com/bug?extid=7efb5850a17ba6ce098b
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=155382e8580000
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release
2024-11-06 11:47 [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release syzbot
2024-11-15 13:36 ` Suraj Sonawane
@ 2024-11-15 18:00 ` Bart Van Assche
2024-11-15 23:46 ` syzbot
2024-11-20 8:19 ` Suraj Sonawane
2 siblings, 1 reply; 8+ messages in thread
From: Bart Van Assche @ 2024-11-15 18:00 UTC (permalink / raw)
To: syzbot, linux-kernel, linux-scsi, linux-usb, syzkaller-bugs
#syz test: https://github.com/bvanassche/linux.git scsi-for-next
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release
2024-11-15 18:00 ` Bart Van Assche
@ 2024-11-15 23:46 ` syzbot
2024-11-18 19:27 ` Bart Van Assche
0 siblings, 1 reply; 8+ messages in thread
From: syzbot @ 2024-11-15 23:46 UTC (permalink / raw)
To: bvanassche, linux-kernel, linux-scsi, linux-usb, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in sg_release
==================================================================
BUG: KASAN: slab-use-after-free in sg_device_destroy+0x57/0x180 drivers/scsi/sg.c:1572
Read of size 8 at addr ffff888034a06008 by task syz.3.47/7437
CPU: 1 UID: 0 PID: 7437 Comm: syz.3.47 Not tainted 6.12.0-rc1-syzkaller-00116-g9024d215a5d3 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:377 [inline]
print_report+0x169/0x550 mm/kasan/report.c:488
kasan_report+0x143/0x180 mm/kasan/report.c:601
sg_device_destroy+0x57/0x180 drivers/scsi/sg.c:1572
kref_put include/linux/kref.h:65 [inline]
sg_release+0x274/0x3c0 drivers/scsi/sg.c:404
__fput+0x23f/0x880 fs/file_table.c:431
task_work_run+0x24f/0x310 kernel/task_work.c:228
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
__syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218
do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f301d17e719
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe38eabda8 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007f301d337a80 RCX: 00007f301d17e719
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 00007f301d337a80 R08: 0000000000000000 R09: 00007ffe38eac09f
R10: 000000000003fdc8 R11: 0000000000000246 R12: 000000000002126f
R13: 00007ffe38eabeb0 R14: 0000000000000032 R15: ffffffffffffffff
</TASK>
Allocated by task 1128:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
__kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:394
kasan_kmalloc include/linux/kasan.h:257 [inline]
__do_kmalloc_node mm/slub.c:4265 [inline]
__kmalloc_noprof+0x1fc/0x400 mm/slub.c:4277
kmalloc_noprof include/linux/slab.h:882 [inline]
kzalloc_noprof include/linux/slab.h:1014 [inline]
scsi_alloc_sdev+0x180/0xb90 drivers/scsi/scsi_scan.c:288
scsi_probe_and_add_lun+0x1db/0x4be0 drivers/scsi/scsi_scan.c:1210
__scsi_scan_target+0x205/0x1080 drivers/scsi/scsi_scan.c:1757
scsi_scan_channel drivers/scsi/scsi_scan.c:1845 [inline]
scsi_scan_host_selected+0x37e/0x690 drivers/scsi/scsi_scan.c:1874
do_scsi_scan_host drivers/scsi/scsi_scan.c:2013 [inline]
do_scan_async+0x138/0x7a0 drivers/scsi/scsi_scan.c:2023
async_run_entry_fn+0xa8/0x420 kernel/async.c:129
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f0/0x390 kernel/kthread.c:389
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
Freed by task 6911:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
poison_slab_object mm/kasan/common.c:247 [inline]
__kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:2343 [inline]
slab_free mm/slub.c:4580 [inline]
kfree+0x1a0/0x440 mm/slub.c:4728
scsi_device_dev_release+0xbfb/0xf40 drivers/scsi/scsi_sysfs.c:519
device_release+0x99/0x1c0
kobject_cleanup lib/kobject.c:689 [inline]
kobject_release lib/kobject.c:720 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x22f/0x480 lib/kobject.c:737
scsi_device_put+0x7e/0x90 drivers/scsi/scsi.c:792
sg_remove_sfp_usercontext+0x354/0x4d0 drivers/scsi/sg.c:2237
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f0/0x390 kernel/kthread.c:389
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
The buggy address belongs to the object at ffff888034a06000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 8 bytes inside of
freed 4096-byte region [ffff888034a06000, ffff888034a07000)
The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x34a00
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88801ac42140 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000040004 00000001f5000000 0000000000000000
head: 00fff00000000040 ffff88801ac42140 dead000000000122 0000000000000000
head: 0000000000000000 0000000000040004 00000001f5000000 0000000000000000
head: 00fff00000000003 ffffea0000d28001 ffffffffffffffff 0000000000000000
head: ffff888000000008 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 6939, tgid 6939 (kworker/1:8), ts 132642795076, free_ts 132531180778
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1537
prep_new_page mm/page_alloc.c:1545 [inline]
get_page_from_freelist+0x3045/0x3190 mm/page_alloc.c:3457
__alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4733
alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
alloc_slab_page+0x6a/0x120 mm/slub.c:2413
allocate_slab+0x5a/0x2f0 mm/slub.c:2579
new_slab mm/slub.c:2632 [inline]
___slab_alloc+0xcd1/0x14b0 mm/slub.c:3819
__slab_alloc+0x58/0xa0 mm/slub.c:3909
__slab_alloc_node mm/slub.c:3962 [inline]
slab_alloc_node mm/slub.c:4123 [inline]
__do_kmalloc_node mm/slub.c:4264 [inline]
__kmalloc_node_track_caller_noprof+0x281/0x440 mm/slub.c:4284
kmalloc_reserve+0x111/0x2a0 net/core/skbuff.c:609
__alloc_skb+0x1f3/0x440 net/core/skbuff.c:678
alloc_skb include/linux/skbuff.h:1322 [inline]
nsim_dev_trap_skb_build drivers/net/netdevsim/dev.c:748 [inline]
nsim_dev_trap_report drivers/net/netdevsim/dev.c:805 [inline]
nsim_dev_trap_report_work+0x254/0xaa0 drivers/net/netdevsim/dev.c:850
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f0/0x390 kernel/kthread.c:389
ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
page last free pid 7491 tgid 7491 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
free_pages_prepare mm/page_alloc.c:1108 [inline]
free_unref_page+0xcfb/0xf20 mm/page_alloc.c:2638
discard_slab mm/slub.c:2678 [inline]
__put_partials+0xeb/0x130 mm/slub.c:3146
put_cpu_partial+0x17c/0x250 mm/slub.c:3221
__slab_free+0x2ea/0x3d0 mm/slub.c:4450
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:329
kasan_slab_alloc include/linux/kasan.h:247 [inline]
slab_post_alloc_hook mm/slub.c:4086 [inline]
slab_alloc_node mm/slub.c:4135 [inline]
kmem_cache_alloc_noprof+0x135/0x2a0 mm/slub.c:4142
alloc_empty_file+0x9e/0x1d0 fs/file_table.c:209
path_openat+0x107/0x3590 fs/namei.c:3919
do_filp_open+0x235/0x490 fs/namei.c:3960
do_open_execat fs/exec.c:901 [inline]
alloc_bprm+0x178/0xe20 fs/exec.c:1509
do_execveat_common+0x18c/0x6f0 fs/exec.c:1903
do_execve fs/exec.c:2026 [inline]
__do_sys_execve fs/exec.c:2102 [inline]
__se_sys_execve fs/exec.c:2097 [inline]
__x64_sys_execve+0x92/0xb0 fs/exec.c:2097
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Memory state around the buggy address:
ffff888034a05f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888034a05f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888034a06000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888034a06080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888034a06100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: 9024d215 sg: Fix a use-after-free in sg_release()
git tree: https://github.com/bvanassche/linux.git scsi-for-next
console output: https://syzkaller.appspot.com/x/log.txt?x=16a8d130580000
kernel config: https://syzkaller.appspot.com/x/.config?x=a4f1b8d0c0075849
dashboard link: https://syzkaller.appspot.com/bug?extid=7efb5850a17ba6ce098b
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
Note: no patches were applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release
2024-11-15 23:46 ` syzbot
@ 2024-11-18 19:27 ` Bart Van Assche
0 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2024-11-18 19:27 UTC (permalink / raw)
To: linux-kernel, linux-scsi, linux-usb
On 11/15/24 3:46 PM, syzbot wrote:
> Hello,
>
> syzbot has tested the proposed patch but the reproducer is still triggering an issue:
> KASAN: slab-use-after-free Read in sg_release
>
> ==================================================================
> BUG: KASAN: slab-use-after-free in sg_device_destroy+0x57/0x180 drivers/scsi/sg.c:1572
> Read of size 8 at addr ffff888034a06008 by task syz.3.47/7437
>
> CPU: 1 UID: 0 PID: 7437 Comm: syz.3.47 Not tainted 6.12.0-rc1-syzkaller-00116-g9024d215a5d3 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
> Call Trace:
> <TASK>
> __dump_stack lib/dump_stack.c:94 [inline]
> dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
> print_address_description mm/kasan/report.c:377 [inline]
> print_report+0x169/0x550 mm/kasan/report.c:488
> kasan_report+0x143/0x180 mm/kasan/report.c:601
> sg_device_destroy+0x57/0x180 drivers/scsi/sg.c:1572
> kref_put include/linux/kref.h:65 [inline]
> sg_release+0x274/0x3c0 drivers/scsi/sg.c:404
> __fput+0x23f/0x880 fs/file_table.c:431
> task_work_run+0x24f/0x310 kernel/task_work.c:228
> resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
> exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
> exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
> __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
> syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218
> do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
The above output shows that the tested patch postponed the use-after-
free from the mutex_unlock() call in sg_release to the code that I
inserted after that call. This is the patch that has been tested:
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 84334ab39c81..6c6e03f37b5f 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -385,6 +385,8 @@ sg_release(struct inode *inode, struct file *filp)
return -ENXIO;
SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp, "sg_release\n"));
+ kref_get(&sdp->d_ref);
+
mutex_lock(&sdp->open_rel_lock);
kref_put(&sfp->f_ref, sg_remove_sfp);
sdp->open_cnt--;
@@ -398,6 +400,9 @@ sg_release(struct inode *inode, struct file *filp)
wake_up_interruptible(&sdp->open_wait);
}
mutex_unlock(&sdp->open_rel_lock);
+
+ kref_put(&sdp->d_ref, sg_device_destroy);
+
return 0;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release
2024-11-06 11:47 [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release syzbot
2024-11-15 13:36 ` Suraj Sonawane
2024-11-15 18:00 ` Bart Van Assche
@ 2024-11-20 8:19 ` Suraj Sonawane
2024-11-20 9:05 ` syzbot
2 siblings, 1 reply; 8+ messages in thread
From: Suraj Sonawane @ 2024-11-20 8:19 UTC (permalink / raw)
To: syzbot
Cc: James.Bottomley, dgilbert, linux-kernel, linux-scsi, linux-usb,
martin.petersen, syzkaller-bugs
[-- Attachment #1.1: Type: text/plain, Size: 10564 bytes --]
#syz test
On Wed, Nov 6, 2024 at 5:17 PM syzbot <
syzbot+7efb5850a17ba6ce098b@syzkaller.appspotmail.com> wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 11066801dd4b Merge tag 'linux_kselftest-fixes-6.12-rc6'
> of..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=16146aa7980000
> kernel config: https://syzkaller.appspot.com/x/.config?x=672325e7ab17fdf7
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=7efb5850a17ba6ce098b
> compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for
> Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14e8755f980000
>
> Downloadable assets:
> disk image:
> https://storage.googleapis.com/syzbot-assets/d5100fe708c2/disk-11066801.raw.xz
> vmlinux:
> https://storage.googleapis.com/syzbot-assets/581317b0fef2/vmlinux-11066801.xz
> kernel image:
> https://storage.googleapis.com/syzbot-assets/c7571fdba64f/bzImage-11066801.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the
> commit:
> Reported-by: syzbot+7efb5850a17ba6ce098b@syzkaller.appspotmail.com
>
> ==================================================================
> BUG: KASAN: slab-use-after-free in lock_release+0x151/0xa30
> kernel/locking/lockdep.c:5838
> Read of size 8 at addr ffff8880312a38c0 by task syz.2.335/8457
>
> CPU: 1 UID: 0 PID: 8457 Comm: syz.2.335 Not tainted
> 6.12.0-rc5-syzkaller-00299-g11066801dd4b #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 09/13/2024
> Call Trace:
> <TASK>
> __dump_stack lib/dump_stack.c:94 [inline]
> dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
> print_address_description mm/kasan/report.c:377 [inline]
> print_report+0x169/0x550 mm/kasan/report.c:488
> kasan_report+0x143/0x180 mm/kasan/report.c:601
> lock_release+0x151/0xa30 kernel/locking/lockdep.c:5838
> __mutex_unlock_slowpath+0xe2/0x750 kernel/locking/mutex.c:912
> sg_release+0x1f4/0x2e0 drivers/scsi/sg.c:407
> __fput+0x23f/0x880 fs/file_table.c:431
> task_work_run+0x24f/0x310 kernel/task_work.c:239
> resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
> exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
> exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
> __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
> syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218
> do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
> RIP: 0033:0x7f312af7e719
> Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7
> 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
> ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
> RSP: 002b:00007ffdb5d17628 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
> RAX: 0000000000000000 RBX: 00007f312b137a80 RCX: 00007f312af7e719
> RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
> RBP: 00007f312b137a80 R08: 0000000000000000 R09: 00007ffdb5d1791f
> R10: 000000000003fdc8 R11: 0000000000000246 R12: 000000000005f4a4
> R13: 00007ffdb5d17730 R14: 0000000000000032 R15: ffffffffffffffff
> </TASK>
>
> Allocated by task 7133:
> kasan_save_stack mm/kasan/common.c:47 [inline]
> kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
> poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
> __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:394
> kasan_kmalloc include/linux/kasan.h:257 [inline]
> __kmalloc_cache_noprof+0x19c/0x2c0 mm/slub.c:4295
> kmalloc_noprof include/linux/slab.h:878 [inline]
> kzalloc_noprof include/linux/slab.h:1014 [inline]
> sg_alloc drivers/scsi/sg.c:1444 [inline]
> sg_add_device+0x139/0xb10 drivers/scsi/sg.c:1518
> device_add+0xa1f/0xbf0 drivers/base/core.c:3698
> scsi_sysfs_add_sdev+0x306/0x5a0 drivers/scsi/scsi_sysfs.c:1435
> scsi_sysfs_add_devices drivers/scsi/scsi_scan.c:1896 [inline]
> scsi_finish_async_scan drivers/scsi/scsi_scan.c:1981 [inline]
> do_scan_async+0x42a/0x7a0 drivers/scsi/scsi_scan.c:2024
> async_run_entry_fn+0xa8/0x420 kernel/async.c:129
> process_one_work kernel/workqueue.c:3229 [inline]
> process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
> worker_thread+0x870/0xd30 kernel/workqueue.c:3391
> kthread+0x2f0/0x390 kernel/kthread.c:389
> ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
>
> Freed by task 6000:
> kasan_save_stack mm/kasan/common.c:47 [inline]
> kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
> kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
> poison_slab_object mm/kasan/common.c:247 [inline]
> __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
> kasan_slab_free include/linux/kasan.h:230 [inline]
> slab_free_hook mm/slub.c:2342 [inline]
> slab_free mm/slub.c:4579 [inline]
> kfree+0x1a0/0x440 mm/slub.c:4727
> kref_put include/linux/kref.h:65 [inline]
> sg_remove_sfp_usercontext+0x331/0x4d0 drivers/scsi/sg.c:2238
> process_one_work kernel/workqueue.c:3229 [inline]
> process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
> worker_thread+0x870/0xd30 kernel/workqueue.c:3391
> kthread+0x2f0/0x390 kernel/kthread.c:389
> ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
>
> The buggy address belongs to the object at ffff8880312a3800
> which belongs to the cache kmalloc-512 of size 512
> The buggy address is located 192 bytes inside of
> freed 512-byte region [ffff8880312a3800, ffff8880312a3a00)
>
> The buggy address belongs to the physical page:
> page: refcount:1 mapcount:0 mapping:0000000000000000
> index:0xffff8880312a2000 pfn:0x312a0
> head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
> flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
> page_type: f5(slab)
> raw: 00fff00000000240 ffff88801ac41c80 ffffea00010c8910 ffffea0001fcb310
> raw: ffff8880312a2000 000000000010000d 00000001f5000000 0000000000000000
> head: 00fff00000000240 ffff88801ac41c80 ffffea00010c8910 ffffea0001fcb310
> head: ffff8880312a2000 000000000010000d 00000001f5000000 0000000000000000
> head: 00fff00000000002 ffffea0000c4a801 ffffffffffffffff 0000000000000000
> head: ffff888000000004 0000000000000000 00000000ffffffff 0000000000000000
> page dumped because: kasan: bad access detected
> page_owner tracks the page as allocated
> page last allocated via order 2, migratetype Unmovable, gfp_mask
> 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC),
> pid 5224, tgid 5224 (udevd), ts 31207973672, free_ts 31004401902
> set_page_owner include/linux/page_owner.h:32 [inline]
> post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1537
> prep_new_page mm/page_alloc.c:1545 [inline]
> get_page_from_freelist+0x303f/0x3190 mm/page_alloc.c:3457
> __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4733
> alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
> alloc_slab_page+0x6a/0x120 mm/slub.c:2412
> allocate_slab+0x5a/0x2f0 mm/slub.c:2578
> new_slab mm/slub.c:2631 [inline]
> ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3818
> __slab_alloc+0x58/0xa0 mm/slub.c:3908
> __slab_alloc_node mm/slub.c:3961 [inline]
> slab_alloc_node mm/slub.c:4122 [inline]
> __kmalloc_cache_noprof+0x1d5/0x2c0 mm/slub.c:4290
> kmalloc_noprof include/linux/slab.h:878 [inline]
> kzalloc_noprof include/linux/slab.h:1014 [inline]
> kernfs_fop_open+0x3e0/0xd10 fs/kernfs/file.c:623
> do_dentry_open+0x978/0x1460 fs/open.c:958
> vfs_open+0x3e/0x330 fs/open.c:1088
> do_open fs/namei.c:3774 [inline]
> path_openat+0x2c84/0x3590 fs/namei.c:3933
> do_filp_open+0x235/0x490 fs/namei.c:3960
> do_sys_openat2+0x13e/0x1d0 fs/open.c:1415
> do_sys_open fs/open.c:1430 [inline]
> __do_sys_openat fs/open.c:1446 [inline]
> __se_sys_openat fs/open.c:1441 [inline]
> __x64_sys_openat+0x247/0x2a0 fs/open.c:1441
> page last free pid 16 tgid 16 stack trace:
> reset_page_owner include/linux/page_owner.h:25 [inline]
> free_pages_prepare mm/page_alloc.c:1108 [inline]
> free_unref_page+0xcfb/0xf20 mm/page_alloc.c:2638
> rcu_do_batch kernel/rcu/tree.c:2567 [inline]
> rcu_core+0xaaa/0x17a0 kernel/rcu/tree.c:2823
> handle_softirqs+0x2c5/0x980 kernel/softirq.c:554
> run_ksoftirqd+0xca/0x130 kernel/softirq.c:927
> smpboot_thread_fn+0x544/0xa30 kernel/smpboot.c:164
> kthread+0x2f0/0x390 kernel/kthread.c:389
> ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
>
> Memory state around the buggy address:
> ffff8880312a3780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8880312a3800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> >ffff8880312a3880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ^
> ffff8880312a3900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8880312a3980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ==================================================================
>
>
> ---
> This report is generated by a bot. It may contain errors.
> See https://goo.gl/tpsmEJ for more information about syzbot.
> syzbot engineers can be reached at syzkaller@googlegroups.com.
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
>
> If the report is already addressed, let syzbot know by replying with:
> #syz fix: exact-commit-title
>
> If you want syzbot to run the reproducer, reply with:
> #syz test: git://repo/address.git branch-or-commit-hash
> If you attach or paste a git patch, syzbot will apply it before testing.
>
> If you want to overwrite report's subsystems, reply with:
> #syz set subsystems: new-subsystem
> (See the list of subsystem names on the web dashboard)
>
> If the report is a duplicate of another one, reply with:
> #syz dup: exact-subject-of-another-report
>
> If you want to undo deduplication, reply with:
> #syz undup
>
> --
> You received this message because you are subscribed to the Google Groups
> "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/syzkaller-bugs/672b574b.050a0220.2edce.1523.GAE%40google.com
> .
>
[-- Attachment #1.2: Type: text/html, Size: 12737 bytes --]
[-- Attachment #2: 0001-fix-slab-use-after-free-Read-in-sg_release.patch --]
[-- Type: text/x-patch, Size: 1001 bytes --]
From f69af151a3aa3f700cac40241b5a3ed23efe66ff Mon Sep 17 00:00:00 2001
From: Suraj Sonawane <surajsonawane0215@gmail.com>
Date: Wed, 20 Nov 2024 13:47:05 +0530
Subject: [PATCH] fix slab-use-after-free Read in sg_release
syz test
Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
---
drivers/scsi/sg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index f86be197f..457d54171 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -393,7 +393,6 @@ sg_release(struct inode *inode, struct file *filp)
mutex_lock(&sdp->open_rel_lock);
scsi_autopm_put_device(sdp->device);
- kref_put(&sfp->f_ref, sg_remove_sfp);
sdp->open_cnt--;
/* possibly many open()s waiting on exlude clearing, start many;
@@ -405,6 +404,7 @@ sg_release(struct inode *inode, struct file *filp)
wake_up_interruptible(&sdp->open_wait);
}
mutex_unlock(&sdp->open_rel_lock);
+ kref_put(&sfp->f_ref, sg_remove_sfp);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release
2024-11-20 8:19 ` Suraj Sonawane
@ 2024-11-20 9:05 ` syzbot
0 siblings, 0 replies; 8+ messages in thread
From: syzbot @ 2024-11-20 9:05 UTC (permalink / raw)
To: dgilbert, james.bottomley, linux-kernel, linux-scsi, linux-usb,
martin.petersen, surajsonawane0215, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+7efb5850a17ba6ce098b@syzkaller.appspotmail.com
Tested-by: syzbot+7efb5850a17ba6ce098b@syzkaller.appspotmail.com
Tested on:
commit: bf9aa14f Merge tag 'timers-core-2024-11-18' of git://g..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11373bf7980000
kernel config: https://syzkaller.appspot.com/x/.config?x=48190c1cdf985419
dashboard link: https://syzkaller.appspot.com/bug?extid=7efb5850a17ba6ce098b
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=106b3bf7980000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-11-20 9:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-06 11:47 [syzbot] [scsi?] [usb?] KASAN: slab-use-after-free Read in sg_release syzbot
2024-11-15 13:36 ` Suraj Sonawane
2024-11-15 13:56 ` syzbot
2024-11-15 18:00 ` Bart Van Assche
2024-11-15 23:46 ` syzbot
2024-11-18 19:27 ` Bart Van Assche
2024-11-20 8:19 ` Suraj Sonawane
2024-11-20 9:05 ` syzbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).