Skip to contentSkip to conversation

x86/efi: Do not insert timestamps in efi files

PATCH In review Bernhard M. Wiedemann 4 participants 10 messages Oct 24, 2018 – Oct 26, 2018 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/efi: Do not insert timestamps in efi files

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good.

---
 xen/arch/x86/Makefile | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/Makefile +1 -0
index 162b0b94c0..052bdb1e25 100644
@@ -158,6 +158,7 @@ note.o: $(TARGET)-syms
 
 EFI_LDFLAGS = $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10
 EFI_LDFLAGS += --image-base=$(1) --stack=0,0 --heap=0,0 --strip-debug
+EFI_LDFLAGS += --no-insert-timestamp
 EFI_LDFLAGS += --section-alignment=0x200000 --file-alignment=0x20
 EFI_LDFLAGS += --major-image-version=$(XEN_VERSION)
 EFI_LDFLAGS += --minor-image-version=$(XEN_SUBVERSION)
Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 4 lines · Bernhard M. Wiedemann

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good.

Please follow the MAINTAINERS file and CC the correct people.  I've done so on this email.

Quoted 9 lines
---
 xen/arch/x86/Makefile | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/Makefile +0 -0
index 162b0b94c0..052bdb1e25 100644

xen/arch/x86/Makefile note.o: $(TARGET)-syms · line 164

Quoted 7 lines
xen/arch/x86/Makefile +1 -0
@@ -158,6 +158,7 @@ note.o: $(TARGET)-syms
 
 EFI_LDFLAGS = $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10
 EFI_LDFLAGS += --image-base=$(1) --stack=0,0 --heap=0,0 --strip-debug
+EFI_LDFLAGS += --no-insert-timestamp
 EFI_LDFLAGS += --section-alignment=0x200000 --file-alignment=0x20
 EFI_LDFLAGS += --major-image-version=$(XEN_VERSION)
 EFI_LDFLAGS += --minor-image-version=$(XEN_SUBVERSION)

This change is fine in principle, but do all i386pep compatible versions of LD support this parameter?

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 2 lines · Andrew Cooper

This change is fine in principle, but do all i386pep compatible versions of LD support this parameter?

It seems, it was added in 2014 to GNU binutils when the default was reversed to be unreproducible:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=eeb14e5a5b378450ca2ed139e76f317f491f4613

Don't know about other ld implementations.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 7 lines · Bernhard M. Wiedemann
Quoted 2 lines · Andrew Cooper

This change is fine in principle, but do all i386pep compatible versions of LD support this parameter?

It seems, it was added in 2014 to GNU binutils when the default was reversed to be unreproducible:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=eeb14e5a5b378450ca2ed139e76f317f491f4613

I think adding this unconditionally will break older ld? Keep in mind that our supported binutils dates back to 2005.

Either some sort of filtering is required or we bump the required binutils version. For the former route see ld-ver-build-id in Config.mk.

Wei.

Quoted 2 lines

Don't know about other ld implementations.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

PATCH 1/1 x86/efi: Do not insert timestamps in efi files

In reply to Bernhard M. Wiedemann

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good.

We only add the option, if ld understands it.

---
 Config.mk             | 8 ++++++++
 xen/arch/x86/Makefile | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
Config.mk +8 -0
index 9b13e75a3e..46b064bcae 100644
@@ -151,6 +151,14 @@ export XEN_HAS_BUILD_ID=y
 build_id_linker := --build-id=sha1
 endif
 
+ld-ver-timestamp = $(shell $(1) -mi386pep --no-insert-timestamp 2>&1 | \
+				grep -q no-insert-timestamp && echo n || echo y)
+ifeq ($(call ld-ver-timestamp,$(LD)),n)
+ld_no_insert_timestamp :=
+else
+ld_no_insert_timestamp := --no-insert-timestamp
+endif
+
 ifndef XEN_HAS_CHECKPOLICY
     CHECKPOLICY ?= checkpolicy
     XEN_HAS_CHECKPOLICY := $(shell $(CHECKPOLICY) -h 2>&1 | grep -q xen && echo y || echo n)
