Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751459AbdIKPvl (ORCPT ); Mon, 11 Sep 2017 11:51:41 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:37676 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751026AbdIKPvj (ORCPT ); Mon, 11 Sep 2017 11:51:39 -0400 X-Google-Smtp-Source: AOwi7QAxpFNJzlYLxgjYY6opSgkG42hEYrH2Yf2Oe17TqKFdgMJWfHmmVQVjSfM1qqcFGbYW7AAFC//kWFxyxBVvioA= MIME-Version: 1.0 From: Andrey Konovalov Date: Mon, 11 Sep 2017 17:51:37 +0200 Message-ID: Subject: usb/gadget: null-ptr-deref in dev_ioctl To: Felipe Balbi , Greg Kroah-Hartman , Alan Stern , David Windsor , Andrew Morton , Andrey Konovalov , Elena Reshetova , Al Viro , Christophe JAILLET , Masahiro Yamada , USB list , LKML Cc: Dmitry Vyukov , Kostya Serebryany , 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 Content-Length: 2104 Lines: 42 Hi! It seems that gadget->ops can be NULL so it probably needs to be checked as well as gadget->ops->ioctl in dev_ioctl() in drivers/usb/gadget/legacy/inode.c. kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: 0000 [#1] SMP KASAN Modules linked in: CPU: 1 PID: 5214 Comm: syz-executor Not tainted 4.13.0+ #94 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff88006ac0e800 task.stack: ffff88006af60000 ! handling hub events now: start RIP: 0010:dev_ioctl+0x117/0x280 drivers/usb/gadget/legacy/inode.c:1323 RSP: 0018:ffff88006af67c30 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: 1ffff1000d5ecf86 RCX: ffffc90000ab5000 RDX: 0000000000000005 RSI: ffffffff83f1c482 RDI: 0000000000000028 RBP: ffff88006af67cf8 R08: ffffed000d5ecf80 R09: ffffed000d5ecf81 R10: ffff88006af67ed8 R11: 0000000000000000 R12: 0000000000000414 R13: 0000000000000000 R14: dffffc0000000000 R15: 0000000000000000 FS: 00007fd2fcbc1700(0000) GS:ffff88006c900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000006e30a0 CR3: 000000006a3ef000 CR4: 00000000000006e0 Call Trace: vfs_ioctl fs/ioctl.c:45 do_vfs_ioctl+0x1d2/0x1560 fs/ioctl.c:685 SYSC_ioctl fs/ioctl.c:700 SyS_ioctl+0x94/0xc0 fs/ioctl.c:691 entry_SYSCALL_64_fastpath+0x1a/0xa5 arch/x86/entry/entry_64.S:203 RIP: 0033:0x447727 RSP: 002b:00007fd2fcbc0bd8 EFLAGS: 00000206 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 0000000000708000 RCX: 0000000000447727 RDX: 0000000000000000 RSI: 0000000000000414 RDI: 0000000000000005 RBP: 0000000000005da0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000005 R13: 00000000ffffffff R14: 000000000000004c R15: 0000000020003000 Code: 80 96 50 fd 41 81 fc 42 42 00 00 0f 84 b3 00 00 00 e8 6e 96 50 fd 49 8d 7f 28 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 4e 01 00 00 4d 8b 77 28 48 b8 00 00 00 00 00 RIP: dev_ioctl+0x117/0x280 RSP: ffff88006af67c30 ---[ end trace 2fb9696e75c067ba ]---