Re: KASAN: use-after-free Read in worker_thread (2)
On Sat, Nov 11, 2017 at 07:56:01AM -0800, syzbot wrote: > syzkaller has found reproducer for the following crash on > d9e0e63d9a6f88440eb201e1491fcf730272c706 > git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/master > compiler: gcc (GCC) 7.1.1 20170620 > .config is attached > Raw console output is attached. > > syzkaller reproducer is attached. See https://goo.gl/kgGztJ > for information about syzkaller reproducers > > > BUG: KASAN: use-after-free in worker_thread+0x15bb/0x1990 > kernel/workqueue.c:2244 > Read of size 8 at addr 88002d0e3de0 by task kworker/u8:1/1209 > > CPU: 0 PID: 1209 Comm: kworker/u8:1 Not tainted 4.14.0-rc8-next-20171110+ > #12 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 > Call Trace: > __dump_stack lib/dump_stack.c:17 [inline] > dump_stack+0x194/0x257 lib/dump_stack.c:53 > print_address_description+0x73/0x250 mm/kasan/report.c:252 > kasan_report_error mm/kasan/report.c:351 [inline] > kasan_report+0x25b/0x340 mm/kasan/report.c:409 > __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430 > worker_thread+0x15bb/0x1990 kernel/workqueue.c:2244 > kthread+0x37a/0x440 kernel/kthread.c:238 > ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:437 > > Allocated by task 11866: > save_stack+0x43/0xd0 mm/kasan/kasan.c:447 > set_track mm/kasan/kasan.c:459 [inline] > kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551 > kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489 > kmem_cache_alloc+0x12e/0x760 mm/slab.c:3548 > kmem_cache_zalloc include/linux/slab.h:693 [inline] > kcm_attach net/kcm/kcmsock.c:1394 [inline] > kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline] > kcm_ioctl+0x2d1/0x1610 net/kcm/kcmsock.c:1695 > sock_do_ioctl+0x65/0xb0 net/socket.c:960 > sock_ioctl+0x2c2/0x440 net/socket.c:1057 > vfs_ioctl fs/ioctl.c:46 [inline] > do_vfs_ioctl+0x1b1/0x1530 fs/ioctl.c:686 > SYSC_ioctl fs/ioctl.c:701 [inline] > SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692 > entry_SYSCALL_64_fastpath+0x1f/0x96 > > Freed by task 11867: > save_stack+0x43/0xd0 mm/kasan/kasan.c:447 > set_track mm/kasan/kasan.c:459 [inline] > kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524 > __cache_free mm/slab.c:3492 [inline] > kmem_cache_free+0x77/0x280 mm/slab.c:3750 > kcm_unattach+0xe50/0x1510 net/kcm/kcmsock.c:1563 > kcm_unattach_ioctl net/kcm/kcmsock.c:1608 [inline] > kcm_ioctl+0xdf0/0x1610 net/kcm/kcmsock.c:1705 > sock_do_ioctl+0x65/0xb0 net/socket.c:960 > sock_ioctl+0x2c2/0x440 net/socket.c:1057 > vfs_ioctl fs/ioctl.c:46 [inline] > do_vfs_ioctl+0x1b1/0x1530 fs/ioctl.c:686 > SYSC_ioctl fs/ioctl.c:701 [inline] > SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692 > entry_SYSCALL_64_fastpath+0x1f/0x96 > > The buggy address belongs to the object at 88002d0e3d00 > which belongs to the cache kcm_psock_cache of size 576 > The buggy address is located 224 bytes inside of > 576-byte region [88002d0e3d00, 88002d0e3f40) > The buggy address belongs to the page: > page:eab43880 count:1 mapcount:0 mapping:88002d0e2180 index:0x0 > compound_mapcount: 0 > flags: 0x1008100(slab|head) > raw: 01008100 88002d0e2180 0001000b > raw: eab14920 eab27e20 88002b0089c0 > page dumped because: kasan: bad access detected > > Memory state around the buggy address: > 88002d0e3c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > 88002d0e3d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > 88002d0e3d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >^ > 88002d0e3e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > 88002d0e3e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > == No longer occurring, the fix seems to have been commit 7e9964574ee97: #syz fix: kcm: Only allow TCP sockets to be attached to a KCM mux - Eric
Re: KASAN: use-after-free Read in worker_thread (2)
On Fri, Nov 10, 2017 at 7:49 PM, Cong Wangwrote: > On Wed, Nov 8, 2017 at 5:00 AM, Dmitry Vyukov wrote: >> On Wed, Nov 8, 2017 at 1:58 PM, syzbot >> >> wrote: >>> Hello, >>> >>> syzkaller hit the following crash on >>> 7dfaa7bc99498da1c6c4a48bee8d2d5265161a8c >>> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master >>> compiler: gcc (GCC) 7.1.1 20170620 >>> .config is attached >>> Raw console output is attached. >>> >>> Unfortunately, I don't have any reproducer for this bug yet. >>> >> >> >> I guess this is more about kcmsock.c rather than workqueue.c. +kcm >> maintainers. > > > Looks like the work is not cancelled before being freed on this path. > Do you have a C reproducer for me to try? This is answered in the email text and the referenced link. If the wording is not clear, we should improve it. >>> == >>> BUG: KASAN: use-after-free in worker_thread+0x15bb/0x1990 >>> kernel/workqueue.c:2245 >>> Read of size 8 at addr 8801c3a74110 by task kworker/u4:6/3515 >>> >>> CPU: 1 PID: 3515 Comm: kworker/u4:6 Not tainted 4.14.0-rc7+ #112 >>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS >>> Google 01/01/2011 >>> Call Trace: >>> __dump_stack lib/dump_stack.c:17 [inline] >>> dump_stack+0x194/0x257 lib/dump_stack.c:53 >>> print_address_description+0x73/0x250 mm/kasan/report.c:252 >>> kasan_report_error mm/kasan/report.c:351 [inline] >>> kasan_report+0x25b/0x340 mm/kasan/report.c:409 >>> __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430 >>> worker_thread+0x15bb/0x1990 kernel/workqueue.c:2245 >>> kthread+0x35e/0x430 kernel/kthread.c:231 >>> ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:432 >>> >>> Allocated by task 31482: >>> save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 >>> save_stack+0x43/0xd0 mm/kasan/kasan.c:447 >>> set_track mm/kasan/kasan.c:459 [inline] >>> kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551 >>> kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489 >>> kmem_cache_alloc+0x12e/0x760 mm/slab.c:3562 >>> kmem_cache_zalloc include/linux/slab.h:657 [inline] >>> kcm_attach net/kcm/kcmsock.c:1394 [inline] >>> kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline] >>> kcm_ioctl+0x2d1/0x1610 net/kcm/kcmsock.c:1695 >>> sock_do_ioctl+0x65/0xb0 net/socket.c:961 >>> sock_ioctl+0x2c2/0x440 net/socket.c:1058 >>> vfs_ioctl fs/ioctl.c:46 [inline] >>> do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686 >>> SYSC_ioctl fs/ioctl.c:701 [inline] >>> SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692 >>> entry_SYSCALL_64_fastpath+0x1f/0xbe >>> >>> Freed by task 1249: >>> save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 >>> save_stack+0x43/0xd0 mm/kasan/kasan.c:447 >>> set_track mm/kasan/kasan.c:459 [inline] >>> kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524 >>> __cache_free mm/slab.c:3504 [inline] >>> kmem_cache_free+0x77/0x280 mm/slab.c:3764 >>> unreserve_psock+0x5a1/0x780 net/kcm/kcmsock.c:547 >>> kcm_write_msgs+0xbae/0x1b80 net/kcm/kcmsock.c:590 >>> kcm_tx_work+0x2e/0x190 net/kcm/kcmsock.c:731 >>> process_one_work+0xbf0/0x1bc0 kernel/workqueue.c:2113 >>> worker_thread+0x223/0x1990 kernel/workqueue.c:2247 >>> kthread+0x35e/0x430 kernel/kthread.c:231 >>> ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:432 >>> >>> The buggy address belongs to the object at 8801c3a74040 >>> which belongs to the cache kcm_psock_cache of size 552 >>> The buggy address is located 208 bytes inside of >>> 552-byte region [8801c3a74040, 8801c3a74268) >>> The buggy address belongs to the page: >>> page:ea00070e9d00 count:1 mapcount:0 mapping:8801c3a74040 index:0x0 >>> compound_mapcount: 0 >>> flags: 0x2fffc008100(slab|head) >>> raw: 02fffc008100 8801c3a74040 0001000b >>> raw: ea00067920a0 8801d3f39948 8801d3f2a840 >>> page dumped because: kasan: bad access detected >>> >>> Memory state around the buggy address: >>> 8801c3a74000: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb >>> 8801c3a74080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb 8801c3a74100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >>> >>> ^ >>> 8801c3a74180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >>> 8801c3a74200: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc >>> == >>> >>> >>> --- >>> This bug is generated by a dumb bot. It may contain errors. >>> See https://goo.gl/tpsmEJ for details. >>> Direct all questions to syzkal...@googlegroups.com. >>> Please credit me with: Reported-by: syzbot >>> >>> syzbot will keep track of this bug report. >>> Once a fix for this bug is committed, please reply to this email with: >>> #syz fix: exact-commit-title >>> To mark this
Re: KASAN: use-after-free Read in worker_thread (2)
On Wed, Nov 8, 2017 at 5:00 AM, Dmitry Vyukovwrote: > On Wed, Nov 8, 2017 at 1:58 PM, syzbot > > wrote: >> Hello, >> >> syzkaller hit the following crash on >> 7dfaa7bc99498da1c6c4a48bee8d2d5265161a8c >> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master >> compiler: gcc (GCC) 7.1.1 20170620 >> .config is attached >> Raw console output is attached. >> >> Unfortunately, I don't have any reproducer for this bug yet. >> > > > I guess this is more about kcmsock.c rather than workqueue.c. +kcm > maintainers. Looks like the work is not cancelled before being freed on this path. Do you have a C reproducer for me to try? > > >> == >> BUG: KASAN: use-after-free in worker_thread+0x15bb/0x1990 >> kernel/workqueue.c:2245 >> Read of size 8 at addr 8801c3a74110 by task kworker/u4:6/3515 >> >> CPU: 1 PID: 3515 Comm: kworker/u4:6 Not tainted 4.14.0-rc7+ #112 >> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS >> Google 01/01/2011 >> Call Trace: >> __dump_stack lib/dump_stack.c:17 [inline] >> dump_stack+0x194/0x257 lib/dump_stack.c:53 >> print_address_description+0x73/0x250 mm/kasan/report.c:252 >> kasan_report_error mm/kasan/report.c:351 [inline] >> kasan_report+0x25b/0x340 mm/kasan/report.c:409 >> __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430 >> worker_thread+0x15bb/0x1990 kernel/workqueue.c:2245 >> kthread+0x35e/0x430 kernel/kthread.c:231 >> ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:432 >> >> Allocated by task 31482: >> save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 >> save_stack+0x43/0xd0 mm/kasan/kasan.c:447 >> set_track mm/kasan/kasan.c:459 [inline] >> kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551 >> kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489 >> kmem_cache_alloc+0x12e/0x760 mm/slab.c:3562 >> kmem_cache_zalloc include/linux/slab.h:657 [inline] >> kcm_attach net/kcm/kcmsock.c:1394 [inline] >> kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline] >> kcm_ioctl+0x2d1/0x1610 net/kcm/kcmsock.c:1695 >> sock_do_ioctl+0x65/0xb0 net/socket.c:961 >> sock_ioctl+0x2c2/0x440 net/socket.c:1058 >> vfs_ioctl fs/ioctl.c:46 [inline] >> do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686 >> SYSC_ioctl fs/ioctl.c:701 [inline] >> SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692 >> entry_SYSCALL_64_fastpath+0x1f/0xbe >> >> Freed by task 1249: >> save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 >> save_stack+0x43/0xd0 mm/kasan/kasan.c:447 >> set_track mm/kasan/kasan.c:459 [inline] >> kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524 >> __cache_free mm/slab.c:3504 [inline] >> kmem_cache_free+0x77/0x280 mm/slab.c:3764 >> unreserve_psock+0x5a1/0x780 net/kcm/kcmsock.c:547 >> kcm_write_msgs+0xbae/0x1b80 net/kcm/kcmsock.c:590 >> kcm_tx_work+0x2e/0x190 net/kcm/kcmsock.c:731 >> process_one_work+0xbf0/0x1bc0 kernel/workqueue.c:2113 >> worker_thread+0x223/0x1990 kernel/workqueue.c:2247 >> kthread+0x35e/0x430 kernel/kthread.c:231 >> ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:432 >> >> The buggy address belongs to the object at 8801c3a74040 >> which belongs to the cache kcm_psock_cache of size 552 >> The buggy address is located 208 bytes inside of >> 552-byte region [8801c3a74040, 8801c3a74268) >> The buggy address belongs to the page: >> page:ea00070e9d00 count:1 mapcount:0 mapping:8801c3a74040 index:0x0 >> compound_mapcount: 0 >> flags: 0x2fffc008100(slab|head) >> raw: 02fffc008100 8801c3a74040 0001000b >> raw: ea00067920a0 8801d3f39948 8801d3f2a840 >> page dumped because: kasan: bad access detected >> >> Memory state around the buggy address: >> 8801c3a74000: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb >> 8801c3a74080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >>> >>> 8801c3a74100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >> >> ^ >> 8801c3a74180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >> 8801c3a74200: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc >> == >> >> >> --- >> This bug is generated by a dumb bot. It may contain errors. >> See https://goo.gl/tpsmEJ for details. >> Direct all questions to syzkal...@googlegroups.com. >> Please credit me with: Reported-by: syzbot >> >> syzbot will keep track of this bug report. >> Once a fix for this bug is committed, please reply to this email with: >> #syz fix: exact-commit-title >> To mark this as a duplicate of another syzbot report, please reply with: >> #syz dup: exact-subject-of-another-report >> If it's a one-off invalid bug report, please reply with: >> #syz invalid >> Note: if the crash happens again, it will cause creation of a new bug >> report. >> Note: all commands must start
Re: KASAN: use-after-free Read in worker_thread (2)
On Wed, Nov 8, 2017 at 1:58 PM, syzbotwrote: > Hello, > > syzkaller hit the following crash on > 7dfaa7bc99498da1c6c4a48bee8d2d5265161a8c > git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master > compiler: gcc (GCC) 7.1.1 20170620 > .config is attached > Raw console output is attached. > > Unfortunately, I don't have any reproducer for this bug yet. > I guess this is more about kcmsock.c rather than workqueue.c. +kcm maintainers. > == > BUG: KASAN: use-after-free in worker_thread+0x15bb/0x1990 > kernel/workqueue.c:2245 > Read of size 8 at addr 8801c3a74110 by task kworker/u4:6/3515 > > CPU: 1 PID: 3515 Comm: kworker/u4:6 Not tainted 4.14.0-rc7+ #112 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > Google 01/01/2011 > Call Trace: > __dump_stack lib/dump_stack.c:17 [inline] > dump_stack+0x194/0x257 lib/dump_stack.c:53 > print_address_description+0x73/0x250 mm/kasan/report.c:252 > kasan_report_error mm/kasan/report.c:351 [inline] > kasan_report+0x25b/0x340 mm/kasan/report.c:409 > __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430 > worker_thread+0x15bb/0x1990 kernel/workqueue.c:2245 > kthread+0x35e/0x430 kernel/kthread.c:231 > ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:432 > > Allocated by task 31482: > save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 > save_stack+0x43/0xd0 mm/kasan/kasan.c:447 > set_track mm/kasan/kasan.c:459 [inline] > kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551 > kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489 > kmem_cache_alloc+0x12e/0x760 mm/slab.c:3562 > kmem_cache_zalloc include/linux/slab.h:657 [inline] > kcm_attach net/kcm/kcmsock.c:1394 [inline] > kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline] > kcm_ioctl+0x2d1/0x1610 net/kcm/kcmsock.c:1695 > sock_do_ioctl+0x65/0xb0 net/socket.c:961 > sock_ioctl+0x2c2/0x440 net/socket.c:1058 > vfs_ioctl fs/ioctl.c:46 [inline] > do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686 > SYSC_ioctl fs/ioctl.c:701 [inline] > SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692 > entry_SYSCALL_64_fastpath+0x1f/0xbe > > Freed by task 1249: > save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 > save_stack+0x43/0xd0 mm/kasan/kasan.c:447 > set_track mm/kasan/kasan.c:459 [inline] > kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524 > __cache_free mm/slab.c:3504 [inline] > kmem_cache_free+0x77/0x280 mm/slab.c:3764 > unreserve_psock+0x5a1/0x780 net/kcm/kcmsock.c:547 > kcm_write_msgs+0xbae/0x1b80 net/kcm/kcmsock.c:590 > kcm_tx_work+0x2e/0x190 net/kcm/kcmsock.c:731 > process_one_work+0xbf0/0x1bc0 kernel/workqueue.c:2113 > worker_thread+0x223/0x1990 kernel/workqueue.c:2247 > kthread+0x35e/0x430 kernel/kthread.c:231 > ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:432 > > The buggy address belongs to the object at 8801c3a74040 > which belongs to the cache kcm_psock_cache of size 552 > The buggy address is located 208 bytes inside of > 552-byte region [8801c3a74040, 8801c3a74268) > The buggy address belongs to the page: > page:ea00070e9d00 count:1 mapcount:0 mapping:8801c3a74040 index:0x0 > compound_mapcount: 0 > flags: 0x2fffc008100(slab|head) > raw: 02fffc008100 8801c3a74040 0001000b > raw: ea00067920a0 8801d3f39948 8801d3f2a840 > page dumped because: kasan: bad access detected > > Memory state around the buggy address: > 8801c3a74000: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb > 8801c3a74080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >> >> 8801c3a74100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > ^ > 8801c3a74180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > 8801c3a74200: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc > == > > > --- > This bug is generated by a dumb bot. It may contain errors. > See https://goo.gl/tpsmEJ for details. > Direct all questions to syzkal...@googlegroups.com. > Please credit me with: Reported-by: syzbot > > syzbot will keep track of this bug report. > Once a fix for this bug is committed, please reply to this email with: > #syz fix: exact-commit-title > To mark this as a duplicate of another syzbot report, please reply with: > #syz dup: exact-subject-of-another-report > If it's a one-off invalid bug report, please reply with: > #syz invalid > Note: if the crash happens again, it will cause creation of a new bug > report. > Note: all commands must start from beginning of the line. > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web