xen/arch/x86/Makefile +1 -1
index 162b0b94c0..61ca474179 100644
@@ -157,7 +157,7 @@ note.o: $(TARGET)-syms
 	rm -f [email protected]
 
 EFI_LDFLAGS = $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10
-EFI_LDFLAGS += --image-base=$(1) --stack=0,0 --heap=0,0 --strip-debug
+EFI_LDFLAGS += --image-base=$(1) --stack=0,0 --heap=0,0 --strip-debug $(ld_no_insert_timestamp)
 EFI_LDFLAGS += --section-alignment=0x200000 --file-alignment=0x20
 EFI_LDFLAGS += --major-image-version=$(XEN_VERSION)
 EFI_LDFLAGS += --minor-image-version=$(XEN_SUBVERSION)
Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 24.10.18 at 15:45, <[email protected]> wrote:

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good.

But is this something everyone wants, unconditionally? I'm generally happy to have this basic indication of when a certain image was built; I regret that ELF images have no such indication.

Config.mk export XEN_HAS_BUILD_ID=y · line 160

Quoted 13 lines
Config.mk +7 -0
@@ -151,6 +151,14 @@ export XEN_HAS_BUILD_ID=y
 build_id_linker := --build-id=sha1
 endif
 
+ld-ver-timestamp = $(shell $(1) -mi386pep --no-insert-timestamp 2>&1 | \
+				grep -q no-insert-timestamp && echo n || echo y)
+ifeq ($(call ld-ver-timestamp,$(LD)),n)
+ld_no_insert_timestamp :=
+else
+ld_no_insert_timestamp := --no-insert-timestamp
+endif

Irrespective of build_id_linker also living here - is this the right place? And can't you simplify things by using the common list model, i.e. populate ld_no_insert_timestamp-$(...) and ...

xen/arch/x86/Makefile note.o: $(TARGET)-syms · line 160

Quoted 8 lines
xen/arch/x86/Makefile +1 -1
@@ -157,7 +157,7 @@ note.o: $(TARGET)-syms
 	rm -f [email protected]
 
 EFI_LDFLAGS = $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10
-EFI_LDFLAGS += --image-base=$(1) --stack=0,0 --heap=0,0 --strip-debug
+EFI_LDFLAGS += --image-base=$(1) --stack=0,0 --heap=0,0 --strip-debug $(ld_no_insert_timestamp)

... use $(ld_no_insert_timestamp-y) here?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#9 lore raw
Quoted 7 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 24.10.18 at 15:45, <[email protected]> wrote:

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good.

But is this something everyone wants, unconditionally? I'm generally happy to have this basic indication of when a certain image was built; I regret that ELF images have no such indication.

What practical purpose does having a time stamp serve?  If you really need to see, what is wrong with the mtime in your build tree?

For shipped binaries to customers, exactly when it was built is irrelevant, whereas peoples ability to independently verify the integrity of the binary is important.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#10 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 25.10.18 at 16:00, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 24.10.18 at 15:45, <[email protected]> wrote:

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good.

Quoted 7 lines
Quoted 4 lines

But is this something everyone wants, unconditionally? I'm generally happy to have this basic indication of when a certain image was built; I regret that ELF images have no such indication.

What practical purpose does having a time stamp serve? If you really need to see, what is wrong with the mtime in your build tree?

This can be changed by simple "cp" to another location.

Quoted 3 lines

For shipped binaries to customers, exactly when it was built is irrelevant, whereas peoples ability to independently verify the integrity of the binary is important.

Correct, which is why I appreciate the _option_ of zapping the timestamp.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#11 lore raw
Quoted 7 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 25.10.18 at 16:00, <[email protected]> wrote:

For shipped binaries to customers, exactly when it was built is irrelevant, whereas peoples ability to independently verify the integrity of the binary is important.

Correct, which is why I appreciate the _option_ of zapping the timestamp.

Adding an option for this, would make the (already somewhat ugly) patch even more ugly, so I thought, that fixing it in binutils might be the better way, because other projects will also want to create reproducible PE binaries and we do not want to add such ugly patches to all of them. => https://sourceware.org/ml/binutils/2018-10/msg00279.html

Let's see what they say.

Ciao
Bernhard M.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel