Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2962582imu; Mon, 19 Nov 2018 08:41:10 -0800 (PST) X-Google-Smtp-Source: AJdET5dy1mXnCwIfgcIOOlVZibBmKnyMTD48ZLg64Wd2XmV/uYcSKGYf300DagphAxWHV3CfK9tg X-Received: by 2002:a63:6302:: with SMTP id x2mr20634355pgb.183.1542645670633; Mon, 19 Nov 2018 08:41:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542645670; cv=none; d=google.com; s=arc-20160816; b=XwnxO66O7HwG7KzotWNzb9poJ/t3byNt0szaR26vPmJF2/d1DXeebecLRVW8oEnfF1 pyHFbIYYYlu9uMZ/i+caYakIz7yKIODSCgvmD834G+p9lMWR3LieCqKfpIw1TDgXPATn YNFDNjv6dcWY4X/2XHlVvU16z3Xo4e+eR7nocI+8rEpcw0JZyuThgGNFnBQglWjUC2qg rYca7394+/cUDHzt4HYjnFJnmHmE+14JbdoPDaoET3oIXbbWtHK3iRFCuGZbW10H90yv 7YYUSAf+2NYiY1oWlGCWW+W4TinkouQqiY9AWIVvGih+7jzBBrxW87MkTK9X7N9pfNCS Bi5g== 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=tO3c192CxUJaKtTQZVs9M90V6n3kFsgtTAo+q1CSlOM=; b=Hiu6yQDvZ310nPtWjmhBmASejZ2QdxFBjDn1vL7ZB6OxJCkWqqd0IJpbNrrOzgymD1 2Kt7YipZ+/ACG2WOX1Fp8uK7Pw2ynHvxBIZkgfg79R0BPlELO/sSE1WkrxCI7ZoGPfnw TthTg3GrqmOvwovhPJX7hF59KjcjFw/dUWm+Xd3JUsrZh0Adl3bOtcO9Ha13az2wLg3N 5jupujSez+tH4/3wed5+2EEdbF42YtfOhwZzj/gsqNfvNs7GKWb4+vMWAziD4syJ/raC aAdh5LcY2UXwdenMxhMAZd/yrrdqJeyj3JCMtO5bJ7mYNm0jT0CgIC2sKCIXa/W+us17 vZZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f01fmPCN; 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 e11si34780194pgf.450.2018.11.19.08.40.56; Mon, 19 Nov 2018 08:41:10 -0800 (PST) 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=f01fmPCN; 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 S1732635AbeKTDDN (ORCPT + 99 others); Mon, 19 Nov 2018 22:03:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:35722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732106AbeKTDDM (ORCPT ); Mon, 19 Nov 2018 22:03:12 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 8C7022147D; Mon, 19 Nov 2018 16:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645543; bh=BcIX7rVgzF17vZvDpFfawKdOiiBmwEykamPmfUtHCAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f01fmPCNtheaiQl1WMGlyDWHRqdJ8+KIA9RfEZ0dTmQk8kal2zbapXrVdbqVdCFgy +HsUAXiSe0RhGCrVxyaN2ijLF7dSYYX5vbstqtbO161s1B+t24vYYDQl+QAfFr/a0z LBOHcXMkcUpyP8Qfv8XnSkJZGSZAOTB2WEyyBYA8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lyude Paul , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Rodrigo Vivi , Joonas Lahtinen Subject: [PATCH 4.19 203/205] drm/i915: Fix NULL deref when re-enabling HPD IRQs on systems with MST Date: Mon, 19 Nov 2018 17:28:30 +0100 Message-Id: <20181119162642.844402422@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lyude Paul commit 541ff7e96c13cd5d67f6021d233f8e1c3df49278 upstream. Turns out that if you trigger an HPD storm on a system that has an MST topology connected to it, you'll end up causing the kernel to eventually hit a NULL deref: [ 332.339041] BUG: unable to handle kernel NULL pointer dereference at 00000000000000ec [ 332.340906] PGD 0 P4D 0 [ 332.342750] Oops: 0000 [#1] SMP PTI [ 332.344579] CPU: 2 PID: 25 Comm: kworker/2:0 Kdump: loaded Tainted: G O 4.18.0-rc3short-hpd-storm+ #2 [ 332.346453] Hardware name: LENOVO 20BWS1KY00/20BWS1KY00, BIOS JBET71WW (1.35 ) 09/14/2018 [ 332.348361] Workqueue: events intel_hpd_irq_storm_reenable_work [i915] [ 332.350301] RIP: 0010:intel_hpd_irq_storm_reenable_work.cold.3+0x2f/0x86 [i915] [ 332.352213] Code: 00 00 ba e8 00 00 00 48 c7 c6 c0 aa 5f a0 48 c7 c7 d0 73 62 a0 4c 89 c1 4c 89 04 24 e8 7f f5 af e0 4c 8b 04 24 44 89 f8 29 e8 <41> 39 80 ec 00 00 00 0f 85 43 13 fc ff 41 0f b6 86 b8 04 00 00 41 [ 332.354286] RSP: 0018:ffffc90000147e48 EFLAGS: 00010006 [ 332.356344] RAX: 0000000000000005 RBX: ffff8802c226c9d4 RCX: 0000000000000006 [ 332.358404] RDX: 0000000000000000 RSI: 0000000000000082 RDI: ffff88032dc95570 [ 332.360466] RBP: 0000000000000005 R08: 0000000000000000 R09: ffff88031b3dc840 [ 332.362528] R10: 0000000000000000 R11: 000000031a069602 R12: ffff8802c226ca20 [ 332.364575] R13: ffff8802c2268000 R14: ffff880310661000 R15: 000000000000000a [ 332.366615] FS: 0000000000000000(0000) GS:ffff88032dc80000(0000) knlGS:0000000000000000 [ 332.368658] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 332.370690] CR2: 00000000000000ec CR3: 000000000200a003 CR4: 00000000003606e0 [ 332.372724] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 332.374773] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 332.376798] Call Trace: [ 332.378809] process_one_work+0x1a1/0x350 [ 332.380806] worker_thread+0x30/0x380 [ 332.382777] ? wq_update_unbound_numa+0x10/0x10 [ 332.384772] kthread+0x112/0x130 [ 332.386740] ? kthread_create_worker_on_cpu+0x70/0x70 [ 332.388706] ret_from_fork+0x35/0x40 [ 332.390651] Modules linked in: i915(O) vfat fat joydev btusb btrtl btbcm btintel bluetooth ecdh_generic iTCO_wdt wmi_bmof i2c_algo_bit drm_kms_helper intel_rapl syscopyarea sysfillrect x86_pkg_temp_thermal sysimgblt coretemp fb_sys_fops crc32_pclmul drm psmouse pcspkr mei_me mei i2c_i801 lpc_ich mfd_core i2c_core tpm_tis tpm_tis_core thinkpad_acpi wmi tpm rfkill video crc32c_intel serio_raw ehci_pci xhci_pci ehci_hcd xhci_hcd [last unloaded: i915] [ 332.394963] CR2: 00000000000000ec This appears to be due to the fact that with an MST topology, not all intel_connector structs will have ->encoder set. So, fix this by skipping connectors without encoders in intel_hpd_irq_storm_reenable_work(). For those wondering, this bug was found on accident while simulating HPD storms using a Chamelium connected to a ThinkPad T450s (Broadwell). Changes since v1: - Check intel_connector->mst_port instead of intel_connector->encoder Signed-off-by: Lyude Paul Reviewed-by: Ville Syrjälä Cc: stable@vger.kernel.org Cc: Rodrigo Vivi Link: https://patchwork.freedesktop.org/patch/msgid/20181106213017.14563-3-lyude@redhat.com (cherry picked from commit fee61deecb1d850bf34f682a6a452e5ee51b7572) Signed-off-by: Joonas Lahtinen Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/intel_hotplug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/intel_hotplug.c +++ b/drivers/gpu/drm/i915/intel_hotplug.c @@ -228,7 +228,9 @@ static void intel_hpd_irq_storm_reenable drm_for_each_connector_iter(connector, &conn_iter) { struct intel_connector *intel_connector = to_intel_connector(connector); - if (intel_connector->encoder->hpd_pin == pin) { + /* Don't check MST ports, they don't have pins */ + if (!intel_connector->mst_port && + intel_connector->encoder->hpd_pin == pin) { if (connector->polled != intel_connector->polled) DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n", connector->name);