From nobody Wed May 8 08:35:01 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1571163557; cv=none; d=zoho.com; s=zohoarc; b=nN6zJPAURN5240XpAqd3G9Qncw1/8ief7oJ8bazUtS7WpGBP7uurcN8QL9JoZ3nRBdJQzZnnLgW2k1GTV20x1gkEbuZejSG1hhd3UsYQSljJurUSmMaAU22eMwCCWO5HolZ4ZvLmkhfZqin3XQD/UFgn01dzg6rfm3yTnxT+epc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571163557; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=I9wxIMgjGJeNtlZX2JWDxEIoQGkZqOyRpvd3fPbGu7E=; b=SXQUTkf3X+uqwSZbHjwo+gP6st6Us7Hl1H6p4vj87zmluIjfpYmevry02ST3cSauOXvlfiINetZhmupHGuhpIJ/U34HZ21J+bGnPi4HXScWzv5aKSTgsrHmYkDOHAT2MziXHGWsoEC3uvarLvwHKQR8wNSpaleV0ApoSsISSmSc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571163556958747.4016088612225; Tue, 15 Oct 2019 11:19:16 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iKROf-0007Mi-Ho; Tue, 15 Oct 2019 18:18:13 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iKROe-0007Ma-D8 for xen-devel@lists.xenproject.org; Tue, 15 Oct 2019 18:18:12 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 251aff05-ef78-11e9-939d-12813bfff9fa; Tue, 15 Oct 2019 18:18:11 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B221E28; Tue, 15 Oct 2019 11:18:10 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0BDED3F6C4; Tue, 15 Oct 2019 11:18:08 -0700 (PDT) X-Inumbo-ID: 251aff05-ef78-11e9-939d-12813bfff9fa From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 15 Oct 2019 19:18:02 +0100 Message-Id: <20191015181802.21957-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 Subject: [Xen-devel] [PATCH for-4.13] xen/arm: Don't use _end in is_xen_fixed_mfn() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: jgross@suse.com, Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Volodymyr Babchuk MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" virt_to_maddr() is using the hardware page-table walk instructions to translate a virtual address to physical address. The function should only be called on virtual address mapped. _end points past the end of Xen binary and may not be mapped when the binary size is page-aligned. This means virt_to_maddr() will not be able to do the translation and therefore crash Xen. Note there is also an off-by-one issue in this code, but the panic will trump that. Both issues can be fixed by using _end - 1 in the check. Signed-off-by: Julien Grall --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu Cc: jgross@suse.com x86 seems to be affected by the off-by-one issue. Jan, Andrew? This could be reached by a domain via XEN_SYSCTL_page_offline_op. However, the operation is not security supported (see XSA-77). So we are fine here. --- xen/include/asm-arm/mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 262d92f18d..174acd8859 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -153,7 +153,7 @@ extern unsigned long xenheap_base_pdx; =20 #define is_xen_fixed_mfn(mfn) \ ((mfn_to_maddr(mfn) >=3D virt_to_maddr(&_start)) && \ - (mfn_to_maddr(mfn) <=3D virt_to_maddr(&_end))) + (mfn_to_maddr(mfn) <=3D virt_to_maddr(_end - 1))) =20 #define page_get_owner(_p) (_p)->v.inuse.domain #define page_set_owner(_p,_d) ((_p)->v.inuse.domain =3D (_d)) --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel