Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1071800ybb; Fri, 10 Apr 2020 16:41:54 -0700 (PDT) X-Google-Smtp-Source: APiQypJjFbO5Pi4nbyZFIksdijf1xrmKRzf9WSXl2TrsbDiXRMdNLVEENtyI111xY4hi2/pxpfg1 X-Received: by 2002:a37:8845:: with SMTP id k66mr6317541qkd.322.1586562114008; Fri, 10 Apr 2020 16:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586562113; cv=none; d=google.com; s=arc-20160816; b=q2sxmlhFFigijQO0fRG+gevdMZQTU0mFy20FIKlJhF91gJCGSPsQAVzdXamoRIaHEu UI2iuGEXBeQ7T/rK1ZeGkIxn6AXCXLqQTaGasiBvjhYwEzXC+FgooY1G+C5ICRpYL7C+ ZuVYb2Te9p5ZYZ8JbI6L1CTqE0c4ENCS/cIpK6VDigKBqUu6jc/jrEEPwF3diOQ36oyr izKKQAoliOOGfg+3vJKow4yGSFHTqlKCaD1Otew3pPYeWucKZSwO5oPqGhg37DCMuJVO CagJGDN4tGApnkH03dtXOJHCx+t+Z6Mz4UEISU4GxIyTuAMx/6NyqcoT1grneQJwCPbY EaBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=akC13aQjNgkKQOHvbWZmZ8Y5pEzMr64eRNA8vJ5PYj0=; b=QyGDAWiHqUZl4/4Tpk6xyCcWEWq4R9f98M65K/K7Dy/xuJId8va9fWEjhs6HRieoPP OBaotVj/gS0D3nxO+THy4HlOxVdIOv3knNEy/A89v+xHq1oGNO22T4k1yZLcj9c8nwJs eGY1+CjcvV1O7nXLgSWcOwuHKdVlMNvtl2pgBekmXoS9stpuKVlVQTcE8+ee1Hi0Q5g9 9LFX9Xc5Bi3pko83C+qoSHOjouwc0iaNF6W8fkerElVaNQ6BgUqxVueGWkuMHOdKzNVG pEhFJPhCcCqrVyKHoUeyb+Aah/pPjXVZ5ZuMZnkdRujLXWRUrPx73U7laqSX2FrJBjDD 9D2A== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 129si2261256qkl.110.2020.04.10.16.41.36; Fri, 10 Apr 2020 16:41:53 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726651AbgDJXkq (ORCPT + 99 others); Fri, 10 Apr 2020 19:40:46 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:51694 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726594AbgDJXkq (ORCPT ); Fri, 10 Apr 2020 19:40:46 -0400 Received: (from localhost user: 'macro', uid#1010) by eddie.linux-mips.org with ESMTP id S23992495AbgDJXkmjfjpJ (ORCPT + 1 other); Sat, 11 Apr 2020 01:40:42 +0200 Date: Sat, 11 Apr 2020 00:40:42 +0100 (BST) From: "Maciej W. Rozycki" To: Kees Cook cc: Jiaxun Yang , linux-mips@vger.kernel.org, Fangrui Song , Nathan Chancellor , Thomas Bogendoerfer , Paul Burton , Borislav Petkov , Heiko Carstens , Masahiro Yamada , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH v3] MIPS: Truncate link address into 32bit for 32bit kernel In-Reply-To: <202004101334.A641706F0@keescook> Message-ID: References: <20200407080611.859256-1-jiaxun.yang@flygoat.com> <20200410090634.3513101-1-jiaxun.yang@flygoat.com> <202004101334.A641706F0@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 10 Apr 2020, Kees Cook wrote: > > diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile > > index d6e97df51cfb..0178f7085317 100644 > > --- a/arch/mips/kernel/Makefile > > +++ b/arch/mips/kernel/Makefile > > @@ -112,4 +112,13 @@ obj-$(CONFIG_MIPS_CPC) += mips-cpc.o > > obj-$(CONFIG_CPU_PM) += pm.o > > obj-$(CONFIG_MIPS_CPS_PM) += pm-cps.o > > > > -CPPFLAGS_vmlinux.lds := $(KBUILD_CFLAGS) > > +# 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 = $(VMLINUX_LOAD_ADDRESS) > > +else > > + load-ld = $(shell $(objtree)/arch/mips/tools/truncate32 $(VMLINUX_LOAD_ADDRESS)) > > This is major overkill. Just use the Makefile's builtin text > manipulation: > > load-ld = $(subst 0xffffffff,0x,$(VMLINUX_LOAD_ADDRESS)) This looks like the best approach to me, thank you for the hint! And we only ever want to strip 0xffffffff anyway. (I forgot about this function of `make', doh!) Maciej