Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5849810ybn; Sun, 29 Sep 2019 07:03:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1tN4Vt8paUE5jjxLX7kCEfMKaBIuOqxs6jR3Bsopz+swBt6lMwmsNEBW3DK3k7T/KnPwQ X-Received: by 2002:a17:906:80c3:: with SMTP id a3mr15216992ejx.271.1569765816216; Sun, 29 Sep 2019 07:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569765816; cv=none; d=google.com; s=arc-20160816; b=uyCCQ2gQeF4dUqmmqqyUgE3OS0DcA5HOL9fBFO/2ED9H0UqAreP0g0VSzsViJIpJm3 eGFbqDiHgXYlAQJ5vkmoAx+Pip1GCAbltSpwqA0EgeY7lNbNH1TYNZxKALd5/xyHJ4Tk Kk/K9WHFEDuL6fhSPEZoJj/Wn9GQw0QkL+0ThgFShP7+T0xwR5WQ+J+8AyyVIrWSgS0a UzsBFcoq9Js9UselTcgN1mMo68xuzHc2CNYZ8cVEsb4qsFCjd+mG60xAmsAkvClhUhuw jrOGMCX5T0QqzIvfHUfQSXf0wqmdxWZ1LVFUfGvR5SJkMWOD6veyWggmQrEjNksqc7zl igOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=q9UzSgyf9+01GoTR6keu5MIo7Z2zvLmPYi48mG8N9FQ=; b=hJ9fxdU8Txerlj/MTRjSmN/gfUV7Qij0Bchw/+qS14cMGqg80BgZ76tjRqfa3zPkDR JzX35Pdfcl8vQbjAwhBlvTBFsKuICh40guj+PoMppxX8cp3iAUHTdq9k4A2UMkuqBJ7r J42kv5Y7PZ2apO9/+G1oYbrL33/jz9DWNPSxQlUL0Oyp4SIBq7s6dvJICk7lBQ925mYI ukPqQqASIah4vwRxKZkZPTXKq7vBlyWeFhEW5H0wA0aFK9JwGya/yscX/J+GNmTYZKk8 qOphrM+HXFWKAcLoYy0CgEpOTslqSIIG/WwEZBucRb30NxWbjEic7crcp1yQns4TfmNZ 8LxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="lUfDc/KE"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si5665292edc.75.2019.09.29.07.03.11; Sun, 29 Sep 2019 07:03:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="lUfDc/KE"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729947AbfI2OAi (ORCPT + 99 others); Sun, 29 Sep 2019 10:00:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:42410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729925AbfI2OAe (ORCPT ); Sun, 29 Sep 2019 10:00:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1D44521925; Sun, 29 Sep 2019 14:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765633; bh=+T1PPjQH2Nuw1jEtXiijYKSa4p8205QbCW+QFj3xMgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lUfDc/KEPs1/tRM+ImNtshY3fHFWM/4JNzzBK65LU+gpjVng6Sl90OVpyHNhDlmnM o5N8uy9IEwo/gLlt9UxvFds49afccSMZnOZ7nw9zuJc9w4EzggtMstL/9zUD9sGh/W ov1ikmnoQGVemXrz8rJuDAz29KN7tyAaTN1auD+w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Jiri Kosina , syzbot+3cbe5cd105d2ad56a1df@syzkaller.appspotmail.com Subject: [PATCH 5.2 14/45] HID: logitech: Fix general protection fault caused by Logitech driver Date: Sun, 29 Sep 2019 15:55:42 +0200 Message-Id: <20190929135028.354392044@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135024.387033930@linuxfoundation.org> References: <20190929135024.387033930@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alan Stern commit 5f9242775bb61f390f0885f23fc16397262c7538 upstream. The syzbot fuzzer found a general protection fault in the HID subsystem: 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 CPU: 0 PID: 3715 Comm: syz-executor.3 Not tainted 5.2.0-rc6+ #15 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:__pm_runtime_resume+0x49/0x180 drivers/base/power/runtime.c:1069 Code: ed 74 d5 fe 45 85 ed 0f 85 9a 00 00 00 e8 6f 73 d5 fe 48 8d bd c1 02 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48 89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 fe 00 00 00 RSP: 0018:ffff8881d99d78e0 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000020 RCX: ffffc90003f3f000 RDX: 0000000416d8686d RSI: ffffffff82676841 RDI: 00000020b6c3436a RBP: 00000020b6c340a9 R08: ffff8881c6d64800 R09: fffffbfff0e84c25 R10: ffff8881d99d7940 R11: ffffffff87426127 R12: 0000000000000004 R13: 0000000000000000 R14: ffff8881d9b94000 R15: ffffffff897f9048 FS: 00007f047f542700(0000) GS:ffff8881db200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b30f21000 CR3: 00000001ca032000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: pm_runtime_get_sync include/linux/pm_runtime.h:226 [inline] usb_autopm_get_interface+0x1b/0x50 drivers/usb/core/driver.c:1707 usbhid_power+0x7c/0xe0 drivers/hid/usbhid/hid-core.c:1234 hid_hw_power include/linux/hid.h:1038 [inline] hidraw_open+0x20d/0x740 drivers/hid/hidraw.c:282 chrdev_open+0x219/0x5c0 fs/char_dev.c:413 do_dentry_open+0x497/0x1040 fs/open.c:778 do_last fs/namei.c:3416 [inline] path_openat+0x1430/0x3ff0 fs/namei.c:3533 do_filp_open+0x1a1/0x280 fs/namei.c:3563 do_sys_open+0x3c0/0x580 fs/open.c:1070 do_syscall_64+0xb7/0x560 arch/x86/entry/common.c:301 entry_SYSCALL_64_after_hwframe+0x49/0xbe It turns out the fault was caused by a bug in the HID Logitech driver, which violates the requirement that every pathway calling hid_hw_start() must also call hid_hw_stop(). This patch fixes the bug by making sure the requirement is met. Reported-and-tested-by: syzbot+3cbe5cd105d2ad56a1df@syzkaller.appspotmail.com Signed-off-by: Alan Stern CC: Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-lg.c | 10 ++++++---- drivers/hid/hid-lg4ff.c | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) --- a/drivers/hid/hid-lg.c +++ b/drivers/hid/hid-lg.c @@ -818,7 +818,7 @@ static int lg_probe(struct hid_device *h if (!buf) { ret = -ENOMEM; - goto err_free; + goto err_stop; } ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf), @@ -850,9 +850,12 @@ static int lg_probe(struct hid_device *h ret = lg4ff_init(hdev); if (ret) - goto err_free; + goto err_stop; return 0; + +err_stop: + hid_hw_stop(hdev); err_free: kfree(drv_data); return ret; @@ -863,8 +866,7 @@ static void lg_remove(struct hid_device struct lg_drv_data *drv_data = hid_get_drvdata(hdev); if (drv_data->quirks & LG_FF4) lg4ff_deinit(hdev); - else - hid_hw_stop(hdev); + hid_hw_stop(hdev); kfree(drv_data); } --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c @@ -1477,7 +1477,6 @@ int lg4ff_deinit(struct hid_device *hid) } } #endif - hid_hw_stop(hid); drv_data->device_props = NULL; kfree(entry);