From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751635AbcLENK4 (ORCPT ); Mon, 5 Dec 2016 08:10:56 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:36371 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751327AbcLENKy (ORCPT ); Mon, 5 Dec 2016 08:10:54 -0500 MIME-Version: 1.0 From: Andrey Konovalov Date: Mon, 5 Dec 2016 14:03:22 +0100 Message-ID: Subject: usb/gadget: use-after-free in gadgetfs_setup To: Felipe Balbi , Greg Kroah-Hartman , Al Viro , Marek Szyprowski , Arnd Bergmann , Michal Hocko , David Eccher , Binyamin Sharet , Bin Liu , Mathieu Laurendeau , Andrey Konovalov , "Kirill A. Shutemov" , linux-usb@vger.kernel.org, LKML Cc: Kostya Serebryany , Dmitry Vyukov , syzkaller Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! I've got the following error report while running the syzkaller fuzzer. On commit 3c49de52d5647cda8b42c4255cf8a29d1e22eff5 (Dec 2). BUG: KASAN: use-after-free in gadgetfs_setup+0x208a/0x20e0 at addr ffff88003dfe5bf2 Read of size 2 by task syz-executor0/22994 CPU: 3 PID: 22994 Comm: syz-executor0 Not tainted 4.9.0-rc7+ #16 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 ffff88006df06a18 ffffffff81f96aba ffffffffe0528500 1ffff1000dbe0cd6 ffffed000dbe0cce ffff88006df068f0 0000000041b58ab3 ffffffff8598b4c8 ffffffff81f96828 1ffff1000dbe0ccd ffff88006df06708 ffff88006df06748 Call Trace: [ 201.343209] [< inline >] __dump_stack lib/dump_stack.c:15 [ 201.343209] [] dump_stack+0x292/0x398 lib/dump_stack.c:51 [] kasan_object_err+0x1c/0x70 mm/kasan/report.c:159 [< inline >] print_address_description mm/kasan/report.c:197 [] kasan_report_error+0x1f0/0x4e0 mm/kasan/report.c:286 [< inline >] kasan_report mm/kasan/report.c:306 [] __asan_report_load_n_noabort+0x3a/0x40 mm/kasan/report.c:337 [< inline >] config_buf drivers/usb/gadget/legacy/inode.c:1298 [] gadgetfs_setup+0x208a/0x20e0 drivers/usb/gadget/legacy/inode.c:1368 [] dummy_timer+0x11f0/0x36d0 drivers/usb/gadget/udc/dummy_hcd.c:1858 [] call_timer_fn+0x241/0x800 kernel/time/timer.c:1308 [< inline >] expire_timers kernel/time/timer.c:1348 [] __run_timers+0xa06/0xec0 kernel/time/timer.c:1641 [] run_timer_softirq+0x21/0x80 kernel/time/timer.c:1654 [] __do_softirq+0x2fb/0xb63 kernel/softirq.c:284 [< inline >] invoke_softirq kernel/softirq.c:364 [] irq_exit+0x19e/0x1d0 kernel/softirq.c:405 [< inline >] exiting_irq arch/x86/include/asm/apic.h:659 [] smp_apic_timer_interrupt+0x7b/0xa0 arch/x86/kernel/apic/apic.c:960 [] apic_timer_interrupt+0x8c/0xa0 arch/x86/entry/entry_64.S:489 [ 201.343209] [] ? _raw_spin_unlock_irqrestore+0x119/0x1a0 [] try_to_wake_up+0x174/0x1160 kernel/sched/core.c:2099 [< inline >] wake_up_process kernel/sched/core.c:2165 [] wake_up_q+0x8a/0xe0 kernel/sched/core.c:469 [] futex_wake+0x5be/0x6c0 kernel/futex.c:1453 [] do_futex+0x11bd/0x1f00 kernel/futex.c:3219 [< inline >] SYSC_futex kernel/futex.c:3275 [] SyS_futex+0x2fc/0x400 kernel/futex.c:3243 [] entry_SYSCALL_64_fastpath+0x1f/0xc2 Object at ffff88003dfe5bf0, in cache kmalloc-32 size: 32 Allocated: PID = 21625 [ 201.343209] [] save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57 [ 201.343209] [] save_stack+0x43/0xd0 mm/kasan/kasan.c:495 [ 201.343209] [< inline >] set_track mm/kasan/kasan.c:507 [ 201.343209] [] kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:598 [ 201.343209] [] kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:537 [ 201.343209] [< inline >] slab_post_alloc_hook mm/slab.h:417 [ 201.343209] [< inline >] slab_alloc_node mm/slub.c:2708 [ 201.343209] [< inline >] slab_alloc mm/slub.c:2716 [ 201.343209] [] __kmalloc_track_caller+0x195/0x290 mm/slub.c:4240 [ 201.343209] [] memdup_user+0x2c/0xa0 mm/util.c:137 [ 201.343209] [] dev_config+0x2eb/0x1190 drivers/usb/gadget/legacy/inode.c:1778 [ 201.343209] [] __vfs_write+0x5d5/0x760 fs/read_write.c:510 [ 201.343209] [] vfs_write+0x170/0x4e0 fs/read_write.c:560 [ 201.343209] [< inline >] SYSC_write fs/read_write.c:607 [ 201.343209] [] SyS_write+0xfb/0x230 fs/read_write.c:599 [ 201.343209] [] entry_SYSCALL_64_fastpath+0x1f/0xc2 Freed: PID = 21625 [ 201.343209] [] save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57 [ 201.343209] [] save_stack+0x43/0xd0 mm/kasan/kasan.c:495 [ 201.343209] [< inline >] set_track mm/kasan/kasan.c:507 [ 201.343209] [] kasan_slab_free+0x73/0xc0 mm/kasan/kasan.c:571 [ 201.343209] [< inline >] slab_free_hook mm/slub.c:1352 [ 201.343209] [< inline >] slab_free_freelist_hook mm/slub.c:1374 [ 201.343209] [< inline >] slab_free mm/slub.c:2951 [ 201.343209] [] kfree+0xe7/0x2b0 mm/slub.c:3871 [ 201.343209] [] dev_config+0xc0b/0x1190 drivers/usb/gadget/legacy/inode.c:1848 [ 201.343209] [] __vfs_write+0x5d5/0x760 fs/read_write.c:510 [ 201.343209] [] vfs_write+0x170/0x4e0 fs/read_write.c:560 [ 201.343209] [< inline >] SYSC_write fs/read_write.c:607 [ 201.343209] [] SyS_write+0xfb/0x230 fs/read_write.c:599 [ 201.343209] [] entry_SYSCALL_64_fastpath+0x1f/0xc2 Memory state around the buggy address: ffff88003dfe5a80: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88003dfe5b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88003dfe5b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fb fb ^ ffff88003dfe5c00: fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88003dfe5c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================