Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2173928imm; Mon, 28 May 2018 03:13:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJvo/kJplaURaFrrN96q7ASHxfJLwjomFI5NnMtsSun/KJtVb2pW3ZIVH0puzDgp8TIGpqk X-Received: by 2002:a65:56c1:: with SMTP id w1-v6mr5403718pgs.227.1527502392998; Mon, 28 May 2018 03:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527502392; cv=none; d=google.com; s=arc-20160816; b=PRlIMU/EFGO0e2UKH8aZeuz7nJIs+JRdlvdPYo2QKHDHm6IyCeUccjgPfOrx+MyFs1 qV59I/rp57ufuluR/yPuaZ8HpMRdvnaujWI2BSg62HkEtL5pW2s8i1c+SGuvC9TdfGH9 UWDOmpmtW55tkHoRcIc2AT7OGtr01fZCsOt5mhzi08URVP4/0Ks5FuUR0vUZ0TCHlOWH BSNIVMKy7xqDSwaSd+EcRNTVgnCUXceoCAPZsbHWoLv+tB5RDnESnw/YAYixBgahGzDh rFjb4WWZp84c2F2K2Lr17WxrtEw9gl5HGxAmVHUWpYlu0hS+JJUICEcznUWBranvRMSS ncLA== 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=iqfQYZA086CPwuRBauB3CABK5r2OEtv9EbArq45Bxrc=; b=YzfnN2+WJPXRmzWP6LMVs0MDssj8VXdgdk7zhTtCuGH7iC0olfNjvjUvAsvYvi75Zj 0y1z+gjNuEM6cKkCC27HjTT/ePPG3KCfk0OIVJ7fXJn1cACsArag6u6e5FdPnMqwuw/H qGKVxG1PM9A995UV9OH5RFv1JPpb153L0dG+/d10WsdIbRgaFUVbVut2M38P7Wft83e6 lhjm3KrV8pNPjTa16zue1IjkvE9eEOqXS0jGwD8HS0563+Ap0pMLolL3VJaYvvjTbvZx 5lk2QTyhy5cSdXpFoStutKt6hSmLJDk+jDB2DpQT8NqOqIlQ3n/1EM3MECeQ8qBjUOfv bo9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BN2WhXtj; 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 l12-v6si23909908pgr.367.2018.05.28.03.12.58; Mon, 28 May 2018 03:13:12 -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=BN2WhXtj; 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 S936673AbeE1KMQ (ORCPT + 99 others); Mon, 28 May 2018 06:12:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:60222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936704AbeE1KME (ORCPT ); Mon, 28 May 2018 06:12:04 -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 B5E72208A2; Mon, 28 May 2018 10:12:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502324; bh=+EKhc3eeknQUd2ooNrQvVV187r0bY7A2ZCL0NjWkF4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BN2WhXtje275tD5Zjrs3SD04iK0h2s0XrJx1UtS97bbL811CIVOqzSUx/X277v7oL 36gHFNYJFrw627CiBbuBFSvZeMffx39hcNc5Um91r2eZCN5MwiStfahvIi04wQHIdI L8bCkyIV+0mRWWQXJxeely5a1tlKFwX1DAMo0Z/o= 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 3.18 145/185] ACPICA: acpi: acpica: fix acpi operand cache leak in nseval.c Date: Mon, 28 May 2018 12:03:06 +0200 Message-Id: <20180528100108.308488591@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-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,