Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2084946rwp; Thu, 13 Jul 2023 23:57:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlHjdGUVbaEHhRbQVjUS31r5JJ56pb7u9m6yAc5uRCMN6+R0IJN9Sc3qr3K6x0tDN6Qwv7Kc X-Received: by 2002:a17:903:247:b0:1b8:1d4b:f5fc with SMTP id j7-20020a170903024700b001b81d4bf5fcmr5045203plh.30.1689317826703; Thu, 13 Jul 2023 23:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689317826; cv=none; d=google.com; s=arc-20160816; b=V86U9kTbu2QjsuWOJgZHuHpPS5QLnxbNXKqH3WHFY9WK/Ic4Ic1huc0smxRg0ph+NF X+5alEFhatGEgZ+c27qLkZDFvm27gErzZjthlj0XdCoRQo5NUounthi9xOyfgowDtj72 x3oTICnH0OnH0aovvYaMLZbh40fzi3lRCsrKOk2DxFMLuc4acBoPuPXeiDjAp3BWcoh4 DRk368SW6u8IR8GI8XTSv24azGtC2L1tcLF5apChyENoSeXGdF6gvPJb6yjateZkmPlw AfXGN2ihgnaR+3+lnzgNMxKQVO5OrCWF7b+6cmuWEk4kEvNoZFhfxofaevc6oE1pAPfG ppEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=TZ+Tlchq7Rx5JUChD94efcFz6I7nfzXVwwR7VBAwSBw=; fh=qIMrpZrY5xHHiykPTU/zR1JJB4lbzuu/WznLpHkGKG8=; b=usuNZdMt/aXxJxrOtaLkSP+T4tWflFOv8DfMiGvO22N1uIc0OCccWT55XZ2JM0+LdN Lf3dVxRemvy29QiVjk+SjQxp/Kfb2qWijre9+PidMpuYWe4jh31K0+wuJE5u1wBP9+T8 OwEAi59GXS2CWojD7fXzmR63LP8F5L/a9KOEJQhRd0ikMJELRiubu1BxEVI/U08g4DR1 2fCPAbA0z1vxwp3x5uSQtwl6fOk4LKe3W1PBe7DaaEtb9m2w5NCP4y9ZTM9rsOawJDDq bJ0Fh97Lkm5G9EVMULDJn8JMCJ4+rJ8kcDMQCm25z6kytpQJMlmQuMei3xkS9EOr6IS1 TDXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=H4q+c87H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020a17090341cc00b001b9ea5f0feesi6990039ple.453.2023.07.13.23.56.54; Thu, 13 Jul 2023 23:57:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=H4q+c87H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235071AbjGNGV0 (ORCPT + 99 others); Fri, 14 Jul 2023 02:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233196AbjGNGVZ (ORCPT ); Fri, 14 Jul 2023 02:21:25 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 564A02726; Thu, 13 Jul 2023 23:21:23 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bb119be881so5240625ad.3; Thu, 13 Jul 2023 23:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689315683; x=1691907683; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=TZ+Tlchq7Rx5JUChD94efcFz6I7nfzXVwwR7VBAwSBw=; b=H4q+c87H4VJCc8tpwfLc7WRMkWvucAc1d0TQMxiBZW1QHOnbr92BfH69PwNsyDY1NS 3DFgzGCFD8xmwSns59zE5u1CCAUONY6jS/ziBDFltyIc7W+7NqFzQSY0ZhG37LkYeZ9M KFQanGY355c3pTdPlzz8Uj+J1k+ZQGHiznZtCtEnkX6FFO0kOjEM9cRe5HiaMP7f1H1c ZL/JfUaL2glLj3+ThYDRiB3shDFDDOBKS1ocfyOXKsFbbx9IpH2YHrFwW6E9W//3Z3+A w7Pmylqt401exPtEiAfBu/7AUByrLTcMLO8m/RHmWUzkQVB73oVnbFb6fHBACL32UPND n3Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689315683; x=1691907683; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TZ+Tlchq7Rx5JUChD94efcFz6I7nfzXVwwR7VBAwSBw=; b=c2pF/2LzJ8vpWgO/7cCa0b5hgvpOeYQewwMya2+/ENGV+NEyibOMKRBWZoVCaKctjG yBbUYMLlMiXzzHE8Rzqz1452KM2eSUoTXxDLljrB6pwkS/UHaqaXlwCJ/AX0HRXU20+j w8Inw7RxYkHiZO+Kmgo2I9cjhWApQJDMMeriwEkTpUcw7Hi9tNYqM/XsKfqElud+IxaM kljE99zmTPS1RpmfsFWxr9Q1L9xyQBvkukV6zLCTb3WImvyjDzH7niIGjwt/ygadG81p NbR/8EJI1NCimEVet4GMTHtgNu6P7Q4PcLuRd1PaCLouo7FezRbWYgsmDxwaE/ZVxPDO MOVA== X-Gm-Message-State: ABy/qLZeKci4IcK/vvFXmsmFp7777BW5MdYtzu//SZvnY9o0M0UypS7O MUPzedIKbE06hJBqKeBJdHbg4IHXqZaazyNUgKM= X-Received: by 2002:a17:902:cec3:b0:1b8:971c:b7b7 with SMTP id d3-20020a170902cec300b001b8971cb7b7mr4128499plg.56.1689315682551; Thu, 13 Jul 2023 23:21:22 -0700 (PDT) MIME-Version: 1.0 References: <0000000000009db51a06005b64e9@google.com> In-Reply-To: <0000000000009db51a06005b64e9@google.com> From: Z qiang Date: Fri, 14 Jul 2023 14:21:10 +0800 Message-ID: Subject: Re: [syzbot] [usb?] memory leak in raw_open To: syzbot Cc: andreyknvl@gmail.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > Hello, > > syzbot found the following issue on: > > HEAD commit: 1c7873e33645 mm: lock newly mapped VMA with corrected orde.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=1517663ca80000 > kernel config: https://syzkaller.appspot.com/x/.config?x=832b404e095b70c0 > dashboard link: https://syzkaller.appspot.com/bug?extid=feb045d335c1fdde5bf7 > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1776519ca80000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=117f9778a80000 > > Downloadable assets: > disk image: https://storage.googleapis.com/syzbot-assets/43b42bd2cf70/disk-1c7873e3.raw.xz > vmlinux: https://storage.googleapis.com/syzbot-assets/011ba1b9e8c1/vmlinux-1c7873e3.xz > kernel image: https://storage.googleapis.com/syzbot-assets/18b349342595/bzImage-1c7873e3.xz > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+feb045d335c1fdde5bf7@syzkaller.appspotmail.com > > BUG: memory leak > unreferenced object 0xffff88810b172000 (size 4096): > comm "syz-executor103", pid 5067, jiffies 4294964128 (age 13.070s) > hex dump (first 32 bytes): > 01 00 00 00 00 00 00 00 00 bc 96 0e 81 88 ff ff ................ > 5d b6 9e 85 ff ff ff ff 03 00 00 00 00 00 00 00 ]............... > backtrace: > [] kmalloc_trace+0x24/0x90 mm/slab_common.c:1076 > [] kmalloc include/linux/slab.h:582 [inline] > [] kzalloc include/linux/slab.h:703 [inline] > [] dev_new drivers/usb/gadget/legacy/raw_gadget.c:191 [inline] > [] raw_open+0x45/0x110 drivers/usb/gadget/legacy/raw_gadget.c:385 > [] misc_open+0x1a9/0x1f0 drivers/char/misc.c:165 > [] chrdev_open+0x11b/0x340 fs/char_dev.c:414 > [] do_dentry_open+0x30f/0x990 fs/open.c:914 > [] do_open fs/namei.c:3636 [inline] > [] path_openat+0x178b/0x1b20 fs/namei.c:3793 > [] do_filp_open+0xc5/0x1b0 fs/namei.c:3820 > [] do_sys_openat2+0xe3/0x140 fs/open.c:1407 > [] do_sys_open fs/open.c:1422 [inline] > [] __do_sys_openat fs/open.c:1438 [inline] > [] __se_sys_openat fs/open.c:1433 [inline] > [] __x64_sys_openat+0x83/0xe0 fs/open.c:1433 > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > [] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 > [] entry_SYSCALL_64_after_hwframe+0x63/0xcd > > BUG: memory leak > unreferenced object 0xffff88810ad20d60 (size 32): > comm "syz-executor103", pid 5067, jiffies 4294964128 (age 13.070s) > hex dump (first 32 bytes): > 72 61 77 2d 67 61 64 67 65 74 2e 30 00 00 00 00 raw-gadget.0.... > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [] kmalloc_trace+0x24/0x90 mm/slab_common.c:1076 > [] kmalloc include/linux/slab.h:582 [inline] > [] raw_ioctl_init+0xdf/0x410 drivers/usb/gadget/legacy/raw_gadget.c:460 > [] raw_ioctl+0x5f9/0x1120 drivers/usb/gadget/legacy/raw_gadget.c:1250 > [] vfs_ioctl fs/ioctl.c:51 [inline] > [] __do_sys_ioctl fs/ioctl.c:870 [inline] > [] __se_sys_ioctl fs/ioctl.c:856 [inline] > [] __x64_sys_ioctl+0x103/0x140 fs/ioctl.c:856 > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > [] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 > [] entry_SYSCALL_64_after_hwframe+0x63/0xcd > > BUG: memory leak > unreferenced object 0xffff88810e96bc00 (size 128): > comm "syz-executor103", pid 5067, jiffies 4294964128 (age 13.070s) > hex dump (first 32 bytes): > 64 75 6d 6d 79 5f 75 64 63 00 00 00 00 00 00 00 dummy_udc....... > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [] kmalloc_trace+0x24/0x90 mm/slab_common.c:1076 > [] kmalloc include/linux/slab.h:582 [inline] > [] raw_ioctl_init+0x11d/0x410 drivers/usb/gadget/legacy/raw_gadget.c:468 > [] raw_ioctl+0x5f9/0x1120 drivers/usb/gadget/legacy/raw_gadget.c:1250 > [] vfs_ioctl fs/ioctl.c:51 [inline] > [] __do_sys_ioctl fs/ioctl.c:870 [inline] > [] __se_sys_ioctl fs/ioctl.c:856 [inline] > [] __x64_sys_ioctl+0x103/0x140 fs/ioctl.c:856 > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > [] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 > [] entry_SYSCALL_64_after_hwframe+0x63/0xcd > > BUG: memory leak > unreferenced object 0xffff88810e96ba80 (size 128): > comm "syz-executor103", pid 5067, jiffies 4294964128 (age 13.070s) > hex dump (first 32 bytes): > 64 75 6d 6d 79 5f 75 64 63 2e 30 00 00 00 00 00 dummy_udc.0..... > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [] kmalloc_trace+0x24/0x90 mm/slab_common.c:1076 > [] kmalloc include/linux/slab.h:582 [inline] > [] raw_ioctl_init+0x1ac/0x410 drivers/usb/gadget/legacy/raw_gadget.c:479 > [] raw_ioctl+0x5f9/0x1120 drivers/usb/gadget/legacy/raw_gadget.c:1250 > [] vfs_ioctl fs/ioctl.c:51 [inline] > [] __do_sys_ioctl fs/ioctl.c:870 [inline] > [] __se_sys_ioctl fs/ioctl.c:856 [inline] > [] __x64_sys_ioctl+0x103/0x140 fs/ioctl.c:856 > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > [] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 > [] entry_SYSCALL_64_after_hwframe+0x63/0xcd > > BUG: memory leak > unreferenced object 0xffff88810e96bd00 (size 128): > comm "syz-executor103", pid 5067, jiffies 4294964128 (age 13.070s) > hex dump (first 32 bytes): > 00 bd 96 0e 81 88 ff ff 00 bd 96 0e 81 88 ff ff ................ > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > backtrace: > [] kmalloc_trace+0x24/0x90 mm/slab_common.c:1076 > [] kmalloc include/linux/slab.h:582 [inline] > [] kzalloc include/linux/slab.h:703 [inline] > [] dummy_alloc_request+0x5a/0xe0 drivers/usb/gadget/udc/dummy_hcd.c:665 > [] usb_ep_alloc_request+0x22/0xd0 drivers/usb/gadget/udc/core.c:196 > [] gadget_bind+0x6d/0x370 drivers/usb/gadget/legacy/raw_gadget.c:292 > [] gadget_bind_driver+0xe3/0x2e0 drivers/usb/gadget/udc/core.c:1591 > [] call_driver_probe drivers/base/dd.c:579 [inline] > [] really_probe+0x12d/0x430 drivers/base/dd.c:658 > [] __driver_probe_device+0xc1/0x1a0 drivers/base/dd.c:798 > [] driver_probe_device+0x2a/0x120 drivers/base/dd.c:828 > [] __driver_attach drivers/base/dd.c:1214 [inline] > [] __driver_attach+0xfe/0x1f0 drivers/base/dd.c:1154 > [] bus_for_each_dev+0xa5/0x110 drivers/base/bus.c:368 > [] bus_add_driver+0x126/0x2a0 drivers/base/bus.c:673 > [] driver_register+0x8a/0x190 drivers/base/driver.c:246 > [] usb_gadget_register_driver_owner+0x64/0x160 drivers/usb/gadget/udc/core.c:1665 > [] raw_ioctl_run drivers/usb/gadget/legacy/raw_gadget.c:546 [inline] > [] raw_ioctl+0x6f6/0x1120 drivers/usb/gadget/legacy/raw_gadget.c:1253 > [] vfs_ioctl fs/ioctl.c:51 [inline] > [] __do_sys_ioctl fs/ioctl.c:870 [inline] > [] __se_sys_ioctl fs/ioctl.c:856 [inline] > [] __x64_sys_ioctl+0x103/0x140 fs/ioctl.c:856 > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > [] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 > #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master diff --git a/drivers/usb/gadget/legacy/raw_gadget.c b/drivers/usb/gadget/legacy/raw_gadget.c index 2acece16b890..c00f93b630ad 100644 --- a/drivers/usb/gadget/legacy/raw_gadget.c +++ b/drivers/usb/gadget/legacy/raw_gadget.c @@ -310,13 +310,12 @@ static int gadget_bind(struct usb_gadget *gadget, dev->eps_num = i; spin_unlock_irqrestore(&dev->lock, flags); - /* Matches kref_put() in gadget_unbind(). */ - kref_get(&dev->count); - ret = raw_queue_event(dev, USB_RAW_EVENT_CONNECT, 0, NULL); if (ret < 0) dev_err(&gadget->dev, "failed to queue event\n"); + /* Matches kref_put() in gadget_unbind(). */ + kref_get(&dev->count); return ret; } > > > --- > 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 bug is already fixed, 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 change bug's subsystems, reply with: > #syz set subsystems: new-subsystem > (See the list of subsystem names on the web dashboard) > > If the bug is a duplicate of another bug, reply with: > #syz dup: exact-subject-of-another-report > > If you want to undo deduplication, reply with: > #syz undup