From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 890E6C433B4 for ; Thu, 8 Apr 2021 07:51:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 590BF61165 for ; Thu, 8 Apr 2021 07:51:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbhDHHvb (ORCPT ); Thu, 8 Apr 2021 03:51:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:58520 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhDHHva (ORCPT ); Thu, 8 Apr 2021 03:51:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D7AAEACC4; Thu, 8 Apr 2021 07:51:18 +0000 (UTC) Date: Thu, 08 Apr 2021 09:51:18 +0200 Message-ID: From: Takashi Iwai To: Ville =?UTF-8?B?U3lyasOkbMOk?= Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [Intel-gfx] [PATCH v2] drm/i915: Fix invalid access to ACPI _DSM objects In-Reply-To: References: <20210402082317.871-1-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 07 Apr 2021 23:28:48 +0200, Ville Syrjälä wrote: > > On Wed, Apr 07, 2021 at 06:56:15PM +0200, Takashi Iwai wrote: > > On Wed, 07 Apr 2021 18:34:46 +0200, > > Ville Syrjälä wrote: > > > > > > On Fri, Apr 02, 2021 at 10:23:17AM +0200, Takashi Iwai wrote: > > > > intel_dsm_platform_mux_info() tries to parse the ACPI package data > > > > from _DSM for the debug information, but it assumes the fixed format > > > > without checking what values are stored in the elements actually. > > > > When an unexpected value is returned from BIOS, it may lead to GPF or > > > > NULL dereference, as reported recently. > > > > > > > > Add the checks of the contents in the returned values and skip the > > > > values for invalid cases. > > > > > > > > v1->v2: Check the info contents before dereferencing, too > > > > > > > > BugLink: http://bugzilla.opensuse.org/show_bug.cgi?id=1184074 > > > > Cc: > > > > Signed-off-by: Takashi Iwai > > > > --- > > > > drivers/gpu/drm/i915/display/intel_acpi.c | 22 ++++++++++++++++++++-- > > > > 1 file changed, 20 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/drivers/gpu/drm/i915/display/intel_acpi.c b/drivers/gpu/drm/i915/display/intel_acpi.c > > > > index e21fb14d5e07..833d0c1be4f1 100644 > > > > --- a/drivers/gpu/drm/i915/display/intel_acpi.c > > > > +++ b/drivers/gpu/drm/i915/display/intel_acpi.c > > > > @@ -84,13 +84,31 @@ static void intel_dsm_platform_mux_info(acpi_handle dhandle) > > > > return; > > > > } > > > > > > > > + if (!pkg->package.count) { > > > > + DRM_DEBUG_DRIVER("no connection in _DSM\n"); > > > > + return; > > > > + } > > > > + > > > > connector_count = &pkg->package.elements[0]; > > > > DRM_DEBUG_DRIVER("MUX info connectors: %lld\n", > > > > (unsigned long long)connector_count->integer.value); > > > > for (i = 1; i < pkg->package.count; i++) { > > > > union acpi_object *obj = &pkg->package.elements[i]; > > > > - union acpi_object *connector_id = &obj->package.elements[0]; > > > > - union acpi_object *info = &obj->package.elements[1]; > > > > + union acpi_object *connector_id; > > > > + union acpi_object *info; > > > > + > > > > + if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count < 2) { > > > > + DRM_DEBUG_DRIVER("Invalid object for MUX #%d\n", i); > > > > + continue; > > > > + } > > > > + > > > > + connector_id = &obj->package.elements[0]; > > > > > > You don't want to check connector_id->type as well? > > > > I added only the minimal checks that may lead to Oops. > > OK. I guess misinterpreting something else as an integer isn't > particular dangerous in this case. > > Pushed to drm-intel-next. Thanks. Great, thanks! > Oh, could you ask the bug reporter to attach an acpidump to the > bug? Might be good to have that stuff on record somewhere if/when > someone wants to actually figure out what's going on here. OK, I'll ask. > That said, maybe we should just nuke this whole thing instead? > Unless I'm missing someting this code doesn't seem to actually > do anything... Yeah, that looks nothing but showing the debug information and that can be checked via acpidump output, too... Takashi