Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5525993pxb; Wed, 26 Jan 2022 14:09:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJw68mdIVSt4RJDiI83AUKW5Og63SvQAwj2BR+WVPFBDt41eAAJdp07jbfuDXSffLh/cbUBA X-Received: by 2002:aa7:df16:: with SMTP id c22mr950797edy.177.1643234969106; Wed, 26 Jan 2022 14:09:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643234969; cv=none; d=google.com; s=arc-20160816; b=ux4x4urBN8hNPj5LB5FyZQAAF+tdF+W11m9V4S/D0Qvbo5atjxWhG+6NobrcAsbEOm AGw50wy8mU1GQtjUsZSBFwnHyV8bGo4e0immBZFoCgXonNHtdpcriHn9z+vyb5nyAxt5 UoLSHnIodeW8oWOVk4VWm1vZbOpLKDskiY7h0160ocRbWLJtYu4UakLtRlDW213JeVOl KfVYcKmZZ8O9KXe1rr6Ku/cLb5IjtvbVq2SY2Cu2hMlH+5Ct6gmj3GF97ia9J+gFpMEz rm0dmJHgUUC6WpkHPoFxPDylpEo+H7qFzo08i+arpl4/H7lceew52kuqFTlB/B0rz24R I3rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=ucO1sywroR8yC1kKoTBiQwAGK1EFu2UMuTi0r7LNQIo=; b=jnKBwaYDgSG5Gs1uZWPT/8GFIUG2HffYmUzaalkeWN9NDKI3BwYzjNzoRQU7YLkz4A lAjFcud5b4Z/JVrNJR6XGdQZclasVDq9hh0/kJpH4vK1Kt4SDh5HEaPhaj27/Z2D3XxN YWx+xX3Qznwc/ntzrZalpyRLPOjobP9J8x7PoeMxdjgw4q/xk3+m0cE9q5e6UH8IvVUa 6epOvtxlFqngQA7kodfXo97BKVwPYpZf+98XnkExD6IONaqHz+IYfPiJX0W1ofNNXYho MldeYR8DVphK43gazqlHQ1m847g+ZGzd0xcf8H46MwQ6wZsIm6ZaXgPYsrPE930GuK8X cbgw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z66si245113ede.101.2022.01.26.14.09.03; Wed, 26 Jan 2022 14:09:29 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231784AbiAZPy5 (ORCPT + 99 others); Wed, 26 Jan 2022 10:54:57 -0500 Received: from mail-yb1-f169.google.com ([209.85.219.169]:43952 "EHLO mail-yb1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbiAZPyy (ORCPT ); Wed, 26 Jan 2022 10:54:54 -0500 Received: by mail-yb1-f169.google.com with SMTP id i10so53712ybt.10; Wed, 26 Jan 2022 07:54:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ucO1sywroR8yC1kKoTBiQwAGK1EFu2UMuTi0r7LNQIo=; b=fziYqRGxe2mG1ZQBaIrI4dqvqu2xaZcqoozdXk1EuSKGzLj/qG5NWyhXrKd4HE4TWP MdlwYrTVlp4ARgLbEkXef5Nr2VClr9jKCc5rq4docxUjFXlD3Fdnny6Z38bewzCeihyP njM6lo7JZpKKEKC7DKL5uy09xBLTY+7aqpFLpB3YhswjOjSV8Enzw2e0EWHtLLeqaMeQ zcRD4eAjHuP0his1DiotkNnZkgk9qjmQy9RMrvVJTYyUpqVjylOC29/s4DwCTLXcGeN6 gjZMy9Sq+dOGYbf+jrXfqqMc+sAQeJTCWOiYxq0fKshTlPKK+z1kLb1Dvt5VP1IoCdaL SJKA== X-Gm-Message-State: AOAM530rASM3sd1KM/4adU6LpLBYFManprB7QJUICNWEL1kmyR6yTbJq 3dhHyWSqaMRtrI2Q+6WfVqsMyfjL6Ut3iUsvtD0= X-Received: by 2002:a25:3793:: with SMTP id e141mr36739114yba.624.1643212494095; Wed, 26 Jan 2022 07:54:54 -0800 (PST) MIME-Version: 1.0 References: <20220123091004.763775-1-ztong0001@gmail.com> <6a0233cd-d931-8a36-3b9e-08b774cec7b0@redhat.com> In-Reply-To: <6a0233cd-d931-8a36-3b9e-08b774cec7b0@redhat.com> From: "Rafael J. Wysocki" Date: Wed, 26 Jan 2022 16:54:43 +0100 Message-ID: Subject: Re: acpi_get_devices() crash when acpi_disabled==true (was [PATCH v2] drm/privacy-screen: honor acpi=off in detect_thinkpad_privacy_screen) To: Hans de Goede Cc: Tong Zhang , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel , Linux Kernel Mailing List , "Rafael J. Wysocki" , linux-acpi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 26, 2022 at 2:47 PM Hans de Goede wrote: > > Hi All, > > On 1/23/22 10:10, Tong Zhang wrote: > > when acpi=off is provided in bootarg, kernel crash with > > > > [ 1.252739] BUG: kernel NULL pointer dereference, address: 0000000000000018 > > [ 1.258308] Call Trace: > > [ 1.258490] ? acpi_walk_namespace+0x147/0x147 > > [ 1.258770] acpi_get_devices+0xe4/0x137 > > [ 1.258921] ? drm_core_init+0xc0/0xc0 [drm] > > [ 1.259108] detect_thinkpad_privacy_screen+0x5e/0xa8 [drm] > > [ 1.259337] drm_privacy_screen_lookup_init+0xe/0xe85 [drm] > > > > The reason is that acpi_walk_namespace expects acpi related stuff > > initialized but in fact it wouldn't when acpi is set to off. In this case > > we should honor acpi=off in detect_thinkpad_privacy_screen(). > > > > Signed-off-by: Tong Zhang > > Thank you for catching this and thank you for your patch. I was about to merge > this, but then I realized that this might not be the best way to fix this. > > A quick grep shows 10 acpi_get_devices() calls outside of drivers/acpi, > and at a first glance about half of those are missing an acpi_disabled > check. IMHO it would be better to simply add an acpi_disabled check to > acpi_get_devices() itself. > > Rafael, do you agree ? Yes, I do. > Note the just added chrome privacy-screen check uses > acpi_dev_present(), this is also used in about 10 places outside > of drivers/acpi and AFAIK none of those do an acpi_disabled check. > > acpi_dev_present() uses bus_find_device(&acpi_bus_type, ...) > but the acpi_bus_type does not get registered when acpi_disabled > is set. In the end this is fine though since bus_find_device > checks for the bus not being registered and then just returns > NULL. Right. > > --- > > v2: fix typo in previous commit -- my keyboard is eating letters > > > > drivers/gpu/drm/drm_privacy_screen_x86.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/gpu/drm/drm_privacy_screen_x86.c b/drivers/gpu/drm/drm_privacy_screen_x86.c > > index a2cafb294ca6..e7aa74ad0b24 100644 > > --- a/drivers/gpu/drm/drm_privacy_screen_x86.c > > +++ b/drivers/gpu/drm/drm_privacy_screen_x86.c > > @@ -33,6 +33,9 @@ static bool __init detect_thinkpad_privacy_screen(void) > > unsigned long long output; > > acpi_status status; > > > > + if (acpi_disabled) > > + return false; > > + > > /* Get embedded-controller handle */ > > status = acpi_get_devices("PNP0C09", acpi_set_handle, NULL, &ec_handle); > > if (ACPI_FAILURE(status) || !ec_handle) >