Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1942582ybv; Fri, 14 Feb 2020 08:36:55 -0800 (PST) X-Google-Smtp-Source: APXvYqy3NX1AE81gZFZqvgV9RLT7ORIHay1J8fDcG1ghTVIY60+nAaxx1F4YIrSSLxdRtyfpUDi5 X-Received: by 2002:a9d:4f17:: with SMTP id d23mr3072971otl.170.1581698215201; Fri, 14 Feb 2020 08:36:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581698215; cv=none; d=google.com; s=arc-20160816; b=gNiZgT29bYAmt3sHhxHuD9kCafEQsIqPfVsGUKFR6g7lYuzt2ZUJxDW7mEnC5k8Wia 7cSJAZDMrOUU3UIfhoxjakxc0Zg6dzOoF4r9THkE9O3fi5uVkI/cdCRhjPD5vYpvTiCb uEG+aVizPZzRtpqjVRvZJopHJ4iRfbm8rwePp/26z8wWKGVwtGXZAWWvNiXUYvsciLKH o+pZlLlqyctrWF2K4JPOzIOq8RyUExO8XzF66HA4pMArAW2wylEi9JXxfP8zdD6Hav53 lIlauV+a54rlxaaf7RHvd0h6J1d1NYT8GOmUnjnCLJjoP5uoYIcvTndcK0AymMTiDzQc hF1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=46zRhi7LVQzBVmde1UvlSfT+QpawhWObNpkyQt1inyk=; b=C7cUdupAjp2p82iXxaWM+GmcbxH6QahgO2Mn066kNlieDO76bNSZ/lMmaBoOrmQiJJ gdFpjU7hMFvWbBMqz5djcL/DuaTmuAbgDmiqhTNhXflesqH0BaZPB3Mu6NYjcUW3CF7g fmuNfLqkgdVnTST3YZGuC3r9eh565P552YvC46RSGQ+UkWi5dOGqlE3F93304iYHX3XU /5Adhm2ix+8sEO8quhgKy0eksNXcC2PSleDTKMFx41ZNgr++OyuNYKu6VDAoyvTquhcn vNtrfich5Ne+1yFoMWYUR4b480SSSx7h8hIJkL52ObV2ffCT8/aX5pqA+M9HmB2NZye/ BN2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="gPHv2Xm/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id l4si2982593oib.170.2020.02.14.08.36.43; Fri, 14 Feb 2020 08:36:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="gPHv2Xm/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2405903AbgBNQYc (ORCPT + 99 others); Fri, 14 Feb 2020 11:24:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:58666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393239AbgBNQWs (ORCPT ); Fri, 14 Feb 2020 11:22:48 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0FDB724761; Fri, 14 Feb 2020 16:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697368; bh=bX4UW4bwdLIwbssVAWjQ1Qt3M8b/dHtiBBmgjZj3URA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPHv2Xm/eOTc0jpju0kffp9jrNno5zevMejwVeCkPHvdlbOCv4zyLpnhFga00NlrO 6ogA0DpluolggeArPNNQtFlshjILZ27eok1TGVL+voMW+EAKyae9I7vL37mWqZlEjM xb5LKPu0gVXZ/l0MIXWHpQZ/DtViSMRn3nk+zyrw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Erik Kaneda , Elia Geretto , Bob Moore , "Rafael J . Wysocki" , Sasha Levin , linux-acpi@vger.kernel.org, devel@acpica.org Subject: [PATCH AUTOSEL 4.9 067/141] ACPICA: Disassembler: create buffer fields in ACPI_PARSE_LOAD_PASS1 Date: Fri, 14 Feb 2020 11:20:07 -0500 Message-Id: <20200214162122.19794-67-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Erik Kaneda [ Upstream commit 5ddbd77181dfca61b16d2e2222382ea65637f1b9 ] ACPICA commit 29cc8dbc5463a93625bed87d7550a8bed8913bf4 create_buffer_field is a deferred op that is typically processed in load pass 2. However, disassembly of control method contents walk the parse tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed in a later walk. This is a problem when there is a control method that has the same name as the AML_CREATE object. In this case, any use of the name segment will be detected as a method call rather than a reference to a buffer field. If this is detected as a method call, it can result in a mal-formed parse tree if the control methods have parameters. This change in processing AML_CREATE ops earlier solves this issue by inserting the named object in the ACPI namespace so that references to this name would be detected as a name string rather than a method call. Link: https://github.com/acpica/acpica/commit/29cc8dbc Reported-by: Elia Geretto Tested-by: Elia Geretto Signed-off-by: Bob Moore Signed-off-by: Erik Kaneda Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/acpica/dsfield.c | 2 +- drivers/acpi/acpica/dswload.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c index 6a4b603d0e834..10bbf6ca082ab 100644 --- a/drivers/acpi/acpica/dsfield.c +++ b/drivers/acpi/acpica/dsfield.c @@ -272,7 +272,7 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op, * FUNCTION: acpi_ds_get_field_names * * PARAMETERS: info - create_field info structure - * ` walk_state - Current method state + * walk_state - Current method state * arg - First parser arg for the field name list * * RETURN: Status diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c index fd34040d4f44a..9c41d2153d0f2 100644 --- a/drivers/acpi/acpica/dswload.c +++ b/drivers/acpi/acpica/dswload.c @@ -440,6 +440,27 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); + /* + * Disassembler: handle create field operators here. + * + * create_buffer_field is a deferred op that is typically processed in load + * pass 2. However, disassembly of control method contents walk the parse + * tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed + * in a later walk. This is a problem when there is a control method that + * has the same name as the AML_CREATE object. In this case, any use of the + * name segment will be detected as a method call rather than a reference + * to a buffer field. + * + * This earlier creation during disassembly solves this issue by inserting + * the named object in the ACPI namespace so that references to this name + * would be a name string rather than a method call. + */ + if ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) && + (walk_state->op_info->flags & AML_CREATE)) { + status = acpi_ds_create_buffer_field(op, walk_state); + return_ACPI_STATUS(status); + } + /* We are only interested in opcodes that have an associated name */ if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) { -- 2.20.1