From patchwork Tue Jan 26 17:10:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 60489 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2089240lbb; Tue, 26 Jan 2016 09:12:20 -0800 (PST) X-Received: by 10.66.129.232 with SMTP id nz8mr35609305pab.102.1453828339862; Tue, 26 Jan 2016 09:12:19 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id os10si3070539pac.121.2016.01.26.09.12.19; Tue, 26 Jan 2016 09:12:19 -0800 (PST) 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; 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; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967134AbcAZRMA (ORCPT + 30 others); Tue, 26 Jan 2016 12:12:00 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38880 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967114AbcAZRLz (ORCPT ); Tue, 26 Jan 2016 12:11:55 -0500 Received: by mail-wm0-f53.google.com with SMTP id b14so141834450wmb.1 for ; Tue, 26 Jan 2016 09:11:54 -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; bh=GopgIHpkL+ihWxHMaHHtS7Qk4z/k3H2Dbrzg+d20Jno=; b=Xp3SzCbBRgrYZm6tOJcnUOoCcSatbDEzZz5+KulhDwW6BKqku9Zf60pCporSkJoAu1 SO7zTflMglhEXhyCcLAzfV1Q7QDplZ6rg2yB0nlxPyV3Ry433abigfGo4oj76tARKzKm EtRGJaEzFhgH8I4BkKNrCemKHaKbIpo0TAvcM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GopgIHpkL+ihWxHMaHHtS7Qk4z/k3H2Dbrzg+d20Jno=; b=SoG2jC9NnMyvNHfy6+W1udj5R/pASA7VqeJo3sMtGYmyOvmSTZ5FsyRc4PG59Av/nX sYuPCm6meHiMVug2TWu7o7LqUfil+C9KFvDhQGH/oKRv/zWN93Lh0WPeSgx2gjfr50oF 7kZHSrUvv1kFB6+JsUceU96ERXfJsIV83n1XA0VvGZX1236cVpNrOXK7U5qNtK/0v+ao thvnReKYyreG3JvSDLaRJWOhqoSdfBeZ2T0cMR291Oi7ImYJo1qXg0A0q3fmmWpibSj3 h0a1hdIasde9/SoECHrMESYLEzNtBUm3KprZYXECm5ItJKkqiZuypJbOluGPZnpyr/fL t99w== X-Gm-Message-State: AG10YOTU1lTowYj6m4yhPpmK4fMudq5ZZb1T5HJh+Y+2Xh4w69UQhMufICgCsYsCNG4p3Ra7 X-Received: by 10.194.119.68 with SMTP id ks4mr23981708wjb.45.1453828314151; Tue, 26 Jan 2016 09:11:54 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id ko2sm2328617wjc.9.2016.01.26.09.11.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Jan 2016 09:11:53 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com, will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, leif.lindholm@linaro.org, keescook@chromium.org, linux-kernel@vger.kernel.org Cc: stuart.yoder@freescale.com, bhupesh.sharma@freescale.com, arnd@arndb.de, marc.zyngier@arm.com, christoffer.dall@linaro.org, labbott@fedoraproject.org, matt@codeblueprint.co.uk, Ard Biesheuvel Subject: [PATCH v4 21/22] efi: stub: use high allocation for converted command line Date: Tue, 26 Jan 2016 18:10:48 +0100 Message-Id: <1453828249-14467-22-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453828249-14467-1-git-send-email-ard.biesheuvel@linaro.org> References: <1453828249-14467-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before we can move the command line processing before the allocation of the kernel, which is required for detecting the 'nokaslr' option which controls that allocation, move the converted command line higher up in memory, to prevent it from interfering with the kernel itself. Since x86 needs the address to fit in 32 bits, use UINT_MAX as the upper bound there. Otherwise, use ULONG_MAX (i.e., no limit) Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/x86/include/asm/efi.h | 2 ++ drivers/firmware/efi/libstub/efi-stub-helper.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) -- 2.5.0 diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 0010c78c4998..08b1f2f6ea50 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -25,6 +25,8 @@ #define EFI32_LOADER_SIGNATURE "EL32" #define EFI64_LOADER_SIGNATURE "EL64" +#define MAX_CMDLINE_ADDRESS UINT_MAX + #ifdef CONFIG_X86_32 diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index f07d4a67fa76..29ed2f9b218c 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -649,6 +649,10 @@ static u8 *efi_utf16_to_utf8(u8 *dst, const u16 *src, int n) return dst; } +#ifndef MAX_CMDLINE_ADDRESS +#define MAX_CMDLINE_ADDRESS ULONG_MAX +#endif + /* * Convert the unicode UEFI command line to ASCII to pass to kernel. * Size of memory allocated return in *cmd_line_len. @@ -684,7 +688,8 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, options_bytes++; /* NUL termination */ - status = efi_low_alloc(sys_table_arg, options_bytes, 0, &cmdline_addr); + status = efi_high_alloc(sys_table_arg, options_bytes, 0, + &cmdline_addr, MAX_CMDLINE_ADDRESS); if (status != EFI_SUCCESS) return NULL;