Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5551800pxb; Mon, 14 Feb 2022 01:39:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxI8qgcru1LvmbFUSDGbBKIEGgv8hK1YFWt2kEFFACxFtF40aaE4MXk3+uvD5MrCrojee2M X-Received: by 2002:a17:903:11d0:: with SMTP id q16mr13296663plh.134.1644831592413; Mon, 14 Feb 2022 01:39:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644831592; cv=none; d=google.com; s=arc-20160816; b=Xzx9DgEwFULagnuX9Do90qpyw6SSCeFvsAZYvXcDXI4qeXqzr+azKephdpq6hWIFH8 7WjhHYVBT7zKb3Xzg1pyG/UMQvc+H60/4QNyxnR4bX7DexHuLuIzNCFAVOV25oSlapdr cQki/hqiEyiMsjBb1Dog4OuQ246TNI1AIHVYZ4XHtvtzbIfN5uG4KN9l21DRsgj2Nc2s D+ja1L2Ly9+mT9aEXZtwe+si9TWqvNhsflOUdvBTkgPihrkxHCa6WEXAhOAS+gLWr/MD vM8KUC9QtO/2XweIZpT2ho6HyhL38v6QB/+d8KDBIC3vH/BnRuRZTMqMeuSYurML3FFT G67Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=RvyT6B/T5DUhviORvFtOZuFNGuWnq6/yP0oV+FPDl10=; b=JxLRF+RdvXKJYTBu1nRnrJmqcbj7f5+eWgufCBZpzemol4LUlv9k9I0dRrvoquPluS CNjNozT2xz5G7iKx9gqhfC+BLOjiL3n65BWBRxZz4XH9fyzYSt4Dl4IXvn8Ep38kKOaE zzzxPEiaivvabViYM47zttoRzjJSNmfEjkoR7H4XzWFxuKjm4MdYs39BGovVK2+XEF+N Ee+ksZwyLNxnjdgNuWzXoXWWGYL4TKCRW363F/j5Xuw55Nd+GRC1CocrxxSBaMWpH/Ws Z9nER6oFVSQIOaWhX3vWzvvN5om2WRE7f40lqYGltn09mBzlZHa9Yoic2Yu8+vy7+KlE ojMw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g18si12283898pgj.522.2022.02.14.01.39.40; Mon, 14 Feb 2022 01:39:52 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353731AbiBKVXu (ORCPT + 93 others); Fri, 11 Feb 2022 16:23:50 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353697AbiBKVXt (ORCPT ); Fri, 11 Feb 2022 16:23:49 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 4C698C5C for ; Fri, 11 Feb 2022 13:23:47 -0800 (PST) Received: (qmail 646920 invoked by uid 1000); 11 Feb 2022 16:23:46 -0500 Date: Fri, 11 Feb 2022 16:23:46 -0500 From: Alan Stern To: syzbot Cc: gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com, Jiri Kosina , Benjamin Tissoires , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-input@vger.kernel.org, noralf@tronnes.org, syzkaller-bugs@googlegroups.com, tzimmermann@suse.de Subject: Re: [syzbot] memory leak in hub_event (3) Message-ID: References: <0000000000005cacef05d7c3c10d@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0000000000005cacef05d7c3c10d@google.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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, Feb 11, 2022 at 12:17:26PM -0800, syzbot wrote: > Hello, > > syzbot found the following issue on: > > HEAD commit: dfd42facf1e4 Linux 5.17-rc3 > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=14b4ef7c700000 > kernel config: https://syzkaller.appspot.com/x/.config?x=48b71604a367da6e > dashboard link: https://syzkaller.appspot.com/bug?extid=8caaaec4e7a55d75e243 > 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=1396902c700000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1466e662700000 > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+8caaaec4e7a55d75e243@syzkaller.appspotmail.com > > BUG: memory leak > unreferenced object 0xffff88810d49e800 (size 2048): > comm "kworker/1:1", pid 25, jiffies 4294954629 (age 16.460s) > hex dump (first 32 bytes): > ff ff ff ff 31 00 00 00 00 00 00 00 00 00 00 00 ....1........... > 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 ................ > backtrace: > [] kmalloc include/linux/slab.h:581 [inline] > [] kzalloc include/linux/slab.h:715 [inline] > [] usb_alloc_dev+0x32/0x450 drivers/usb/core/usb.c:582 > [] hub_port_connect drivers/usb/core/hub.c:5260 [inline] > [] hub_port_connect_change drivers/usb/core/hub.c:5502 [inline] > [] port_event drivers/usb/core/hub.c:5660 [inline] > [] hub_event+0x1097/0x21a0 drivers/usb/core/hub.c:5742 > [] process_one_work+0x2bf/0x600 kernel/workqueue.c:2307 > [] worker_thread+0x59/0x5b0 kernel/workqueue.c:2454 > [] kthread+0x125/0x160 kernel/kthread.c:377 > [] ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 There's a refcount leak in the probe-failure path of the hid-elo driver. (You can see that this is the relevant driver in the console output.) It doesn't need the refcount anyway, because the elo_priv structure is always deallocated synchronously before the elo_remove routine returns. (Syzbot isn't always all that great at deducing where the real problem lies when something goes wrong.) Alan Stern #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ v5.17-rc3 Index: usb-devel/drivers/hid/hid-elo.c =================================================================== --- usb-devel.orig/drivers/hid/hid-elo.c +++ usb-devel/drivers/hid/hid-elo.c @@ -239,7 +239,7 @@ static int elo_probe(struct hid_device * INIT_DELAYED_WORK(&priv->work, elo_work); udev = interface_to_usbdev(to_usb_interface(hdev->dev.parent)); - priv->usbdev = usb_get_dev(udev); + priv->usbdev = udev; hid_set_drvdata(hdev, priv); @@ -270,8 +270,6 @@ static void elo_remove(struct hid_device { struct elo_priv *priv = hid_get_drvdata(hdev); - usb_put_dev(priv->usbdev); - hid_hw_stop(hdev); cancel_delayed_work_sync(&priv->work); kfree(priv);