Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2256888rwp; Fri, 14 Jul 2023 03:27:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlEuda13GLRGBUyEvPOwvPuIrhBf838uU/bpsRe3Q9C9oVSybnYgAlj0ETfVAzH605+RVDyT X-Received: by 2002:a05:6a00:124b:b0:668:82fe:16e2 with SMTP id u11-20020a056a00124b00b0066882fe16e2mr3703354pfi.16.1689330478194; Fri, 14 Jul 2023 03:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689330478; cv=none; d=google.com; s=arc-20160816; b=AJBne9nJsjIXQiQ1KMnm1FtAHTpXZ5JF00FX9dBtUB9uQU6fXJkTLfNCLSCOylhs4d efLQttKD4msKbCHMVARIQcd7RjqIP9MkuECxQrTFi0ufkJ7cmIobivt8NQePLs/PjYDw IrK0wlKRz2CWqsp/UsQTbmhQH9bLvdI1YRukDG6rU/NaL+70HEe+srVSyxy03SwwmKy/ vBgRzNC0R2gMAnwz45E0Gl6deS29fkQxopm/ym4qELERmVFl6nhAeD/UgiSMsHzTao1U YfIeKworeTjR1TNZwBTXW8W1LLr2JGHM6nuFoR1QqvwvI/WCL3JZ6uz2CNb3a7tbILau QhSw== 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=AB28jTtYwCDZ7KgVFdc80ouWDjex8LD1i8UrxUr0xx8=; fh=XOfeZYlfXzpoBFZyJ1KriJhNYtmZitupm0czEL7715I=; b=yNBQKoHZmYpzuxg+JtegVjIo1WBa9zRZK5taE+RB/UHH+zJeVRib99auZ+iGl9GX75 UyFVlzgfxw2zNkPiQbKKHZPIUrbSZYkizd9aP61ypk7xj7JbFyoFYUS3Jzdrt2Uopf0o gRo4XhLn+rBizgpYx3OReYFhDLxtDLUpI/gol63RLvsC3HQoP80jYN67o2aAOP2aq/gk 9SRD2t+bvEN0KKCMTD4uvZDuIim6JKSh1UgcjjEDjL1nlMZix0dHVPbw7uchwLtRy7iG ZWBkqNmH2fzemBV8EEHIcejATIKYnlSHjLIqYU+XtRHM8GvIf0j6Byn2N4dxVXDgTIlq PA7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="6+za/qwq"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a6566c6000000b0051b70b1f1f5si6823261pgw.608.2023.07.14.03.27.46; Fri, 14 Jul 2023 03:27:58 -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=@google.com header.s=20221208 header.b="6+za/qwq"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235926AbjGNJsH (ORCPT + 99 others); Fri, 14 Jul 2023 05:48:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235972AbjGNJrz (ORCPT ); Fri, 14 Jul 2023 05:47:55 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A8D430DE for ; Fri, 14 Jul 2023 02:47:51 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fbd33a1819so47675e9.1 for ; Fri, 14 Jul 2023 02:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689328070; x=1691920070; 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=AB28jTtYwCDZ7KgVFdc80ouWDjex8LD1i8UrxUr0xx8=; b=6+za/qwqfyTzVX1ny/9MnOXTEN4MVlVs0hfM3qKGQyHIf0EqFkQFa6LOW9TBf3Vcyp RenGkOWHvyFOrf/izsxt3PS0A2mItlzqVaucQ+2CBLmw/Ihc8XpdrCsHJpM8k3eZvfA8 jWEjNq7mlw1uhrRWX+DralnOU8oQV3RvxtZcXXrJYqOzObWl+EbPbCPFr0GwKhzqaa0z HXylq6SZxgnl5eUGOYXu0T2iewqlY4Cm88meT7UtSAcNXltsM56jvtPilAH1v0JVkTOc rgMB9yYN5p2RWin6gLjftsW5pPZJhhoVm8zMDMjpb2YsXudhKlqVmdI40L2BL1e2JEro Mkaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689328070; x=1691920070; 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=AB28jTtYwCDZ7KgVFdc80ouWDjex8LD1i8UrxUr0xx8=; b=XzzRWf9Qr/wob7mYHe504qAryKHFiPssqSwyc9zgcxkOs6HG1MAf9FYW63N/gfikfQ CSwaN1NMmL89FmWRcRWHghnj0p+7ct4ZNoHkZHAuJDzOMh97M6NCAHrmCbgZiKeoeadz 9J2M3uqCvVQRHFJ919QuROgzJ+qUSnjX6ka5RdWyKcANR0xDuvhxiQoSetnY2h7KdYMU 5qU85szsOZkjAwPwwrwu2skUCOL2FJiKHhBOV6/p+qH7boFVVZZH8ti+c/uY7k/CRqK1 WWKd1Zvnjp6gAGXMxvdbdigava2X3Ppced6h3c5vxP/x5wbsTozG5dcerlIEDNYvocPa 9nQw== X-Gm-Message-State: ABy/qLa6pUUmnNwbGncOLxXqIC7xZeKOmK67dyhALimb/Jg0yZ0wm92I yOSkc6m909ILjlGvdRyda7ynwt11Q0vV0sVQ7jM5wQ== X-Received: by 2002:a05:600c:8609:b0:3f1:73b8:b5fe with SMTP id ha9-20020a05600c860900b003f173b8b5femr302722wmb.3.1689328069613; Fri, 14 Jul 2023 02:47:49 -0700 (PDT) MIME-Version: 1.0 References: <0000000000009db51a06005b64e9@google.com> In-Reply-To: From: Aleksandr Nogikh Date: Fri, 14 Jul 2023 11:47:37 +0200 Message-ID: Subject: Re: [syzbot] [usb?] memory leak in raw_open To: Z qiang 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=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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 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 o= rde.. > > git tree: upstream > > console output: https://syzkaller.appspot.com/x/log.txt?x=3D1517663ca80= 000 > > kernel config: https://syzkaller.appspot.com/x/.config?x=3D832b404e095= b70c0 > > dashboard link: https://syzkaller.appspot.com/bug?extid=3Dfeb045d335c1f= dde5bf7 > > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binu= tils for Debian) 2.35.2 > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=3D1776519ca= 80000 > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=3D117f9778a80= 000 > > > > Downloadable assets: > > disk image: https://storage.googleapis.com/syzbot-assets/43b42bd2cf70/d= isk-1c7873e3.raw.xz > > vmlinux: https://storage.googleapis.com/syzbot-assets/011ba1b9e8c1/vmli= nux-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 co= mmit: > > 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 [inl= ine] > > [] 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/l= egacy/raw_gadget.c:460 > > [] raw_ioctl+0x5f9/0x1120 drivers/usb/gadget/lega= cy/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 [inl= ine] > > [] 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/lega= cy/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 [inl= ine] > > [] 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/lega= cy/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 [inl= ine] > > [] 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/gadg= et/udc/dummy_hcd.c:665 > > [] usb_ep_alloc_request+0x22/0xd0 drivers/usb/gad= get/udc/core.c:196 > > [] gadget_bind+0x6d/0x370 drivers/usb/gadget/lega= cy/raw_gadget.c:292 > > [] gadget_bind_driver+0xe3/0x2e0 drivers/usb/gadg= et/udc/core.c:1591 > > [] call_driver_probe drivers/base/dd.c:579 [inlin= e] > > [] 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:1= 154 > > [] 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 dr= ivers/usb/gadget/udc/core.c:1665 > > [] raw_ioctl_run drivers/usb/gadget/legacy/raw_ga= dget.c:546 [inline] > > [] raw_ioctl+0x6f6/0x1120 drivers/usb/gadget/lega= cy/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 [inl= ine] > > [] 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 > > > --- 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. > - /* 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 Groups= "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/msgi= d/syzkaller-bugs/CALm%2B0cXi-YsnJBdBt38v4gEoR7oEeaoj3wXjEw3m%3D25RSLEs8g%40= mail.gmail.com.