Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp524986pxb; Wed, 3 Mar 2021 08:52:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdty9RhPpIdsGd2R5JID3WjM7zBQtqfJbVoh66lDex1nUSf3OJUq1uROLEFNv4Ifu1WsRw X-Received: by 2002:a17:906:bfcc:: with SMTP id us12mr4591887ejb.266.1614790365214; Wed, 03 Mar 2021 08:52:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614790365; cv=none; d=google.com; s=arc-20160816; b=iwpTNfvK026kDXBnG41fxoh4/yiIJFbSM4hFvutjdbX9Ccnnc2dUiaQlcUVlABwjMz yB/wGarB83zOkQnv8wz1TItmsJaDGq+/I6OjgGpJW/qXls/e9WdKIDZ0o1BcXAVJaait NinTUZ6pM40hDHXqgNUa9l204ydPLXeO4ZSgD9B+d//GHYs4IS63ghIO8b/7ASb439vl 4gR9/PxsjV6OJb1AN7fd2zx0TyGdepu2EPo08WD+F4q0frC4nhQr/7TVZnvcR7m+czLp SvGah8olo51YUDQMoeVyExsUbmP/pO7GGJloPhAFT3u5+Qz/d9h+/z8nligChgcJrbgu Zu/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=momiDqzOfbO/nPMwwOE8f1F1qE/D6u1HMIDvSv3mlQ0=; b=KvMSPXBtSByDO7GS/y4YxP/zR+ytlF/uSI5J5yYCeWJJqO3dpxt5Py95JLgCOacW7A p8K7BZtCs2TLlbN3J3z7J2DwFWNB5kIqrb5mQVR9ceOR7Hys4WbXyqDg8+MiE/rIa06U Zz5JMaoozxSV3Ba5wFPkcxyE1Mnuh5OLuXthQqBPqFLYCJ8J/8qzr1bqVPM5Ew+eWkws MONABhQAXcfOq5RIfH2UVmt+/CbxT/ZgLdbcHj0FrlinFooJDPXDfVDFWyqrbcU2PISi uYYo5n+uZ9b5uctjPnIEgm9ty8pLQBOg/cio1xmUF+5JXo/0JTBXych18fXsUyV7uXWx T15Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cwB8cZRe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r18si15686162eds.390.2021.03.03.08.52.01; Wed, 03 Mar 2021 08:52:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cwB8cZRe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347918AbhCBAVi (ORCPT + 99 others); Mon, 1 Mar 2021 19:21:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:41508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233019AbhCAS0J (ORCPT ); Mon, 1 Mar 2021 13:26:09 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 586D265227; Mon, 1 Mar 2021 17:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619510; bh=upBw5AdhJq8rnQs+7k6VyJ4fcKb+oB1WjUncSlyNNPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cwB8cZRedwFHgH9yJPqbHbeXuVJX1cpohL45F2+YdFJRg7FO7WtbJ8SxYg1mHJSIk YP4PpuCjr1PtQPaFgBpQqRRO2pUpefWzzpwuc7dF5UFyCX1ea4Vtzm1GED08Lp9QCT FyzgmFAKwbuFk2Hrc0inFBn0WM5+2eW77fU9Uvj4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Marcin=20=C5=9Alusarz?= , Pierre-Louis Bossart , "Rafael J. Wysocki" , Vinod Koul Subject: [PATCH 5.10 480/663] soundwire: intel: fix possible crash when no device is detected Date: Mon, 1 Mar 2021 17:12:08 +0100 Message-Id: <20210301161205.609735455@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marcin Ślusarz commit 957e3f797917b36355766807b1d8a54a1ba0cfc9 upstream. acpi_walk_namespace can return success without executing our callback which initializes info->handle. If the random value in this structure is a valid address (which is on the stack, so it's quite possible), then nothing bad will happen, because: sdw_intel_scan_controller -> acpi_bus_get_device -> acpi_get_device_data -> acpi_get_data_full -> acpi_ns_validate_handle will reject this handle. However, if the value from the stack doesn't point to a valid address, we get this: BUG: kernel NULL pointer dereference, address: 0000000000000050 PGD 0 P4D 0 Oops: 0000 [#1] SMP NOPTI CPU: 6 PID: 472 Comm: systemd-udevd Tainted: G W 5.10.0-1-amd64 #1 Debian 5.10.4-1 Hardware name: HP HP Pavilion Laptop 15-cs3xxx/86E2, BIOS F.05 01/01/2020 RIP: 0010:acpi_ns_validate_handle+0x1a/0x23 Code: 00 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 0f 1f 44 00 00 48 8d 57 ff 48 89 f8 48 83 fa fd 76 08 48 8b 05 0c b8 67 01 c3 <80> 7f 08 0f 74 02 31 c0 c3 0f 1f 44 00 00 48 8b 3d f6 b7 67 01 e8 RSP: 0000:ffffc388807c7b20 EFLAGS: 00010213 RAX: 0000000000000048 RBX: ffffc388807c7b70 RCX: 0000000000000000 RDX: 0000000000000047 RSI: 0000000000000246 RDI: 0000000000000048 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: ffffffffc0f5f4d1 R11: ffffffff8f0cb268 R12: 0000000000001001 R13: ffffffff8e33b160 R14: 0000000000000048 R15: 0000000000000000 FS: 00007f24548288c0(0000) GS:ffff9f781fb80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000050 CR3: 0000000106158004 CR4: 0000000000770ee0 PKRU: 55555554 Call Trace: acpi_get_data_full+0x4d/0x92 acpi_bus_get_device+0x1f/0x40 sdw_intel_acpi_scan+0x59/0x230 [soundwire_intel] ? strstr+0x22/0x60 ? dmi_matches+0x76/0xe0 snd_intel_dsp_driver_probe.cold+0xaf/0x163 [snd_intel_dspcfg] azx_probe+0x7a/0x970 [snd_hda_intel] local_pci_probe+0x42/0x80 ? _cond_resched+0x16/0x40 pci_device_probe+0xfd/0x1b0 really_probe+0x205/0x460 driver_probe_device+0xe1/0x150 device_driver_attach+0xa1/0xb0 __driver_attach+0x8a/0x150 ? device_driver_attach+0xb0/0xb0 ? device_driver_attach+0xb0/0xb0 bus_for_each_dev+0x78/0xc0 bus_add_driver+0x12b/0x1e0 driver_register+0x8b/0xe0 ? 0xffffffffc0f65000 do_one_initcall+0x44/0x1d0 ? do_init_module+0x23/0x250 ? kmem_cache_alloc_trace+0xf5/0x200 do_init_module+0x5c/0x250 __do_sys_finit_module+0xb1/0x110 do_syscall_64+0x33/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Signed-off-by: Marcin Ślusarz Reviewed-by: Pierre-Louis Bossart Reviewed-by: Rafael J. Wysocki CC: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210208120104.204761-1-marcin.slusarz@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/soundwire/intel_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/soundwire/intel_init.c +++ b/drivers/soundwire/intel_init.c @@ -405,11 +405,12 @@ int sdw_intel_acpi_scan(acpi_handle *par { acpi_status status; + info->handle = NULL; status = acpi_walk_namespace(ACPI_TYPE_DEVICE, parent_handle, 1, sdw_intel_acpi_cb, NULL, info, NULL); - if (ACPI_FAILURE(status)) + if (ACPI_FAILURE(status) || info->handle == NULL) return -ENODEV; return sdw_intel_scan_controller(info);