Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3456035imc; Wed, 13 Mar 2019 19:30:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQQgJEjJXhTVs9I2FIXmjH4OT+JPSA5LQp7gH3UtpOoqK76wD1pF0ihYWaRTGjwmHgTgF1 X-Received: by 2002:aa7:838c:: with SMTP id u12mr46590542pfm.189.1552530609892; Wed, 13 Mar 2019 19:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552530609; cv=none; d=google.com; s=arc-20160816; b=bwTAbKOiw9RSPyUvl/y9z4GfBSQiOuorfQ0q3EYvd8IIbPx5YJT/sZUwB7B5v4f0LX e/oj4NUtbMybnbWO+I2HgRMr0dC2x6LFk8d9TO7fUxnpM+TKu4i6dydMi2bTEX6f+vPi uhimSHbLQbYvzv5cx9ZgZQXf865IFCjJEdFG5Dq6+AddV1u5aGbkbzVxOdalpKKQzbRb 2DzkQLpVsmMX5dFQWpYJEDBjADaZyrmCcEhS9dtB7UA/A5I4vsFl8KhCDl6w999rbZeC 7DSacyrP4/bcM0NdRpuhzXs8bIC9BWQjL/L4TNn+8QWwzZWxJ7UlE+42y4xrPblj3GqB MoYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:message-id:date:thread-index:thread-topic:subject :cc:to:from; bh=Z5rPTe+sUt5rr9R3bQyAsMwV6Z2iKlnwxzZxgYiBJ9U=; b=DXc3n0E30LL0+lA2h1gi3o30eXNQBV7HbgTLw8A9tfZVOEJ37xM2AUfSAOt01BZWmR CzzhawfozQgBJAFyE6oZAoFCMfxfQrz9rAvSeVnx1Sz/y73rFsX4cEELuxrHmtvNTNDA 21UrxIDnAzEOHrl3PNBsuiNYBkMHcC+WL5AsSzReziKddpcrI29Cbs6LizyaAZHOAxfK Tj2S7Z4pb8jSf9m3BkUFRMn5doPcP36lBhNMgUfPRQW8KEe7DiC/ddbwq4NWaWWpyNJX igztWmJIzXB2Hl6KJjLBMF6slTlPQ5VVlkg7B58GZNALdwnuEtCXkAoCR9y5ExwWHEPZ ps+Q== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j22si11415740pgg.463.2019.03.13.19.29.53; Wed, 13 Mar 2019 19:30:09 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726828AbfCNC32 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 13 Mar 2019 22:29:28 -0400 Received: from mga07.intel.com ([134.134.136.100]:32344 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726530AbfCNC31 (ORCPT ); Wed, 13 Mar 2019 22:29:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2019 19:29:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,476,1544515200"; d="scan'208";a="307050400" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga005.jf.intel.com with ESMTP; 13 Mar 2019 19:29:26 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 13 Mar 2019 19:29:26 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 13 Mar 2019 19:29:26 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.74]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.80]) with mapi id 14.03.0415.000; Thu, 14 Mar 2019 10:28:22 +0800 From: "He, Bo" To: "jikos@kernel.org" , "benjamin.tissoires@redhat.com" , "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "Zhang, Jun" , "Zhang, Yanmin" Subject: must hold the driver_input_lock in hid_debug_rdesc_show Thread-Topic: must hold the driver_input_lock in hid_debug_rdesc_show Thread-Index: AdTaDWtNLTEcOrQfQrCEZYJMmjpu/w== Date: Thu, 14 Mar 2019 02:28:21 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2VhMjBjY2EtZmY5Mi00MmZmLWE5ODctOTA0YWM0YzE4N2U1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSjlXSTViUnpvamk5bEVsa2xYWnBhUTdvUmsweG9CM0k3bzlGcGY3RWpIUTQrMUk2dkFJa1lxeG02cEZ4SlQ0bCJ9 dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org we see the below kernel panic logs when run suspend resume test with usb mouse and usb keyboard connected. the scenario is the userspace call the hid_debug_rdesc_show to dump the input device while the device is removed. the patch hold the driver_input_lock to avoid the race. [ 5381.757295] selinux: SELinux: Could not stat /sys/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/0003:03F0:0325.0320/input/input960/input960::scrolllock: No such file or directory. [ 5382.636498] BUG: unable to handle kernel paging request at 0000000783316040 [ 5382.651950] CPU: 1 PID: 1512 Comm: getevent Tainted: G U O 4.19.20-quilt-2e5dc0ac-00029-gc455a447dd55 #1 [ 5382.663797] RIP: 0010:hid_dump_device+0x9b/0x160 [ 5382.758853] Call Trace: [ 5382.761581] hid_debug_rdesc_show+0x72/0x1d0 [ 5382.766343] seq_read+0xe0/0x410 [ 5382.769941] full_proxy_read+0x5f/0x90 [ 5382.774121] __vfs_read+0x3a/0x170 [ 5382.788392] vfs_read+0xa0/0x150 [ 5382.791984] ksys_read+0x58/0xc0 [ 5382.801404] __x64_sys_read+0x1a/0x20 [ 5382.805483] do_syscall_64+0x55/0x110 [ 5382.809559] entry_SYSCALL_64_after_hwframe+0x49/0xbe Signed-off-by: he, bo Signed-off-by: "Zhang, Jun" --- drivers/hid/hid-debug.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index ebc9ffde41e9..a353a011fbdf 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c @@ -1060,10 +1060,15 @@ static int hid_debug_rdesc_show(struct seq_file *f, void *p) seq_printf(f, "\n\n"); /* dump parsed data and input mappings */ + if (down_interruptible(&hdev->driver_input_lock)) + return 0; + hid_dump_device(hdev, f); seq_printf(f, "\n"); hid_dump_input_mapping(hdev, f); + up(&hdev->driver_input_lock); + return 0; } -- 2.20.1