Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp208377pxf; Thu, 8 Apr 2021 00:52:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8IFlrGKbqEe9/O1VM80VWeUHoi977foR3wrKG907m8iolc2cto3VX6JxBIVHfvswcax6g X-Received: by 2002:a05:6a00:1585:b029:203:6bc9:3ca6 with SMTP id u5-20020a056a001585b02902036bc93ca6mr6356586pfk.79.1617868323448; Thu, 08 Apr 2021 00:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617868323; cv=none; d=google.com; s=arc-20160816; b=XnwlOwUoP4AVPqiArJ+FAYiEErkqWo7G0ukdMr+OSST/J8NetkVbVrVhjmPrL0GxZp j7PS/u/F6LuXItV9fCVORvuN7s4KZdrE6rZ68BxoUIp6a7Fcn2uUKll4HBWblzkSB/o8 b0yOxaBIFmjUQwAn0gLFOMj/DfRec9Aq96F3cNC+mc4GKDx/IWDY3Xiq8WAhovL1eACt cPTEYGEPKjswcBySW1TRklC9NJfXv43J8FrOcFa/THvefv/e1Kg7LIppNuBAAN/w/VRJ 6ZXaGbpXrae1RHsuyUERNe2aKPP4/ZGKnqSmQkLBVHFxQGulTkO0hp8T52JRksz9y84D bNWw== 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:subject:cc:to:from:message-id :date; bh=be/elDSl5+FAqXIQnCQgTruWGIhbnV8MiwcHM0vCtTw=; b=FQ6TjmTE7lKlNBsDnV4NNuvv3PqxLWx4vKVR5pELMGUZeglLe8y2nYCuCkhNv6DnyO BVty+1Eo5XKBQnrufZ9nT3ejEVcDJ8rPEMzANrAzy90NtAV+2RpZwsbD+mHtIeF4FVbG ws5oy6fNwhAYT3bIPLVGEsTBk5abG4XCwFQJCqQk5hqHx5uC2RdQRh8xpcWXv7IipMwL /a426b9Sf24m8dHeEVNhSYuh/4Ya8oQGIhhRWYULXq43qGoXm1SutUPzXtCvpgHmQhCz pvJ7bi4I+r2P4NK5LkY+BEgVlhafX7MnMPW9HsKXxXD3qRK/V6aI+BlQzlXS6HtfL0VR aLVg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si27433020pls.285.2021.04.08.00.51.51; Thu, 08 Apr 2021 00:52:03 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229588AbhDHHvb (ORCPT + 99 others); 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