NetBSD Problem Report #57914
From www@netbsd.org Fri Feb 9 07:03:57 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id CFE971A9238
for <gnats-bugs@gnats.NetBSD.org>; Fri, 9 Feb 2024 07:03:57 +0000 (UTC)
Message-Id: <20240209070356.3DE1B1A9239@mollari.NetBSD.org>
Date: Fri, 9 Feb 2024 07:03:56 +0000 (UTC)
From: jbglaw@lug-owl.de
Reply-To: jbglaw@lug-owl.de
To: gnats-bugs@NetBSD.org
Subject: [RB] evbarm/earmv4eb mkubootimage: Set reproducible timestamp
X-Send-Pr-Version: www-1.0
>Number: 57914
>Category: misc
>Synopsis: [RB] evbarm/earmv4eb mkubootimage: Set reproducible timestamp
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: misc-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Feb 09 07:05:00 +0000 2024
>Last-Modified: Fri Feb 09 16:15:02 +0000 2024
>Originator: Jan-Benedict Glaw
>Release: current
>Organization:
>Environment:
>Description:
uBoot images contain (build) timestamps. For reproducible builds, use the top commit's timestamp instead.
>How-To-Repeat:
Build twice, compare build artifacts.
>Fix:
index 3a101134aaa2..9ef4c3eb15a4 100644
--- a/distrib/evbarm/instkernel/ramdisk/Makefile
+++ b/distrib/evbarm/instkernel/ramdisk/Makefile
@@ -34,6 +34,10 @@ UBOOT_IMAGE_ARCH= arm64
UBOOT_IMAGE_ARCH= arm
.endif
+.if ${MKREPRO_TIMESTAMP:Uno} != "no"
+MKUBOOTIMAGE_TIMESTAMP=-t "${MKREPRO_TIMESTAMP}"
+.endif
+
# Use stubs to eliminate some large stuff from libc
HACKSRC= ${DISTRIBDIR}/utils/libhack
.include "${HACKSRC}/Makefile.inc"
@@ -50,7 +54,7 @@ release: ${IMAGE}
${INSTALL} -d -m 755 ${RAMDISKDIR}
${RELEASE_INSTALL} ${IMAGE} ${RAMDISKDIR}
${TOOL_MKUBOOTIMAGE} -A ${UBOOT_IMAGE_ARCH} -C none -O linux \
- -T ramdisk -a 0 -n "NetBSD/${MACHINE_ARCH} ramdisk" ${IMAGE} \
- ${RAMDISKDIR}/${IMAGE:S/.fs/.ub/}
+ -T ramdisk -a 0 -n "NetBSD/${MACHINE_ARCH} ramdisk" \
+ ${MKUBOOTIMAGE_TIMESTAMP} ${IMAGE} ${RAMDISKDIR}/${IMAGE:S/.fs/.ub/}
.include <bsd.prog.mk>
diff --git a/usr.bin/mkubootimage/mkubootimage.1 b/usr.bin/mkubootimage/mkubootimage.1
index a02e34d8160d..82dae3247e02 100644
--- a/usr.bin/mkubootimage/mkubootimage.1
+++ b/usr.bin/mkubootimage/mkubootimage.1
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd December 4, 2019
+.Dd February 7, 2024
.Dt MKUBOOTIMAGE 1
.Os
.Sh NAME
@@ -119,6 +119,8 @@ This is required.
Defines the operating system type.
The default OS name is
.Qq netbsd .
+.It Fl t Ar epoch
+Use given epoch timestamp as image creation time. (This is only used for legacy U-Boot images.)
.It Fl T No ( fs Ns | Ns kernel Ns | Ns kernel_noload Ns | Ns ramdisk Ns | Ns script Ns | Ns standalone )
Defines the image type.
This is required for
diff --git a/usr.bin/mkubootimage/mkubootimage.c b/usr.bin/mkubootimage/mkubootimage.c
index b7ebcb6d7abe..15f1dd16f4fe 100644
--- a/usr.bin/mkubootimage/mkubootimage.c
+++ b/usr.bin/mkubootimage/mkubootimage.c
@@ -266,7 +266,7 @@ usage(void)
{
fprintf(stderr, "usage: mkubootimage [-hu] -A "
"<arm|arm64|i386|mips|mips64|or1k|powerpc|sh> -a address\n");
- fprintf(stderr, "\t-C <bz2|gz|lzma|lzo|none> [-E address] [-e address]\n");
+ fprintf(stderr, "\t-C <bz2|gz|lzma|lzo|none> [-E address] [-e address] [ -t epoch]\n");
fprintf(stderr, "\t[-f <arm64|uimg>] [-m magic] -n image -O <freebsd|linux|netbsd|openbsd>\n");
fprintf(stderr, "\t-T <fs|kernel|kernel_noload|ramdisk|script|standalone>\n");
fprintf(stderr, "\tsource destination\n");
@@ -298,7 +298,7 @@ dump_header_uimg(struct uboot_image_header *hdr)
}
static int
-generate_header_uimg(struct uboot_image_header *hdr, int kernel_fd)
+generate_header_uimg(struct uboot_image_header *hdr, time_t repro_time, int kernel_fd)
{
uint8_t *p;
struct stat st;
@@ -342,7 +342,7 @@ generate_header_uimg(struct uboot_image_header *hdr, int kernel_fd)
memset(hdr, 0, sizeof(*hdr));
hdr->ih_magic = htonl(image_magic);
- hdr->ih_time = htonl(st.st_mtime);
+ hdr->ih_time = htonl(repro_time? repro_time: st.st_mtime);
hdr->ih_size = htonl(dsize);
hdr->ih_load = htonl(image_loadaddr);
hdr->ih_ep = htonl(image_entrypoint);
@@ -462,8 +462,9 @@ main(int argc, char *argv[])
int kernel_fd, image_fd;
int ch;
unsigned long long num;
+ time_t repro_time = 0;
- while ((ch = getopt(argc, argv, "A:C:E:O:T:a:e:f:hm:n:u")) != -1) {
+ while ((ch = getopt(argc, argv, "A:C:E:O:T:a:e:f:hm:n:ut:")) != -1) {
switch (ch) {
case 'A': /* arch */
image_arch = get_arch(optarg);
@@ -474,6 +475,9 @@ main(int argc, char *argv[])
case 'O': /* os */
image_os = get_os(optarg);
break;
+ case 't': /* FS timestamp */
+ repro_time = atol(optarg);
+ break;
case 'T': /* type */
image_type = get_type(optarg);
break;
@@ -584,7 +588,7 @@ main(int argc, char *argv[])
switch (image_format) {
case FMT_UIMG:
- if (generate_header_uimg(&hdr_uimg, kernel_fd) != 0)
+ if (generate_header_uimg(&hdr_uimg, repro_time, kernel_fd) != 0)
return EXIT_FAILURE;
if (write_image(&hdr_uimg, sizeof(hdr_uimg),
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57914 CVS commit: src/usr.bin/mkubootimage
Date: Fri, 9 Feb 2024 11:10:18 -0500
Module Name: src
Committed By: christos
Date: Fri Feb 9 16:10:18 UTC 2024
Modified Files:
src/usr.bin/mkubootimage: crc32.c mkubootimage.1 mkubootimage.c
Added Files:
src/usr.bin/mkubootimage: crc32.h
Log Message:
PR/57914: Jan-Benedict Glaw: Set reproducible timestamp
Cleanup lint.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/mkubootimage/crc32.c
cvs rdiff -u -r0 -r1.1 src/usr.bin/mkubootimage/crc32.h
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/mkubootimage/mkubootimage.1
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/mkubootimage/mkubootimage.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.