All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@citrix.com>,
	"Bertrand Marquis" <bertrand.marquis@arm.com>,
	"George Dunlap" <George.Dunlap@eu.citrix.com>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Juergen Gross" <jgross@suse.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Wei Liu" <wl@xen.org>
Subject: [PATCH] xen/build: Fix build failure from LDFLAGS mismatch
Date: Tue, 26 Apr 2022 00:06:56 +0100	[thread overview]
Message-ID: <20220425230656.12808-1-andrew.cooper3@citrix.com> (raw)

In a GNU compatbile makefile, $(LDFLAGS) are passed to $(CC), not $(LD).

In a default CentOS 7 build environment, $(LDFLAGS) is set to -Wl,-z,relro,
which causes the Xen build to explode with:

  ld: unrecognized option '-Wl,-z,relro'
  ld: use the --help option for usage information

It turns out that many downstreams identify this as a breakage in Xen's build
system and bodge around it in various ways, mostly by unsetting all of
$(CFLAGS), $(AFLAGS) and $(LDFLAGS).

However, that is a security issue because it means that tools/ is not built
with the distro-wide hardening flags that are otherwise expected of
packages (relro, _FORTIFY_SOURCE, stack-protector, etc).

tools/ specifically should honour the packaging environment's choice of flags,
while xen/ must not pass $(LDFLAGS) to $(LD), and should not be influenced by
the others either.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@citrix.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
CC: Juergen Gross <jgross@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Wei Liu <wl@xen.org>

RFC, because CFLAGS/AFLAGS need nuking too, and they're rather more entangled.
I expect this to cause some disgreement, but Xen is behaving in a very
nonstandard way even among embedded projects and all downstreams are suffering
security problems as a consequence.
---
 xen/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/Makefile b/xen/Makefile
index ec34524ed21d..a8e1de54823b 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -254,6 +254,8 @@ export KBUILD_DEFCONFIG := $(ARCH)_defconfig
 # reparsing Config.mk by e.g. arch/x86/boot/.
 export XEN_TREEWIDE_CFLAGS := $(CFLAGS)
 
+LDFLAGS :=
+
 # CLANG_FLAGS needs to be calculated before calling Kconfig
 ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
 CLANG_FLAGS :=
-- 
2.11.0



             reply	other threads:[~2022-04-25 23:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25 23:06 Andrew Cooper [this message]
2022-04-26  8:04 ` [PATCH] xen/build: Fix build failure from LDFLAGS mismatch Jan Beulich
2022-04-26 10:20 ` Bertrand Marquis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220425230656.12808-1-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=anthony.perard@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.