Received: by 10.192.165.156 with SMTP id m28csp1096073imm; Wed, 11 Apr 2018 12:19:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx49HiHxLLTS3WzQR01/xJzQrXsBhShBNBLrqfYoPixyXz+8g4qOteIPHzWGMGmSzW3keJiin X-Received: by 2002:a17:902:1006:: with SMTP id b6-v6mr6412256pla.252.1523474391265; Wed, 11 Apr 2018 12:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523474391; cv=none; d=google.com; s=arc-20160816; b=U7cCuJQdTj/VrN5MrMDouHI0QBtJFo4/sYk2RKmmZ6Ww+P23vprF38PzU2TT2e0uEw 9Ct3QqNqaEG7AmJaE11y4oxUxmRrd+twxIVc0cAh2UPYOu0PJ5Dc7JE59bAKMf02+snL UdoU6SrGs4Xl7a76J1hB4zfmZ/CL6k0U3+j/6lfei3QQWi9SYZN9Xi/CaLpWNCw/Qd5B aO4c+gV4VSEa+omn/ANqtgO/vYbt/gnBbna4nZxx10zE/rFCzVN9n5u6OSran+J2HspN g7A2jP1RkV2QZgIroMCVpz9gSzoQMAMiUNQwsSVyNdemzV97ww08guiLTrRFL9wzo91l kNig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EpRMFgMbx9sj4xd05iqAPBjY9nQb5KY6TA3QEsgUxRA=; b=JUH2982mMrke8SIvGnHL0K13dNz0CU910FGjaeenaN04FAlOsJE/KLac2pobBkdvII 8mIIloa1EugG82+RqdUrYVCRSsuknoMMvSr1T7oXl5H5TBYTBsIVlem2YhcvYwrvHyhh aSJ+kGaiRj1iBAaQYES27kvUAqH3/IfoUdcZxXEK7d5tLzrq8yrIRT1QuET32TNCSGP8 AS8zZV+QAni3YI27Sohmild2tXKPd103gfL63iBmbkixNTxS+qC6tOWeIlQ1LZjhjuwX pShKB8S1QIR9wpm739WsWrxM2HbfhjMF6uTpyk7dhfiUVDl57dTSWKtyoPFMexSchRp7 PFOw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m72si1343025pfi.236.2018.04.11.12.19.14; Wed, 11 Apr 2018 12:19:51 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757065AbeDKTOd (ORCPT + 99 others); Wed, 11 Apr 2018 15:14:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40532 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935069AbeDKTFi (ORCPT ); Wed, 11 Apr 2018 15:05:38 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E730BCE3; Wed, 11 Apr 2018 19:05:37 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bob Moore , Lv Zheng , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.9 251/310] ACPICA: Disassembler: Abort on an invalid/unknown AML opcode Date: Wed, 11 Apr 2018 20:36:30 +0200 Message-Id: <20180411183633.239977484@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bob Moore [ Upstream commit 6f0527b77d9e0129dd8e50945b0d610ed943d6b2 ] ACPICA commit ed0389cb11a61e63c568ac1f67948fc6a7bd1aeb An invalid opcode indicates something seriously wrong with the input AML file. The AML parser is immediately confused and lost, causing the resulting parse tree to be ill-formed. The actual disassembly can then cause numerous unrelated errors and faults. This change aborts the disassembly upon discovery of such an opcode during the AML parse phase. Link: https://github.com/acpica/acpica/commit/ed0389cb Signed-off-by: Bob Moore Signed-off-by: Lv Zheng Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/acpica/psobject.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/drivers/acpi/acpica/psobject.c +++ b/drivers/acpi/acpica/psobject.c @@ -121,6 +121,9 @@ static acpi_status acpi_ps_get_aml_opcod (u32)(aml_offset + sizeof(struct acpi_table_header))); + ACPI_ERROR((AE_INFO, + "Aborting disassembly, AML byte code is corrupt")); + /* Dump the context surrounding the invalid opcode */ acpi_ut_dump_buffer(((u8 *)walk_state->parser_state. @@ -129,6 +132,14 @@ static acpi_status acpi_ps_get_aml_opcod sizeof(struct acpi_table_header) - 16)); acpi_os_printf(" */\n"); + + /* + * Just abort the disassembly, cannot continue because the + * parser is essentially lost. The disassembler can then + * randomly fail because an ill-constructed parse tree + * can result. + */ + return_ACPI_STATUS(AE_AML_BAD_OPCODE); #endif } @@ -293,6 +304,9 @@ acpi_ps_create_op(struct acpi_walk_state if (status == AE_CTRL_PARSE_CONTINUE) { return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); } + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } /* Create Op structure and append to parent's argument list */