Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2257729rwp; Fri, 14 Jul 2023 03:28:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlE7nmOdGiJSG/pdhx/bC/Xojz/yddbxOwqY3fomrnW6lpr8OXcHa4tiaQ3gpahKLZEWdB2j X-Received: by 2002:a17:903:2349:b0:1b8:656f:76e7 with SMTP id c9-20020a170903234900b001b8656f76e7mr3031375plh.23.1689330530227; Fri, 14 Jul 2023 03:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689330530; cv=none; d=google.com; s=arc-20160816; b=lCwgiCZnw/2xE+SyVGforLPrYAltz2weQY5PxAkRbJs522xUnL2HX4NHCg3JUn4c0J YceYj7k6h3gMC2SRMC94pNcNUHEZ5u5CUNWawLtktX6rorfBOLcQzHjXmQfOx3g42OfA qnVT51mbFz62qBm1nwYhA/5YEFotjl0i3I9qx3/iQBOIRk1Ef187ctkj6vH9TeIFmGOP N7OC/p1nM4dLIJgeJD7ANMMX4qTMufbELuCIPgCEQHWQij1vixKpimJ+V+pdNz1gCIF1 n8rbFc50tx5qBX3NESgjnWIvX4KNqDiXK9PKsecHpllO+j1v7Mp6r+tIIukS/d3H9PJf pn6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=CEvX4KPZZMtAxsaBUd2aHjaev/UBEibxCwQJvNcdreQ=; fh=Izj69nSyixV5N3BlNJmhFcC+emWD/2uKIvOa5OmhGl8=; b=TQNWzE4W6WOwP8uuW4ZmyLX39NOnUlg1KYvIRv6h+BVWobUt3ZbkjdG89kelln9pX0 wb60dR8razVrqwfmetf1iUJZU07ssStep5Jq/uUiRD1nu2M+2A7pB4XqXqn4Fg+GIZ8A gbRIGUAsykkZHouFLFUOyhiXXrjHqwfcU9NGPiJgHwPsg0RBOV2KlvYmvJG7pNxekMWh bp42nuUGU1MprLNEOsitGX1ixKvXhqSwOCZ9ajDenIXCt8ofutl33d+rL0Lf1//CA81+ UCIEMuV113PSfqUt3EsEKewM+R0AwR3kTB5iauyGIGWZ7VdFgnijfu6U+n9l1aArzg51 4vBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=LlIXvZEl; 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 e7-20020a170902cf4700b001b8b564b558si6560087plg.645.2023.07.14.03.28.37; Fri, 14 Jul 2023 03:28:50 -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=LlIXvZEl; 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 S235554AbjGNKCS (ORCPT + 99 others); Fri, 14 Jul 2023 06:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235746AbjGNKCD (ORCPT ); Fri, 14 Jul 2023 06:02:03 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26BCE26B7; Fri, 14 Jul 2023 03:02:01 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2633fe9b6c0so1976324a91.1; Fri, 14 Jul 2023 03:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689328920; x=1691920920; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=CEvX4KPZZMtAxsaBUd2aHjaev/UBEibxCwQJvNcdreQ=; b=LlIXvZElFSwPQQP3EdOQW7/Ccpi+mGJa/+kHElIUP2221clCruGTO6JDTjGt/70Br9 +1jYKgFH/pQQg+JwFLZRLt6g8zW7LKsjh90racIMltSY2Vv0DEpvQgAyPV2I6Sx7pylL OxeKUmfQeU4JaMFZMU3bnaZAw6qC2BewSuTP8+zi76DWflHKcVMMvQELCNe2zqV98zcb Y7Jg1odbeGGH4vHC3FvYTR9A3FrxVE1p5IPGp2rTmUKMloK+warj+83wmXRD1aWGeLXq I3rSJfHnSZQICUBq2VvGBaiSZaBc2nGUkEeSyPUuW8M4Q7RK13Jm+rl+NtMRJssLPkjF 5OZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689328920; x=1691920920; h=content-transfer-encoding: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=CEvX4KPZZMtAxsaBUd2aHjaev/UBEibxCwQJvNcdreQ=; b=H9FtCXaoFx0PLF6Wr2cwrWZtjWmrg+MC2/a1ZahWZMFhx02zm7yAxBUxvJuuXMOUQk azPgANhZyRnLeYtbPC7/nMdoxDyRyfMg/D3H+PUvhYFR7QX36T+Vw1eVQ7TfaNA/RY1N QnEqcxvdgnNBwjL9GWRu7ZTX6dGu4UHG8wV7LI7eMogBySQwzjIfBDcTARhpH4vJX3xV tac/I9FV3XGTVIoQx/1qwpwJ7OHJ+mb/CORJXc9gC0gqktkKNbmzH4KjEnG5+tkPoLFG YP+n+MKFOpWWsVcp1L5n9jvahuMGPuAFDlOWl1KKR8tBHclJwfXdpNx9t2XBpyX1zw3F Js7Q== X-Gm-Message-State: ABy/qLbhltfLhJz6jbtSMgkJaQGT9KxWYeqXE0mmJ4Y2qSYCg+2IZunJ 83zS/ECj6Y0H1lzSbqFealawzKK4gc2tyuPbkkQU+EyRmqk= X-Received: by 2002:a17:90a:72c8:b0:25e:fb6d:ce68 with SMTP id l8-20020a17090a72c800b0025efb6dce68mr3102557pjk.6.1689328920447; Fri, 14 Jul 2023 03:02:00 -0700 (PDT) MIME-Version: 1.0 References: <0000000000009db51a06005b64e9@google.com> In-Reply-To: From: Z qiang Date: Fri, 14 Jul 2023 18:01:48 +0800 Message-ID: Subject: Re: [syzbot] [usb?] memory leak in raw_open To: Aleksandr Nogikh Cc: syzbot , 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" Content-Transfer-Encoding: quoted-printable 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 On Fri, Jul 14, 2023 at 5:47=E2=80=AFPM Aleksandr Nogikh wrote: > > Hi, > > On Fri, Jul 14, 2023 at 9:12=E2=80=AFAM Z qiang wrote: > > > > > > > > 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=3D1517663ca= 80000 > > > kernel config: https://syzkaller.appspot.com/x/.config?x=3D832b404e0= 95b70c0 > > > dashboard link: https://syzkaller.appspot.com/bug?extid=3Dfeb045d335c= 1fdde5bf7 > > > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Bi= nutils for Debian) 2.35.2 > > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=3D1776519= ca80000 > > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=3D117f9778a= 80000 > > > > > > Downloadable assets: > > > disk image: https://storage.googleapis.com/syzbot-assets/43b42bd2cf70= /disk-1c7873e3.raw.xz > > > vmlinux: https://storage.googleapis.com/syzbot-assets/011ba1b9e8c1/vm= linux-1c7873e3.xz > > > kernel image: https://storage.googleapis.com/syzbot-assets/18b3493425= 95/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:107= 6 > > > [] 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/legac= y/raw_gadget.c:385 > > > [] misc_open+0x1a9/0x1f0 drivers/char/misc.c:16= 5 > > > [] 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 [i= nline] > > > [] do_syscall_64+0x39/0xb0 arch/x86/entry/commo= n.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:107= 6 > > > [] 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/le= gacy/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 [i= nline] > > > [] do_syscall_64+0x39/0xb0 arch/x86/entry/commo= n.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:107= 6 > > > [] kmalloc include/linux/slab.h:582 [inline] > > > [] raw_ioctl_init+0x11d/0x410 drivers/usb/gadge= t/legacy/raw_gadget.c:468 > > > [] raw_ioctl+0x5f9/0x1120 drivers/usb/gadget/le= gacy/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 [i= nline] > > > [] do_syscall_64+0x39/0xb0 arch/x86/entry/commo= n.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:107= 6 > > > [] kmalloc include/linux/slab.h:582 [inline] > > > [] raw_ioctl_init+0x1ac/0x410 drivers/usb/gadge= t/legacy/raw_gadget.c:479 > > > [] raw_ioctl+0x5f9/0x1120 drivers/usb/gadget/le= gacy/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 [i= nline] > > > [] do_syscall_64+0x39/0xb0 arch/x86/entry/commo= n.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:107= 6 > > > [] kmalloc include/linux/slab.h:582 [inline] > > > [] kzalloc include/linux/slab.h:703 [inline] > > > [] dummy_alloc_request+0x5a/0xe0 drivers/usb/ga= dget/udc/dummy_hcd.c:665 > > > [] usb_ep_alloc_request+0x22/0xd0 drivers/usb/g= adget/udc/core.c:196 > > > [] gadget_bind+0x6d/0x370 drivers/usb/gadget/le= gacy/raw_gadget.c:292 > > > [] gadget_bind_driver+0xe3/0x2e0 drivers/usb/ga= dget/udc/core.c:1591 > > > [] call_driver_probe drivers/base/dd.c:579 [inl= ine] > > > [] really_probe+0x12d/0x430 drivers/base/dd.c:6= 58 > > > [] __driver_probe_device+0xc1/0x1a0 drivers/bas= e/dd.c:798 > > > [] driver_probe_device+0x2a/0x120 drivers/base/= dd.c:828 > > > [] __driver_attach drivers/base/dd.c:1214 [inli= ne] > > > [] __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/driv= er.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/le= gacy/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 [i= nline] > > > [] do_syscall_64+0x39/0xb0 arch/x86/entry/commo= n.c:80 > > > > > > > > > > > > #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-nex= t.git > > master > > > > > > --- a/drivers/usb/gadget/legacy/raw_gadget.c > > +++ b/drivers/usb/gadget/legacy/raw_gadget.c > > @@ -310,12 +310,15 @@ static int gadget_bind(struct usb_gadget *gadget, > > dev->eps_num =3D i; > > spin_unlock_irqrestore(&dev->lock, flags); > > > > syzbot expects that every line of the git diff patch begins with some > character (unchanged lines with space, added/deleted with + and - > correspondingly). Here you have an empty line and syzbot thinks it's > already the end of the patch. Therefore the patch testing fails. > Thanks for your remind and I also sent a patch :) Thanks Zqiang > > > - /* Matches kref_put() in gadget_unbind(). */ > > - kref_get(&dev->count); > > - > > ret =3D raw_queue_event(dev, USB_RAW_EVENT_CONNECT, 0, NULL); > > - if (ret < 0) > > + if (ret < 0) { > > dev_err(&gadget->dev, "failed to queue event\n"); > > + set_gadget_data(gadget, NULL); > > + return ret; > > + } > > + > > + /* Matches kref_put() in gadget_unbind(). */ > > + kref_get(&dev->count); > > > > return ret; > > } > > > > -- > > You received this message because you are subscribed to the Google Grou= ps "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 on the web visit https://groups.google.com/d/ms= gid/syzkaller-bugs/CALm%2B0cXi-YsnJBdBt38v4gEoR7oEeaoj3wXjEw3m%3D25RSLEs8g%= 40mail.gmail.com.