Skip to contentSkip to conversation

Reproducible builds of xen.gz

PATCH In review Trammell Hudson 2 participants 2 messages Aug 9, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reproducible builds of xen.gz

The mkelf32 executable was using an uninitialized stack buffer for padding after the ehdr and phdr are written to the xen file, which leads to non-deterministic bytes in the binary and prevented Xen hypervisors from being reproducibly built.

Additionally, the file was then compressed with gzip -9 without the -n | --no-name flag, which lead to the xen.gz file having non-deterministric bytes (the timestamp) in the compressed file.

---
 xen/Makefile                | 2 +-
 xen/arch/x86/boot/mkelf32.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/Makefile +1 -1
index ee8ce8e..76b60bc 100644
@@ -121,7 +121,7 @@ _distclean: clean
 	rm -f tags TAGS cscope.files cscope.in.out cscope.out cscope.po.out GTAGS GPATH GRTAGS GSYMS .config
 
 $(TARGET).gz: $(TARGET)
-	gzip -f -9 < $< > [email protected]
+	gzip -n -f -9 < $< > [email protected]
 	mv [email protected] $@
 
 $(TARGET): delete-unfresh-files
xen/arch/x86/boot/mkelf32.c +1 -1
index 6cfa312..e66740f 100644
@@ -260,7 +260,7 @@ int main(int argc, char **argv)
     u32        loadbase, dat_siz, mem_siz, note_base, note_sz, offset;
     char      *inimage, *outimage;
     int        infd, outfd;
-    char       buffer[1024];
+    char       buffer[1024] = {};
     int        bytes, todo, i = 1;
     int        num_phdrs = 1;
 
Signature · 7 lines
2.5.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw

xen/arch/x86/boot/mkelf32.c int main(int argc, char **argv) · line 265

Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 09.08.16 at 16:56, <[email protected]> wrote:
xen/arch/x86/boot/mkelf32.c +1 -1
@@ -260,7 +260,7 @@ int main(int argc, char **argv)
     u32        loadbase, dat_siz, mem_siz, note_base, note_sz, offset;
     char      *inimage, *outimage;
     int        infd, outfd;
-    char       buffer[1024];
+    char       buffer[1024] = {};
     int        bytes, todo, i = 1;
     int        num_phdrs = 1;

This is less of a change than you earlier mail had - did you intentionally strip off the other changes?

Regardless of that,

albeit as said before I'd have preferred this to be two separate patches.

Jan

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