From patchwork Mon Feb 6 16:24:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9558345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7E68A602B1 for ; Mon, 6 Feb 2017 16:25:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7191F26D05 for ; Mon, 6 Feb 2017 16:25:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6680627F88; Mon, 6 Feb 2017 16:25:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 9463E26D05 for ; Mon, 6 Feb 2017 16:25:34 +0000 (UTC) Received: (qmail 26578 invoked by uid 550); 6 Feb 2017 16:25:17 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 26515 invoked from network); 6 Feb 2017 16:25:17 -0000 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=8RzRifR54ZQEzOGYkfImc59xBCuqVS+TVkiHfho8Hb4=; b=H8f4cbIHyZsUIGIqj0RwxvNttFKgIELOV1bdex9Pmk4f+sIMMs36A1LPsEjqsUP0/J 4yka8aegV854NI60ID2d6PHoqe1ijoUef++UN3W4Yts2FEyqs9lyMfy/xB5rwcT+up9F 21knm+f1dH2fQ37cr8xAnIW2B/WItH+e14+7E= 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; bh=8RzRifR54ZQEzOGYkfImc59xBCuqVS+TVkiHfho8Hb4=; b=QZ60XUN2Zk/ItAonp0xlJtN2zqcAqBPCZkRX92KCv0xeqxsE/o5l2THiDmZIs2GG3i f9n41NE2k+POHnKK019VqvuZmRewobzYB6voCKzEf/wrF4gQxm1U5UG48RdX0sDtkf2o mJM+AqxjRyMK6zFG8h0Vm5CJtKmE4c4IJh2lKAPyfJjg3ZMLL0V6bBzjXc3+K2uTm1LF UZgJ9ld34psteFnnzE/lZ1MEWgMolMcWkY93tV6x2/6N4aCFsQym427wBmwweGwx+Hrs 23iOhlNW1VzkcRxpCPJ8Jqa00CEdbcBJIeJzwpZNIu3yZu4TgODA2j7vz2pbmELLZRtd oPpA== X-Gm-Message-State: AMke39m/neTxWIiVCNg+Qb9XkjXLlQz38LwXuOGOMRqgGMNY4+pifKXnxg7ca1KShcB5IkyY X-Received: by 10.28.214.137 with SMTP id n131mr8638840wmg.120.1486398305995; Mon, 06 Feb 2017 08:25:05 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com Cc: labbott@fedoraproject.org, kernel-hardening@lists.openwall.com, leif.lindholm@linaro.org, pjones@redhat.com, Ard Biesheuvel Date: Mon, 6 Feb 2017 16:24:32 +0000 Message-Id: <1486398275-3966-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486398275-3966-1-git-send-email-ard.biesheuvel@linaro.org> References: <1486398275-3966-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [kernel-hardening] [PATCH 4/7] arm64: efi: ensure that the PE/COFF header pointer appears at offset 0x3c X-Virus-Scanned: ClamAV using ClamSMTP Use a .org directive to ensure that the PE/COFF header pointer appears at offset 0x3c. Since the EFI header is now emitted using a macro, this helps ensure that the invocation of the macro remains at the correct offset. At the same time, collapse two adjacent #ifdef CONFIG_EFI blocks into one, and replace .word with .long (which are equivalent, but the former is never used elsewhere) Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi-header.S | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/efi-header.S b/arch/arm64/kernel/efi-header.S index 8c8cd0a8192b..74a25c09a1b8 100644 --- a/arch/arm64/kernel/efi-header.S +++ b/arch/arm64/kernel/efi-header.S @@ -22,14 +22,16 @@ .endm .macro __EFI_HEADER -#ifdef CONFIG_EFI - .long pe_header - _head // Offset to the PE header. +#ifndef CONFIG_EFI + .long 0 // reserved #else - .word 0 // reserved -#endif + /* + * PE/COFF requires the offset to the PE header + * to be stored at offset 0x3c into the file. + */ + .org _head + 0x3c + .long pe_header - _head // Offset to the PE header. -#ifdef CONFIG_EFI - .align 3 pe_header: .ascii "PE" .short 0