Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1022335yba; Thu, 4 Apr 2019 02:37:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUiYcyJtPLQ0rNFbuv5g/ZHE6dSKNYu/6Abz3F5ezse/KJXJ0c2RklM1zaXDHK89k7rBht X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12mr5133532plb.192.1554370679232; Thu, 04 Apr 2019 02:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370679; cv=none; d=google.com; s=arc-20160816; b=GJFCym7grRwoZVsFe0TmRCGpYi+emu8mP5Ao1VDrflqgdGio7UrlNjRJDM3ANkVIRn NH/ZD1BXqS69LPQex0Q/gD8+uoVUTWMKPL4DTVaX2g4gw8J9bfaGLK5tHSEhlwmYwhjg n/GHN10GR0FVlHT1HkOoZ7Chft9TBwADeBe+uHn+RaGEL9xTzBJa3TWfdpAnm5ihkBX1 cfJ8ClUfKtMn5MVVpJJTjKBlTYynM4DQv5rJk4FOhrWucXboCQ+LFRKjZD8WnH+TpgWu 3qJOJT8qsR6ovqWufuCX/F50AFICZfhhg73ensuakxJ5jcJgyxZKcfyvImye93YVa6ri /Srg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9QzMj7B1b7wMlbElOSvc53dyYMCUfOmJnugtmSUYRfY=; b=FRNOqg5RO48nAt6clhmU4VphbPAQTXDj1Mbf8mefYGrs8g3M2DTX8C1VVlGhhyFDLF G/lX/nEBHcWp0HQiapeGDcsPgOQur3st2T8/DESiJ/1GN9WQ5LWzGPtSyciBsYLUOi/G uj8P5iPzu3zj8z+IhaMVRMI3wrGJ3v1nIo1S8mTeTi8PZWcMooA6FJpmMUZArIh4wpqc DD57/CZ7T7qp006P80plnTifK29NObX7dKDoaXFLJrzn8u/v+kD0OpA65reDxCjo5e/0 xGVtMyvGy7wQLh/bZoBeTaX3uf1fS9i3AbUIq99UFAMAX9L1nGbqgBKFdhAU7LcXB8h9 XksQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WRhkh1XY; 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 h8si527534pgg.573.2019.04.04.02.37.43; Thu, 04 Apr 2019 02:37:59 -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=WRhkh1XY; 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 S1732166AbfDDJFh (ORCPT + 99 others); Thu, 4 Apr 2019 05:05:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:43624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731896AbfDDJFc (ORCPT ); Thu, 4 Apr 2019 05:05:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 24E9E214AF; Thu, 4 Apr 2019 09:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368731; bh=vi9xHRGQzb0BkyTs0LZy9Gk9N+u48BRT8fLZQ2jE/Qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WRhkh1XYzt4+FhbXhNWCpI/NsWwPv3R9B2K05oSUf20GVW+wyPsuAm/rdRIaBRpBh 1Obje4KOo1e5w98iAhXAoj7DoOuSeZLa8LL+TwzD5biRrtbGV/KRAX7x3KQwbuJrm8 /vsWjJsFdzp+qYEZtsUQfc2ertTiuG6E95liv07c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Sai Praneeth Prakhya , AKASHI Takahiro , Alexander Graf , Bjorn Andersson , Borislav Petkov , Heinrich Schuchardt , Jeffrey Hugo , Lee Jones , Leif Lindholm , Linus Torvalds , Matt Fleming , Peter Jones , Peter Zijlstra , Thomas Gleixner , linux-efi@vger.kernel.org, Ingo Molnar , Sasha Levin Subject: [PATCH 4.19 133/187] efi/memattr: Dont bail on zero VA if it equals the regions PA Date: Thu, 4 Apr 2019 10:47:50 +0200 Message-Id: <20190404084609.465957811@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 5de0fef0230f3c8d75cff450a71740a7bf2db866 ] The EFI memory attributes code cross-references the EFI memory map with the more granular EFI memory attributes table to ensure that they are in sync before applying the strict permissions to the regions it describes. Since we always install virtual mappings for the EFI runtime regions to which these strict permissions apply, we currently perform a sanity check on the EFI memory descriptor, and ensure that the EFI_MEMORY_RUNTIME bit is set, and that the virtual address has been assigned. However, in cases where a runtime region exists at physical address 0x0, and the virtual mapping equals the physical mapping, e.g., when running in mixed mode on x86, we encounter a memory descriptor with the runtime attribute and virtual address 0x0, and incorrectly draw the conclusion that a runtime region exists for which no virtual mapping was installed, and give up altogether. The consequence of this is that firmware mappings retain their read-write-execute permissions, making the system more vulnerable to attacks. So let's only bail if the virtual address of 0x0 has been assigned to a physical region that does not reside at address 0x0. Signed-off-by: Ard Biesheuvel Acked-by: Sai Praneeth Prakhya Cc: AKASHI Takahiro Cc: Alexander Graf Cc: Bjorn Andersson Cc: Borislav Petkov Cc: Heinrich Schuchardt Cc: Jeffrey Hugo Cc: Lee Jones Cc: Leif Lindholm Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Jones Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Fixes: 10f0d2f577053 ("efi: Implement generic support for the Memory ...") Link: http://lkml.kernel.org/r/20190202094119.13230-4-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- drivers/firmware/efi/memattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/efi/memattr.c b/drivers/firmware/efi/memattr.c index 8986757eafaf..aac972b056d9 100644 --- a/drivers/firmware/efi/memattr.c +++ b/drivers/firmware/efi/memattr.c @@ -94,7 +94,7 @@ static bool entry_is_valid(const efi_memory_desc_t *in, efi_memory_desc_t *out) if (!(md->attribute & EFI_MEMORY_RUNTIME)) continue; - if (md->virt_addr == 0) { + if (md->virt_addr == 0 && md->phys_addr != 0) { /* no virtual mapping has been installed by the stub */ break; } -- 2.19.1