Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2446813imm; Mon, 28 May 2018 08:14:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrojcMVqsUhq5XcAQEf3CNeKpX/xQul1LDEyFq8xrnQXmSWwNJcMTlLlTNPerGD2xAw7uIr X-Received: by 2002:a62:8910:: with SMTP id v16-v6mr13622163pfd.13.1527520469601; Mon, 28 May 2018 08:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527520469; cv=none; d=google.com; s=arc-20160816; b=UtfxB4ufWPe1777xXIcUtEGyVQyHCfxK3IOEA7UaigUHvbyuc3wvMzz5xX+sKR9cRy c6qw/5GjNWjyBC0CyEzZ/MEktEeiPOpF52zfigGH6LD9hQGj7N1pyMh6Ny71IuPj2Pjr sG/hPuRD7hzla4Z/Ecxs8Irn9iH977uTRPF0C/5oqJx+tIkzZjUJkNA+G7odhyemM+8k iSJvtgq9hSAj1g1tm2UORBOgs0Iase/XHfyJMxp3kf2Wh+TkmFp6hsj5jdRwOQSW300b RaOi3s3f/OUyplMwsAbPbk91Va279lP8FH6Yr9meMZN/LbC2PwG366yPqzAHcdMGf73v VaqQ== 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:dkim-signature :arc-authentication-results; bh=K5uqZYz7ztk43kM7u3IAvXH78aO1bTWLL7yZRId3KiQ=; b=jo+EPoSNqnanmUn+rdcsAFow/qYPxZz0qP5xE9brTIbgnKmtlY06xsYTH3ha/pByki EPgh3PNlrT5aQ8bVR4XR6uyxabiyuGWHYppqVGYLUiqTMlGmdUkqY0j4fvVA639mqYef 4wEdMbhg2mna0yqex6R8yPjkAGfKBBQecT5lS+AoZDpwKVgD/6jDZK2CubWC5VvHvTHG Uu38+HR57oWf5f7hd62N8+uXYNEWLqRoSVrpXAPF++wiI2JgOVpQkmg0imbx3xIVzMF3 V6Rwx2r6I7tD+2I2fE67YUrsFYKHLKWsHQMfbsgo2oGzvU2muZxmgcmpDRfGFBbw+X7F wLAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Skk12+8; 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 p7-v6si23233710pgd.96.2018.05.28.08.14.14; Mon, 28 May 2018 08:14:29 -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; dkim=pass header.i=@kernel.org header.s=default header.b=0Skk12+8; 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 S1033656AbeE1KXZ (ORCPT + 99 others); Mon, 28 May 2018 06:23:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:42694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032835AbeE1KXT (ORCPT ); Mon, 28 May 2018 06:23:19 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8442520843; Mon, 28 May 2018 10:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502999; bh=Eu79lQkRXBwaXOobyM6X9GO+oYi5LcbDBW0kvI/NRCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Skk12+89vfDJ7aCOSdUCIezrvMSuj2R6Rn7vbi8nnU4QNpodGl+qgmm4J1e6DH5m zWFdjPGWCy8JwO7N8n/lehNZHhnlmXOf5b94shHhjJqFT512ZwgjBQ4d5tvuFYaqqs KuuicVNJKFuFbB1hXxcCGE949YxUWmcBWDn+XYX8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Seunghun Han , Erik Schmauss , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.4 206/268] ACPICA: acpi: acpica: fix acpi operand cache leak in nseval.c Date: Mon, 28 May 2018 12:03:00 +0200 Message-Id: <20180528100225.589647517@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Seunghun Han [ Upstream commit 97f3c0a4b0579b646b6b10ae5a3d59f0441cc12c ] I found an ACPI cache leak in ACPI early termination and boot continuing case. When early termination occurs due to malicious ACPI table, Linux kernel terminates ACPI function and continues to boot process. While kernel terminates ACPI function, kmem_cache_destroy() reports Acpi-Operand cache leak. Boot log of ACPI operand cache leak is as follows: >[ 0.464168] ACPI: Added _OSI(Module Device) >[ 0.467022] ACPI: Added _OSI(Processor Device) >[ 0.469376] ACPI: Added _OSI(3.0 _SCP Extensions) >[ 0.471647] ACPI: Added _OSI(Processor Aggregator Device) >[ 0.477997] ACPI Error: Null stack entry at ffff880215c0aad8 (20170303/exresop-174) >[ 0.482706] ACPI Exception: AE_AML_INTERNAL, While resolving operands for [opcode_name unavailable] (20170303/dswexec-461) >[ 0.487503] ACPI Error: Method parse/execution failed [\DBG] (Node ffff88021710ab40), AE_AML_INTERNAL (20170303/psparse-543) >[ 0.492136] ACPI Error: Method parse/execution failed [\_SB._INI] (Node ffff88021710a618), AE_AML_INTERNAL (20170303/psparse-543) >[ 0.497683] ACPI: Interpreter enabled >[ 0.499385] ACPI: (supports S0) >[ 0.501151] ACPI: Using IOAPIC for interrupt routing >[ 0.503342] ACPI Error: Null stack entry at ffff880215c0aad8 (20170303/exresop-174) >[ 0.506522] ACPI Exception: AE_AML_INTERNAL, While resolving operands for [opcode_name unavailable] (20170303/dswexec-461) >[ 0.510463] ACPI Error: Method parse/execution failed [\DBG] (Node ffff88021710ab40), AE_AML_INTERNAL (20170303/psparse-543) >[ 0.514477] ACPI Error: Method parse/execution failed [\_PIC] (Node ffff88021710ab18), AE_AML_INTERNAL (20170303/psparse-543) >[ 0.518867] ACPI Exception: AE_AML_INTERNAL, Evaluating _PIC (20170303/bus-991) >[ 0.522384] kmem_cache_destroy Acpi-Operand: Slab cache still has objects >[ 0.524597] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.12.0-rc5 #26 >[ 0.526795] Hardware name: innotek gmb_h virtual_box/virtual_box, BIOS virtual_box 12/01/2006 >[ 0.529668] Call Trace: >[ 0.530811] ? dump_stack+0x5c/0x81 >[ 0.532240] ? kmem_cache_destroy+0x1aa/0x1c0 >[ 0.533905] ? acpi_os_delete_cache+0xa/0x10 >[ 0.535497] ? acpi_ut_delete_caches+0x3f/0x7b >[ 0.537237] ? acpi_terminate+0xa/0x14 >[ 0.538701] ? acpi_init+0x2af/0x34f >[ 0.540008] ? acpi_sleep_proc_init+0x27/0x27 >[ 0.541593] ? do_one_initcall+0x4e/0x1a0 >[ 0.543008] ? kernel_init_freeable+0x19e/0x21f >[ 0.546202] ? rest_init+0x80/0x80 >[ 0.547513] ? kernel_init+0xa/0x100 >[ 0.548817] ? ret_from_fork+0x25/0x30 >[ 0.550587] vgaarb: loaded >[ 0.551716] EDAC MC: Ver: 3.0.0 >[ 0.553744] PCI: Probing PCI hardware >[ 0.555038] PCI host bridge to bus 0000:00 > ... Continue to boot and log is omitted ... I analyzed this memory leak in detail and found acpi_ns_evaluate() function only removes Info->return_object in AE_CTRL_RETURN_VALUE case. But, when errors occur, the status value is not AE_CTRL_RETURN_VALUE, and Info->return_object is also not null. Therefore, this causes acpi operand memory leak. This cache leak causes a security threat because an old kernel (<= 4.9) shows memory locations of kernel functions in stack dump. Some malicious users could use this information to neutralize kernel ASLR. I made a patch to fix ACPI operand cache leak. Signed-off-by: Seunghun Han Signed-off-by: Erik Schmauss Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/acpica/nseval.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/acpi/acpica/nseval.c +++ b/drivers/acpi/acpica/nseval.c @@ -308,6 +308,14 @@ acpi_status acpi_ns_evaluate(struct acpi /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ status = AE_OK; + } else if (ACPI_FAILURE(status)) { + + /* If return_object exists, delete it */ + + if (info->return_object) { + acpi_ut_remove_reference(info->return_object); + info->return_object = NULL; + } } ACPI_DEBUG_PRINT((ACPI_DB_NAMES,