Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2649177pxj; Mon, 14 Jun 2021 04:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmfzsT+kAPOL1qtHqkRqtFGeJE6FtHMpcvjQpLo5Z8G7XYAAynKfv0Tk4c+H1JT7A0agQf X-Received: by 2002:a17:906:bc2:: with SMTP id y2mr14497784ejg.489.1623668519205; Mon, 14 Jun 2021 04:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623668519; cv=none; d=google.com; s=arc-20160816; b=yBI157Ju96E6vaxk2/QMhkyZTpznQj0wNBjNk/68+zyPCgI8/SYsk43TR1245Ww/FG FauwOwM9qbdvk56blLLWW0/4jonb5LDtyYYyDglHTd/nFnbVYiJUNQadzOCtXC9YUzkD h1GmY6yTe95cwennpVx3aQeeNMNN9PhO9TkLb6Boafnt24iuUWL9muX5H92rKJyGhKTi ct5U3vlwlS9JNoIvHte2mFitc41v/sA7ICdDiv/0Tnn93M7eCExSvtvfqMTTBg08Hlfn 5INZFEWQ6KA8cJitglTdDMWLBSe/B4kmoG5rrJy2Uz7LfaSA2bTotCzaolIM2F/zonNT W85w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gnv4mdrdhYXhD7nHLogxWv41GWaYQX080cs9vhzI47Q=; b=CN824MEr5bJ8eywdx7/u8n8+n3BIa2wnN8Ju0RiUFwZOPj/6hcu/zmOWPK+XrRA2oj X0Qdx5obs0Ng4oQkz+lr302tSnKr9SqW4/sMRCseSL9IGQ0leZVMXt44KS2831QKlXQg GFOH87SBiQUdkTuO0yVXyF1Qrk1YOpWAUWCeh5kpVjwBdKUEQn/E2625qS1SQifl8ERe jTN8qncJxwgwz9nBDWnGJJ/f5iJXG5REieDqtcP1rkgoDtsL7Kc1zMEj7esY4cp81BFv stanBKbO+UV0CwFYROKrRv3Okd3qFfspz7pZ/VNuFOt1D9QtHVc4JLo8svSN06Cuddib AYaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hdhMLy9D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yd14si9147062ejb.245.2021.06.14.04.01.35; Mon, 14 Jun 2021 04:01:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hdhMLy9D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234888AbhFNK71 (ORCPT + 99 others); Mon, 14 Jun 2021 06:59:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:52160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234090AbhFNKus (ORCPT ); Mon, 14 Jun 2021 06:50:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A988061461; Mon, 14 Jun 2021 10:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667125; bh=sfOW8B2JXyu0ZkaHdx8JEUteKmzxI01AuoO2Fvsr/Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hdhMLy9DBmbQRdvbsseklTDW7DRaYo7wH3akLB4ivTQGOd1Srb5Lhv9naJ/5rn4L7 39jZ5yl+17DFIdMC3aKW9qEdSJ1oyCtJ30NHn4Nv1poCMrz17/hzXbL4ycFBDkfv+K 9xP4X0slFlXxhPndrpsM4ZpboZcMi3LfeoWeJF38= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arvind Sankar , Kees Cook , Ingo Molnar , Nick Desaulniers , Sedat Dilek , Ard Biesheuvel , Fangrui Song Subject: [PATCH 5.4 37/84] x86/boot: Add .text.* to setup.ld Date: Mon, 14 Jun 2021 12:27:15 +0200 Message-Id: <20210614102647.625527026@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102646.341387537@linuxfoundation.org> References: <20210614102646.341387537@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arvind Sankar commit 2e7a858ba843d2e6ceab1ba996805411de51b340 upstream. GCC puts the main function into .text.startup when compiled with -Os (or -O2). This results in arch/x86/boot/main.c having a .text.startup section which is currently not included explicitly in the linker script setup.ld in the same directory. The BFD linker places this orphan section immediately after .text, so this still works. However, LLD git, since [1], is choosing to place it immediately after the .bstext section instead (this is the first code section). This plays havoc with the section layout that setup.elf requires to create the setup header, for eg on 64-bit: LD arch/x86/boot/setup.elf ld.lld: error: section .text.startup file range overlaps with .header >>> .text.startup range is [0x200040, 0x2001FE] >>> .header range is [0x2001EF, 0x20026B] ld.lld: error: section .header file range overlaps with .bsdata >>> .header range is [0x2001EF, 0x20026B] >>> .bsdata range is [0x2001FF, 0x200398] ld.lld: error: section .bsdata file range overlaps with .entrytext >>> .bsdata range is [0x2001FF, 0x200398] >>> .entrytext range is [0x20026C, 0x2002D3] ld.lld: error: section .text.startup virtual address range overlaps with .header >>> .text.startup range is [0x40, 0x1FE] >>> .header range is [0x1EF, 0x26B] ld.lld: error: section .header virtual address range overlaps with .bsdata >>> .header range is [0x1EF, 0x26B] >>> .bsdata range is [0x1FF, 0x398] ld.lld: error: section .bsdata virtual address range overlaps with .entrytext >>> .bsdata range is [0x1FF, 0x398] >>> .entrytext range is [0x26C, 0x2D3] ld.lld: error: section .text.startup load address range overlaps with .header >>> .text.startup range is [0x40, 0x1FE] >>> .header range is [0x1EF, 0x26B] ld.lld: error: section .header load address range overlaps with .bsdata >>> .header range is [0x1EF, 0x26B] >>> .bsdata range is [0x1FF, 0x398] ld.lld: error: section .bsdata load address range overlaps with .entrytext >>> .bsdata range is [0x1FF, 0x398] >>> .entrytext range is [0x26C, 0x2D3] Add .text.* to the .text output section to fix this, and also prevent any future surprises if the compiler decides to create other such sections. [1] https://reviews.llvm.org/D75225 Signed-off-by: Arvind Sankar Signed-off-by: Kees Cook Signed-off-by: Ingo Molnar Tested-by: Nick Desaulniers Tested-by: Sedat Dilek Reviewed-by: Kees Cook Reviewed-by: Ard Biesheuvel Reviewed-by: Fangrui Song Link: https://lore.kernel.org/r/20200731230820.1742553-5-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/boot/setup.ld | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/boot/setup.ld +++ b/arch/x86/boot/setup.ld @@ -20,7 +20,7 @@ SECTIONS .initdata : { *(.initdata) } __end_init = .; - .text : { *(.text) } + .text : { *(.text .text.*) } .text32 : { *(.text32) } . = ALIGN(16);