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.8 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 63E07C43460 for ; Wed, 7 Apr 2021 16:56:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B5486120E for ; Wed, 7 Apr 2021 16:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347774AbhDGQ4h (ORCPT ); Wed, 7 Apr 2021 12:56:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:54934 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354404AbhDGQ4c (ORCPT ); Wed, 7 Apr 2021 12:56:32 -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 9DF10AD41; Wed, 7 Apr 2021 16:56:15 +0000 (UTC) Date: Wed, 07 Apr 2021 18:56:15 +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 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. Takashi > > > + info = &obj->package.elements[1]; > > + if (info->type != ACPI_TYPE_BUFFER || info->buffer.length < 4) { > > + DRM_DEBUG_DRIVER("Invalid info for MUX obj #%d\n", i); > > + continue; > > + } > > + > > DRM_DEBUG_DRIVER("Connector id: 0x%016llx\n", > > (unsigned long long)connector_id->integer.value); > > DRM_DEBUG_DRIVER(" port id: %s\n", > > -- > > 2.26.2 > > > > _______________________________________________ > > Intel-gfx mailing list > > Intel-gfx@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx > > -- > Ville Syrjälä > Intel >