From: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
To: masahiroy@kernel.org, bgray@linux.ibm.com, ajd@linux.ibm.com,
n.schier@avm.de
Cc: paulo.miguel.almeida.rodenas@gmail.com,
linux-kernel@vger.kernel.org, keescook@chromium.org
Subject: [PATCH] [next] initramfs: Parse KBUILD_BUILD_TIMESTAMP as UTC date
Date: Sat, 29 Jul 2023 17:02:09 +1200 [thread overview]
Message-ID: <ZMSdUS37BD5b/dn7@mail.google.com> (raw)
When KBUILD_BUILD_TIMESTAMP is specified, the date command will parse
it to Unix Epoch time in UTC. However, the date command is
timezone-aware so it will convert from the local timezone to UTC first
which hits some of the sanity checks added on commit 5efb685bb3af1
("initramfs: Check negative timestamp to prevent broken cpio archive")
This creates an edge case for the UTC+<N> part of the world. For instance
- In New Zealand (UTC+12:00):
$ date -d"1970-01-01" +%s
-43200
$ make KBUILD_BUILD_TIMESTAMP=1970-01-01
make[1]: Entering directory '<snip>/linux/'
GEN Makefile
DESCEND objtool
INSTALL libsubcmd_headers
CALL ../scripts/checksyscalls.sh
GEN usr/initramfs_data.cpio
ERROR: Timestamp out of range for cpio format
make[4]: *** [../usr/Makefile:76: usr/initramfs_data.cpio] Error 1
- In Seattle, WA (UTC-07:00):
$ date -d"1970-01-01" +%s
32400
$ make KBUILD_BUILD_TIMESTAMP=1970-01-01
<builds fine>
Parse KBUILD_BUILD_TIMESTAMP date string as UTC so no localtime
conversion is done which fixes the edge case aforementioned.
Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
---
usr/gen_initramfs.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh
index 14b5782f961a..a90316d9a080 100755
--- a/usr/gen_initramfs.sh
+++ b/usr/gen_initramfs.sh
@@ -221,7 +221,7 @@ while [ $# -gt 0 ]; do
shift
;;
"-d") # date for file mtimes
- timestamp="$(date -d"$1" +%s || :)"
+ timestamp="$(date -d"$1" -u +%s || :)"
if test -n "$timestamp"; then
timestamp="-t $timestamp"
fi
--
2.40.1
next reply other threads:[~2023-07-29 5:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-29 5:02 Paulo Miguel Almeida [this message]
2023-08-16 6:38 ` [PATCH] [next] initramfs: Parse KBUILD_BUILD_TIMESTAMP as UTC date Nicolas Schier
2023-08-18 0:32 ` Andrew Donnellan
2023-08-21 7:45 ` Paulo Miguel Almeida
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=ZMSdUS37BD5b/dn7@mail.google.com \
--to=paulo.miguel.almeida.rodenas@gmail.com \
--cc=ajd@linux.ibm.com \
--cc=bgray@linux.ibm.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=n.schier@avm.de \
/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.