From patchwork Fri Nov 30 11:28:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152519 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3539484ljp; Fri, 30 Nov 2018 03:28:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wq6UVVD9+ntcgDpyyqMaVKffJrNISG6ZtYACb1Kg4UoFm1MRXdh1mT+fAwhnnHjPeuXTcl X-Received: by 2002:a17:902:7c0a:: with SMTP id x10mr5400483pll.65.1543577318516; Fri, 30 Nov 2018 03:28:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543577318; cv=none; d=google.com; s=arc-20160816; b=JeOynRTWetk08pZcXz6Y15yDtiZmH6D+X73ADjpwZJW2/2I1Utli2iQJV0u1e8XuAl kGyJEcZ/OLm7XGVbBWPdiH6gQns7VHQ13fLm1Y0MMBRdemYSuDZTGGmMj4iqsuy9+peA gVK6OCfFrqnWLr4yIENWH5O584djjQM6xRHBCZsQhbXaYSaIJlM6Qizb+2jfqsrSm4ol 6ZcKmPe4mvQWD55WcGfADvqJvVR5tpMRtBkERNd1eGlDphfk6CxnlKKjbzCV5JeyLRwm NsG/KAZIDOWGVEh2DOKlsKHAuLEFBhV7FpR54nkP3USRvuvAZEp+1q5l8IVKOi/ekosc OWTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=gJOZZMkYIVqe/pbSRSw5GgXxc9S9rVw3e+ODAsvWydY=; b=s+sT0W2PBKyqtha4ju/whddWooTFSdyaqMBJweMl36E2tMdmGTf0Df+cf1wEY1v47S rDXWXgKd3tBaF7KQ8LAwUIfoMkK+xmcUvkfvt0GZmbZdOxbAvFitXm6Q3bcOgA05iuEA tBr6J7WzjWgLWuT8siP2pwqnASksTzTWQ704Ii5WZ5YAl+543ioTbJVRYtilajHL4j5W v03DOKqeKzlcAMlgJqdDM6BI8Vbg1gPKM3rSSvVRHBWviIH8i+7x6Vpn/08jytplYwU9 vQiOTtIAQdtvpwF3TouaZ1MpdQYRx/3AIlb7dQGF3qwD+rLIiONXCrrGugKh5jYAMC3q q2uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CFZuGmam; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 41si5029010plf.347.2018.11.30.03.28.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 03:28:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CFZuGmam; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BD40C2119739E; Fri, 30 Nov 2018 03:28:36 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 00EBD2117D76B for ; Fri, 30 Nov 2018 03:28:35 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id k198so5366373wmd.3 for ; Fri, 30 Nov 2018 03:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SoPA/xPSkYtoqdMYE6fW82fWunjWMgKB9dw55lI2VBs=; b=CFZuGmamOsQuAWK8u1kBwUANiHNXcOtJGOUDyeV73aKg0Ylo8hX0p+vgL3rGw3bkI7 Fy6pdkBJ+/4HklRfSrqHaZcjrGP23v/MU2Qp1LASTffLD5QBKjXl0OCZQzMACOhIJ5Fh /XEks3Z/UYqb9+Lqf3GGzWb8oGL0RIqPhuEcY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SoPA/xPSkYtoqdMYE6fW82fWunjWMgKB9dw55lI2VBs=; b=JcHsm67fxKjDu4yX3AJvVkFa8WfKU/W80CuEM3oZgRCX3e0Rg3GrUx+7vYo1UQeYr+ 6ieRz6tSeW/MlXmgzS6rC6qg3efZjbiM9mqf/eAepqnTsxP+Aj/dvxRkK3pTuF3Niaq+ AsQVxo0aJ8SEnvfh0/a27l6qY8FkBI6ptHILUcQDGxiqkCYHK0tS8rJtgxTjAukuEDYF EFXHnWwhzpenk2OWTetbNDVz7mzxANEwU9pUnGfYj7FWK8z23GIMIvs9k5dq7xSnlC+W o0+hVlS1vNSdvxBU7Sh507ZaR29t1iWEIM5B73xC7U0KRbgtWlFr0GGMeBBEbF4OWjr/ chyg== X-Gm-Message-State: AA+aEWbW77eWWCtw9llhLamEJTYB/MTU1nkOWhaKBlRfyo6otShpZt+v uToAN0XcHxUu1acbHSZbMrv0SBPuGOk= X-Received: by 2002:a1c:7d54:: with SMTP id y81mr5397298wmc.78.1543577314164; Fri, 30 Nov 2018 03:28:34 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:f070:d240:312e:9f99]) by smtp.gmail.com with ESMTPSA id h16sm4340570wrs.60.2018.11.30.03.28.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 03:28:33 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 30 Nov 2018 12:28:26 +0100 Message-Id: <20181130112829.12173-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130112829.12173-1-ard.biesheuvel@linaro.org> References: <20181130112829.12173-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH v2 1/4] ArmPkg/ArmMmuLib ARM: handle unmapped section in GetMemoryRegion() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jones , Laszlo Ersek Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" GetMemoryRegion() is used to obtain the attributes of an existing mapping, to permit permission attribute changes to be optimized away if the attributes don't actually change. The current ARM code assumes that a section mapping or a page mapping exists for any region passed into GetMemoryRegion(), but the region may be unmapped entirely, in which case the code will crash. So check if a section mapping exists before dereferencing it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/CpuDxe/Arm/Mmu.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.19.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm Reviewed-by: Philippe Mathieu-Daudé diff --git a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c b/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c index 12ca5b26673e..3b29d33d0a9c 100644 --- a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c +++ b/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c @@ -457,6 +457,9 @@ GetMemoryRegion ( // Get the section at the given index SectionDescriptor = FirstLevelTable[TableIndex]; + if (!SectionDescriptor) { + return EFI_NOT_FOUND; + } // If 'BaseAddress' belongs to the section then round it to the section boundary if (((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) ||