From patchwork Sun Jul 26 12:59:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 51473 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 59DA7214B7 for ; Sun, 26 Jul 2015 13:02:06 +0000 (UTC) Received: by lagw2 with SMTP id w2sf19925539lag.3 for ; Sun, 26 Jul 2015 06:02:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:cc:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=d8Nmv4oxlTV+A/2LoHAejSneJVP9Qg5mZr4NPQkomBA=; b=L2MbKy5NVzrpb+6RlVhPFeaceXgWaSMI/31WHxYUslKBj8+daSVC7fK43adfvCjdAh wdhgfbVlcpkTdnqmbAsUo19yds6Mp26AEuogfmae27CQ9bJWIy1OZbKqKZ4qGikMEELN QQCMlaVmguTxaTngJMftFrpqaZZ8lhfaqBJH2bUAhr+SraSd3xvQHuiNvV7Xwma1yove rfBHoA/cNcB/R0cr9jVeNZrL1ZUr3svbhIMSCLMCX3FokuJi/n68GW+Ywou4opB3/Zr0 za3VjxDgsosC+vIAgRUBFNWlh8UfVh4/TpoVvWKBBr+fG+76SakSLoc9ATRe+4X7QuE7 +nqg== X-Gm-Message-State: ALoCoQk9CkSZzUCHADY0UDFihplAGDQwbfXbkicKoTAvm7gQR0dUafPcH1voJJabnGc0NqHcfgmP X-Received: by 10.180.106.10 with SMTP id gq10mr3359265wib.0.1437915725021; Sun, 26 Jul 2015 06:02:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.9 with SMTP id ku9ls511843lac.37.gmail; Sun, 26 Jul 2015 06:02:04 -0700 (PDT) X-Received: by 10.112.166.106 with SMTP id zf10mr22240047lbb.36.1437915724666; Sun, 26 Jul 2015 06:02:04 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id dp7si12620126lbc.155.2015.07.26.06.02.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jul 2015 06:02:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lahh5 with SMTP id h5so35136263lah.2 for ; Sun, 26 Jul 2015 06:02:04 -0700 (PDT) X-Received: by 10.152.22.99 with SMTP id c3mr22877311laf.32.1437915724527; Sun, 26 Jul 2015 06:02:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1016424lba; Sun, 26 Jul 2015 06:02:03 -0700 (PDT) X-Received: by 10.67.12.136 with SMTP id eq8mr54564831pad.3.1437915722611; Sun, 26 Jul 2015 06:02:02 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id c3si13876465pdj.114.2015.07.26.06.02.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jul 2015 06:02:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZJLWs-0004ZW-81; Sun, 26 Jul 2015 12:59:46 +0000 Received: from mail-wi0-f181.google.com ([209.85.212.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZJLWp-0004Ye-8c for linux-arm-kernel@lists.infradead.org; Sun, 26 Jul 2015 12:59:44 +0000 Received: by wibud3 with SMTP id ud3so83403766wib.0 for ; Sun, 26 Jul 2015 05:59:20 -0700 (PDT) X-Received: by 10.194.58.130 with SMTP id r2mr45070143wjq.72.1437915560269; Sun, 26 Jul 2015 05:59:20 -0700 (PDT) Received: from localhost.localdomain (ip16-2-212-87.adsl2.static.versatel.nl. [87.212.2.16]) by smtp.gmail.com with ESMTPSA id gc4sm8142635wib.23.2015.07.26.05.59.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Jul 2015 05:59:19 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, catalin.marinas@arm.com, matt.fleming@intel.com, leif.lindholm@linaro.org, msalter@redhat.com Subject: [PATCH] arm64/efi: map the entire UEFI vendor string before reading it Date: Sun, 26 Jul 2015 14:59:00 +0200 Message-Id: <1437915540-7553-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150726_055943_471176_AABE4343 X-CRM114-Status: GOOD ( 14.07 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.181 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.181 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 At boot, the UTF-16 UEFI vendor string is copied from the system table into a char array with a size of 100 bytes. However, this size of 100 bytes is also used for memremapping() the source, which may not be sufficient if the vendor string exceeds 50 UTF-16 characters, and the placement of the vendor string inside a 4 KB page happens to leave the end unmapped. So use the correct '100 * sizeof(efi_char16_t)' for the size of the mapping. Signed-off-by: Ard Biesheuvel --- Hello Catalin, I think this should go into v4.2 with a cc: stable. Thanks, Ard. arch/arm64/kernel/efi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 9d4aa18f2a82..e8ca6eaedd02 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -122,12 +122,12 @@ static int __init uefi_init(void) /* Show what we know for posterity */ c16 = early_memremap(efi_to_phys(efi.systab->fw_vendor), - sizeof(vendor)); + sizeof(vendor) * sizeof(efi_char16_t)); if (c16) { for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i) vendor[i] = c16[i]; vendor[i] = '\0'; - early_memunmap(c16, sizeof(vendor)); + early_memunmap(c16, sizeof(vendor) * sizeof(efi_char16_t)); } pr_info("EFI v%u.%.02u by %s\n",