Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp997490ybt; Fri, 19 Jun 2020 21:03:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvDVrShicjzPM8j4zv13zppUN7Suh0e5hlTKL2WaDR5roAakMQ/C/1o3NPTh9wKSmyIm9Y X-Received: by 2002:a17:906:241b:: with SMTP id z27mr6378032eja.267.1592625811710; Fri, 19 Jun 2020 21:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592625811; cv=none; d=google.com; s=arc-20160816; b=hQ/HrNSZ4kmfdoWwRVBZQmuhlO+X0SEbFIhh1TiLFE8vc2P0w1zrnYbNns3M7moRpb WHhkpDrfzKya3cJ8nXrErpqZsC2Hy02SJLlIboR96avG4TxE1O+4sa95CuoVq7q6YTHG Bs0YzQAoquJsEkAvhXlePdNnc22cJFwAW2iNTA0XS32eRPYSuZZ0K0FAo6YSnVWsAJWt DUTIS/3TSymO20rmBOuR9mk++qR37cNeHyGgMNIYKkmGfB6uHCP57bz4a7WllHX7+Slg HpWqNTScef02QtuOEM+hbT84qYEUkOL+4ediQ+VRNmatjnlt5Thzs2Awk++MSOcsC7r3 KLtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jUu9W7+LjpN35Nam+nMJC9T3rzC1U/UIx4XGhEjEY3w=; b=zNESUmw6+ykIHFbOLnobcvMZeeZsTwK7EClKuLOaBDo9q1q4rZSyQN7bfUdYNhvNLG yZRhn84dDcPK1m3mh9ro+aJBgFJiEKh+ZVc3wEuwOS1ouO0CTYDIXXRdqUB+QpMXh3jK 6lq/BSHQpGLTeIDLbHTWADHzgpHpWu5caiDxKJl8MzbTBpyVNDA6hYrqL2wMHO5L/TyX etByghBgYO2kjBEsFrrYMC2wmjzu+Z0BKpBZ23TUjYfb1tq3UPjdiCf4fyFV3VHW8rMg hYJ4150vZBIUN/XOWXZRwrjOSnyZJIBQF6OaaSDgMgWptehBhOnPEiiveIZ1VgCo5ZeO AneA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rfi0WfGz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si6051381edl.218.2020.06.19.21.03.09; Fri, 19 Jun 2020 21:03:31 -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=@kernel.org header.s=default header.b=rfi0WfGz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395218AbgFSQff (ORCPT + 99 others); Fri, 19 Jun 2020 12:35:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:42344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387935AbgFSOtm (ORCPT ); Fri, 19 Jun 2020 10:49:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E069920DD4; Fri, 19 Jun 2020 14:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578182; bh=VBKWQ5iLv1fYJthBSpg/mc/0FfYgJ1CTvw8ww/USsgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rfi0WfGzdeP+8KtVsECu2Vp74etXfhv7NJXe+hgRTL6f/G4IElC/3NO7wNDkatVCg igSBFqlbju1EV0tHRJr7T9VlTqrCk+jUyOXCeV2JAUnzpeiOKb9wXQtl1qgG/HUEe6 17ofgKm0x5hrBfdGruZRxACNVj+WZsiGwJOwHV7k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiaxun Yang , Fangrui Song , Kees Cook , Nathan Chancellor , "Maciej W. Rozycki" , Nick Desaulniers , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 4.14 114/190] MIPS: Truncate link address into 32bit for 32bit kernel Date: Fri, 19 Jun 2020 16:32:39 +0200 Message-Id: <20200619141639.329046102@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141633.446429600@linuxfoundation.org> References: <20200619141633.446429600@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiaxun Yang [ Upstream commit ff487d41036035376e47972c7c522490b839ab37 ] LLD failed to link vmlinux with 64bit load address for 32bit ELF while bfd will strip 64bit address into 32bit silently. To fix LLD build, we should truncate load address provided by platform into 32bit for 32bit kernel. Signed-off-by: Jiaxun Yang Link: https://github.com/ClangBuiltLinux/linux/issues/786 Link: https://sourceware.org/bugzilla/show_bug.cgi?id=25784 Reviewed-by: Fangrui Song Reviewed-by: Kees Cook Tested-by: Nathan Chancellor Cc: Maciej W. Rozycki Tested-by: Nick Desaulniers Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/Makefile | 13 ++++++++++++- arch/mips/boot/compressed/Makefile | 2 +- arch/mips/kernel/vmlinux.lds.S | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 5977884b008e..a4a06d173858 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -279,12 +279,23 @@ ifdef CONFIG_64BIT endif endif +# When linking a 32-bit executable the LLVM linker cannot cope with a +# 32-bit load address that has been sign-extended to 64 bits. Simply +# remove the upper 32 bits then, as it is safe to do so with other +# linkers. +ifdef CONFIG_64BIT + load-ld = $(load-y) +else + load-ld = $(subst 0xffffffff,0x,$(load-y)) +endif + KBUILD_AFLAGS += $(cflags-y) KBUILD_CFLAGS += $(cflags-y) -KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y) +KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y) -DLINKER_LOAD_ADDRESS=$(load-ld) KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0) bootvars-y = VMLINUX_LOAD_ADDRESS=$(load-y) \ + LINKER_LOAD_ADDRESS=$(load-ld) \ VMLINUX_ENTRY_ADDRESS=$(entry-y) \ PLATFORM="$(platform-y)" \ ITS_INPUTS="$(its-y)" diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index baa34e4deb78..516e593a8ee9 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -87,7 +87,7 @@ ifneq ($(zload-y),) VMLINUZ_LOAD_ADDRESS := $(zload-y) else VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ - $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS)) + $(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS)) endif UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 36f2e860ba3e..be63fff95b2a 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -50,7 +50,7 @@ SECTIONS /* . = 0xa800000000300000; */ . = 0xffffffff80300000; #endif - . = VMLINUX_LOAD_ADDRESS; + . = LINKER_LOAD_ADDRESS; /* read-only */ _text = .; /* Text and read-only data */ .text : { -- 2.25.1