Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp920827pxf; Wed, 7 Apr 2021 15:06:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze63YndJ3Nefl3bPN8VG7zq9aXmdwBTUNEME3yLRRkwgnDDg9fFkUoIznYqJVMzZwZO1V7 X-Received: by 2002:a17:90b:196:: with SMTP id t22mr5100146pjs.44.1617833187230; Wed, 07 Apr 2021 15:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617833187; cv=none; d=google.com; s=arc-20160816; b=O6wSfxTaQmGs4pduSwfKqZNZc5kOWOMhlEFs6vDXDMo8HmU25E4zqJ5EIyYN9KLtZ9 AT5RN8n1zSy6lViXSBna2PeeRVw3cZyg8AXRR6cNOXOVQCQ5UXqrzZw1txRYDjSuKpKc Q9TPTUV9OcOUd60mlnPn+XnPjeqkxz/Fbs3RkIH5C2tZHoa98rS1RL4Qp7nxPmMKv0kI HOMOAnRupCLf1SEZoeDY6MrXbX6TS4paehMtngkgjYgCgBIy7bWnzuiFlNNay/p51+Io +ncR7FhgpOlIx9BdROYpDi7zNrPFAl40xo9DlTbIK9iNXCJwxGJEO2RGzJmBF9dp2OYP FXGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=oiuVRGFYPFbygStah76fhHCJD3nLsb1u+x3CJbNrfU8=; b=LemQB2hfjXgAM/9eDDrP0+ghWxN4nWFCu7uhzG2dQfK6tRbCL0x2fB6mHldLEfMwLl wB7kbKmPplEaxuJb/EfCsswtKV3HAJA3TWAuT4oeyHDDvdjFnj2GF1i3Rgb7d87Nj78u Fv6otx0+sAkU04c8x496MRS3623RIPsLogTHp1WHGrYWJNlAwqMGgtr41EnEBNj43Kyu fYABt1GYgp/4xaVsqY8Lxv7LKafavv1GjkZCtbs+fOWSyRkj7L7tSgFJBfsa2ATgw0WS YLtxJqKgLc2TamD50fXneR6kK3gQAjKbKpgr5lUTiumed6qORFzO2nGKy1OV/GSjgnOQ asPA== 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si27845180pls.90.2021.04.07.15.06.14; Wed, 07 Apr 2021 15:06:27 -0700 (PDT) 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233174AbhDGV3G (ORCPT + 99 others); Wed, 7 Apr 2021 17:29:06 -0400 Received: from mga06.intel.com ([134.134.136.31]:7164 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232762AbhDGV3G (ORCPT ); Wed, 7 Apr 2021 17:29:06 -0400 IronPort-SDR: IFW3DBuIPxtFyzpq727AuuvLUSUDiQxOJi6egkr5G9rIGJRFnd8Q1qORRQiYuk2U3/8hzqknbJ TfJNkhKwiqfA== X-IronPort-AV: E=McAfee;i="6000,8403,9947"; a="254740001" X-IronPort-AV: E=Sophos;i="5.82,204,1613462400"; d="scan'208";a="254740001" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 14:28:52 -0700 IronPort-SDR: KQrS4tTE9U49Ey/tU4WtUCsHHYZyvz+Qt5XrN1kzop9rEudlwazfJyaUuE2EcEjd4bX97/ErhT uZHzVYSNId8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,204,1613462400"; d="scan'208";a="387143406" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.171]) by fmsmga007.fm.intel.com with SMTP; 07 Apr 2021 14:28:49 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 08 Apr 2021 00:28:48 +0300 Date: Thu, 8 Apr 2021 00:28:48 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Takashi Iwai 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 Message-ID: References: <20210402082317.871-1-tiwai@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Patchwork-Hint: comment Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. 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... -- Ville Syrj?l? Intel