From patchwork Fri Aug 21 19:43:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11730423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED62F138C for ; Fri, 21 Aug 2020 19:55:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C478920791 for ; Fri, 21 Aug 2020 19:55:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="2a5FYZ1t"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Sh9vRY/S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C478920791 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=siXTnPtG/tBFuTO2deYNhRM82Iv6GPJcAcf+LtZB9aE=; b=2a5FYZ1t54LXVHOnUV5GldQPt DlgmviEmxDV7YxMeyMQ0SRwXRJ9I7Ulmn7gF/NqDSi7Ol8PWUGldNbk13Qm8oTWjAlqQlWi+4O4Td z6Hb+V4R9iBROmb8bedtfs+UNT8fyZwxXID7PZdcR4RVsK0m5QDp0JvdCDMXmhajgcUA1KLgYTy4n efaZCuuLcEuU0siv+BjXKAAbas/liQ1HqpQTIJZaJ+ANXIEzQDBGFAtXD3liQAWKVYbTYv9MmW8gG 1vUpsfaUcpsvMnq2OC+fwdtDtjm+jwtn/OI5/y+sP5ZIDSyLElwJ9Puz52Chc7b975eL1ETwSYLkn DiH3d0r0g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k9D8I-0003cD-KF; Fri, 21 Aug 2020 19:55:26 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k9D70-00037E-Qt for linux-arm-kernel@lists.infradead.org; Fri, 21 Aug 2020 19:54:11 +0000 Received: by mail-pj1-x1044.google.com with SMTP id t6so1265469pjr.0 for ; Fri, 21 Aug 2020 12:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0UnndhLoIUPQilO6J2hBojAKmFC4OCA3zcUIp6ZOMro=; b=Sh9vRY/SnIiq5Ijo9twGKuJvIro+2ScdJC7L8hqNb74wvpnUXW74552MBiBf5c9ho/ BOqwZzPM/KRTMkdU/ope8Bau3ipHQ8VZu0l4lmJP8/F6K4yUVcmPySQ5Ug2/EOEQUcoO ZdMtW7Ylxl5Y+uUwL1z39akrMncft2tc4GNeQ= 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=0UnndhLoIUPQilO6J2hBojAKmFC4OCA3zcUIp6ZOMro=; b=gX9oQuDifqlycj9KrB1opYe4o7xSvbmV55w8TzMYKs7ThTbpAmOBENnHxKSaPlMpaf 91icn1XrebUgkiZyH7rz/7WDYtXg/eyWtLDRkrCVQXd03wyIL8RhiogXz7XqIV2wYjGX ewQQ+MWQHFUBU2Pewl4YW2g4j9m3TD6HkPR8x39SR5dklVlSEnf8cOjCGklrrG51RpHo fZeZ+N/fp5LmRf07/WARafeviwEetRas0JHvbSjstSVFhXJAQ1XwAgAp1EUscd6uzzFQ DEEd70D/CuNL1AEw7H/zGRJkUVUlRi8ybzsO1zoGSoJQONqT1YM0jJYXJ9p+cJ3ET3mZ ArvQ== X-Gm-Message-State: AOAM5318XbHp0KFzldb6tFSp2fYMpE3x5yvrWOEodTkGmT1wuD27KSqv nLIUWp6uKDeRZqX9WLCu4PTysA== X-Google-Smtp-Source: ABdhPJwmCnmOTUQk1XKd+olibX9ZOXDXcitcUxjr93v5Do636rUlnfDVQTuwBKBQgeAByyk2C/5Y4Q== X-Received: by 2002:a17:90a:6787:: with SMTP id o7mr3611282pjj.76.1598039644813; Fri, 21 Aug 2020 12:54:04 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id e2sm3424685pfm.37.2020.08.21.12.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:54:02 -0700 (PDT) From: Kees Cook To: Ingo Molnar Subject: [PATCH v6 26/29] x86/boot/compressed: Reorganize zero-size section asserts Date: Fri, 21 Aug 2020 12:43:07 -0700 Message-Id: <20200821194310.3089815-27-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821194310.3089815-1-keescook@chromium.org> References: <20200821194310.3089815-1-keescook@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200821_155406_916489_CF197FCC X-CRM114-Status: GOOD ( 14.41 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, Kees Cook , Arnd Bergmann , Catalin Marinas , Masahiro Yamada , x86@kernel.org, Nick Desaulniers , Russell King , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Arvind Sankar , Ingo Molnar , James Morse , Nathan Chancellor , Borislav Petkov , Peter Collingbourne , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For readability, move the zero-sized sections to the end after DISCARDS. Signed-off-by: Kees Cook --- arch/x86/boot/compressed/vmlinux.lds.S | 44 +++++++++++++++----------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S index 3c2ee9a5bf43..ca544a16724b 100644 --- a/arch/x86/boot/compressed/vmlinux.lds.S +++ b/arch/x86/boot/compressed/vmlinux.lds.S @@ -42,19 +42,6 @@ SECTIONS *(.rodata.*) _erodata = . ; } - .rel.dyn : { - *(.rel.*) - } - .rela.dyn : { - *(.rela.*) - } - .got : { - *(.got) - } - .got.plt : { - *(.got.plt) - } - .data : { _data = . ; *(.data) @@ -85,13 +72,34 @@ SECTIONS ELF_DETAILS DISCARDS -} -ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") + .got.plt (INFO) : { + *(.got.plt) + } + ASSERT(SIZEOF(.got.plt) == 0 || #ifdef CONFIG_X86_64 -ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!") + SIZEOF(.got.plt) == 0x18, #else -ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc, "Unexpected GOT/PLT entries detected!") + SIZEOF(.got.plt) == 0xc, #endif + "Unexpected GOT/PLT entries detected!") + + /* + * Sections that should stay zero sized, which is safer to + * explicitly check instead of blindly discarding. + */ + .got : { + *(.got) + } + ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") + + .rel.dyn : { + *(.rel.*) + } + ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!") -ASSERT(SIZEOF(.rel.dyn) == 0 && SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations detected!") + .rela.dyn : { + *(.rela.*) + } + ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!") +}