Received: by 10.223.176.5 with SMTP id f5csp3444099wra; Mon, 29 Jan 2018 13:16:10 -0800 (PST) X-Google-Smtp-Source: AH8x224WXnV5mhD/z7NSaqiIRaHjJuOu9/W2s6iHE6jUjKMYm1nIiuV7cOnm0q1I0jDxAln6lA8y X-Received: by 10.98.71.74 with SMTP id u71mr28403932pfa.45.1517260570680; Mon, 29 Jan 2018 13:16:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517260570; cv=none; d=google.com; s=arc-20160816; b=vK7nhK+TSOwyRJFYtqZo/DJskFTXpbRoHM6l4SDq8qUGhXP/gJCWLI9XBNeveJPlT4 oGaFXsAeybOpoZCefDKRDcD17TTlP0rGGZCg9o9nfhDf4ktHL66CAbefYm7aYXYIm6K7 K20dOUEYabwzYIhQ/y1L2atFCv9Sfkoia1vvFctGUOzmh7UnEqRNmaE17PUj3vIwRw87 nVl2MHqYRWZvqU0cdajyC8KterSNdPJ4qKPsD8MxdbQBIAq1idR6DGZqnDj6SkiK9Rz+ AfHA5U7WlQTBLWKoF+DMAopbd6wXEg7m7dUSq1UXNUI4xFpoPqTYqVG2LVQ33VfzRT6G NO9A== 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=8J+3U3+hWVRX4ezuwtXl/nHZNaswh6KWDgSYW4Mubt4=; b=NQuHc5pFrGi8WWhWQmLAiWst7NN2ThXbr6hnD3e5e2w4I7TpvBxqbBECz+t3ZI6yz5 ZQGzAT7yua/I6e+aOWGl04gQrdmEpVF2IEM5S6MQq2peo6iq88RurpPXq2yAOcSGjmjU bEDrLt2m6hD3pMsz2tD5WbSoawSyO1i9sLgPc5IMdGl8XSN8Y4p6+u2CGLU5Hc/G75WM RvgNLJ7VP7tYyrixfh+Ab07t1vAEWIlyBGGRaWUYdvWc8QLFV2ADyMLEJuchNZMAyMGf 38OlPXjI2IxkFP1BgMVuOArY0H0qBiEG2cJHeHWqxDFB6FRzPulZIa0Q8SoS9jxhh/iz fB/A== 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 e64si340100pfg.409.2018.01.29.13.15.55; Mon, 29 Jan 2018 13:16:10 -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; 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 S1752309AbeA2VPc (ORCPT + 99 others); Mon, 29 Jan 2018 16:15:32 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43902 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752365AbeA2UEp (ORCPT ); Mon, 29 Jan 2018 15:04:45 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 66D4E2F6E; Mon, 29 Jan 2018 13:04:48 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Seunghun Han , Lv Zheng , Bob Moore , "Rafael J. Wysocki" , "Lee, Chun-Yi" Subject: [PATCH 4.9 19/66] ACPICA: Namespace: fix operand cache leak Date: Mon, 29 Jan 2018 13:56:43 +0100 Message-Id: <20180129123840.840091063@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@linuxfoundation.org> User-Agent: quilt/0.65 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: Seunghun Han commit 3b2d69114fefa474fca542e51119036dceb4aa6f upstream. ACPICA commit a23325b2e583556eae88ed3f764e457786bf4df6 I found some ACPI operand cache leaks in ACPI early abort cases. Boot log of ACPI operand cache leak is as follows: >[ 0.174332] ACPI: Added _OSI(Module Device) >[ 0.175504] ACPI: Added _OSI(Processor Device) >[ 0.176010] ACPI: Added _OSI(3.0 _SCP Extensions) >[ 0.177032] ACPI: Added _OSI(Processor Aggregator Device) >[ 0.178284] ACPI: SCI (IRQ16705) allocation failed >[ 0.179352] ACPI Exception: AE_NOT_ACQUIRED, Unable to install System Control Interrupt handler (20160930/evevent-131) >[ 0.180008] ACPI: Unable to start the ACPI Interpreter >[ 0.181125] ACPI Error: Could not remove SCI handler (20160930/evmisc-281) >[ 0.184068] kmem_cache_destroy Acpi-Operand: Slab cache still has objects >[ 0.185358] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.10.0-rc3 #2 >[ 0.186820] Hardware name: innotek gmb_h virtual_box/virtual_box, BIOS virtual_box 12/01/2006 >[ 0.188000] Call Trace: >[ 0.188000] ? dump_stack+0x5c/0x7d >[ 0.188000] ? kmem_cache_destroy+0x224/0x230 >[ 0.188000] ? acpi_sleep_proc_init+0x22/0x22 >[ 0.188000] ? acpi_os_delete_cache+0xa/0xd >[ 0.188000] ? acpi_ut_delete_caches+0x3f/0x7b >[ 0.188000] ? acpi_terminate+0x5/0xf >[ 0.188000] ? acpi_init+0x288/0x32e >[ 0.188000] ? __class_create+0x4c/0x80 >[ 0.188000] ? video_setup+0x7a/0x7a >[ 0.188000] ? do_one_initcall+0x4e/0x1b0 >[ 0.188000] ? kernel_init_freeable+0x194/0x21a >[ 0.188000] ? rest_init+0x80/0x80 >[ 0.188000] ? kernel_init+0xa/0x100 >[ 0.188000] ? ret_from_fork+0x25/0x30 When early abort is occurred due to invalid ACPI information, Linux kernel terminates ACPI by calling acpi_terminate() function. The function calls acpi_ns_terminate() function to delete namespace data and ACPI operand cache (acpi_gbl_module_code_list). But the deletion code in acpi_ns_terminate() function is wrapped in ACPI_EXEC_APP definition, therefore the code is only executed when the definition exists. If the define doesn't exist, ACPI operand cache (acpi_gbl_module_code_list) is leaked, and stack dump is shown in kernel log. This causes a security threat because the old kernel (<= 4.9) shows memory locations of kernel functions in stack dump, therefore kernel ASLR can be neutralized. To fix ACPI operand leak for enhancing security, I made a patch which removes the ACPI_EXEC_APP define in acpi_ns_terminate() function for executing the deletion code unconditionally. Link: https://github.com/acpica/acpica/commit/a23325b2 Signed-off-by: Seunghun Han Signed-off-by: Lv Zheng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki Acked-by: Lee, Chun-Yi Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/acpica/nsutils.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) --- a/drivers/acpi/acpica/nsutils.c +++ b/drivers/acpi/acpica/nsutils.c @@ -594,25 +594,20 @@ struct acpi_namespace_node *acpi_ns_vali void acpi_ns_terminate(void) { acpi_status status; + union acpi_operand_object *prev; + union acpi_operand_object *next; ACPI_FUNCTION_TRACE(ns_terminate); -#ifdef ACPI_EXEC_APP - { - union acpi_operand_object *prev; - union acpi_operand_object *next; + /* Delete any module-level code blocks */ - /* Delete any module-level code blocks */ - - next = acpi_gbl_module_code_list; - while (next) { - prev = next; - next = next->method.mutex; - prev->method.mutex = NULL; /* Clear the Mutex (cheated) field */ - acpi_ut_remove_reference(prev); - } + next = acpi_gbl_module_code_list; + while (next) { + prev = next; + next = next->method.mutex; + prev->method.mutex = NULL; /* Clear the Mutex (cheated) field */ + acpi_ut_remove_reference(prev); } -#endif /* * Free the entire namespace -- all nodes and all objects