summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2025-05-20 23:20:02 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-05-22 14:36:49 +0100
commitee22a23e989c6f3edc4a1c28a3fa6da4e981024c (patch)
treef1b006ba2d529e0dac065854a531c875f134a92e
parent2dfdcf7891b4af80fe53b1d85c3c625a690e25b0 (diff)
downloadpoky-ee22a23e989c6f3edc4a1c28a3fa6da4e981024c.tar.gz
busybox: Fix build on architectures without SYS_settimeofday
Fixes following errors on riscv32/musl | util-linux/hwclock.c:143:20: error: use of undeclared identifier 'SYS_settimeofday' | 143 | int ret = syscall(SYS_settimeofday, NULL, tz); | | ^ | 1 error generated. (From OE-Core rev: 2d19a43c18c2c5b87e9a99f4c672ca7c6a202b80) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/busybox/busybox/0001-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch52
-rw-r--r--meta/recipes-core/busybox/busybox_1.37.0.bb1
2 files changed, 53 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch b/meta/recipes-core/busybox/busybox/0001-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch
new file mode 100644
index 0000000000..11ef2b6824
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0001-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch
@@ -0,0 +1,52 @@
1From 4e1eafc6e0de3e58cac9f62e57b552eddb50ca8e Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 7 Mar 2021 17:30:24 -0800
4Subject: [PATCH] hwclock: Check for SYS_settimeofday before calling syscall
5
6Some newer architectures e.g. RISCV32 have 64bit time_t from get go and
7thusly do not have gettimeofday_time64/settimeofday_time64 implemented
8therefore check for SYS_settimeofday definition before making the
9syscall. Fixes build for riscv32 and it will bail out at runtime.
10
11This issue has been discussed on the musl mailing list, and
12the musl developers' opinion is that Busybox is wrong:
13
14https://www.openwall.com/lists/musl/2024/03/03/2
15https://www.openwall.com/lists/musl/2024/04/07/2
16
17The correct fix isn't clear, and in the mean time, the patch
18turns the build issue into a runtime error only on the problematic
19architecture (riscv32), which seems like a reasonable trade-off
20
21Upstream-Status: Submitted [http://lists.busybox.net/pipermail/busybox/2021-March/088583.html]]
22Signed-off-by: Khem Raj <raj.khem@gmail.com>
23---
24 util-linux/hwclock.c | 7 +++++--
25 1 file changed, 5 insertions(+), 2 deletions(-)
26
27diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
28index c3fd0eb57..dea9c9a55 100644
29--- a/util-linux/hwclock.c
30+++ b/util-linux/hwclock.c
31@@ -132,6 +132,7 @@ static void show_clock(const char **pp_rtcname, int utc)
32
33 static void set_kernel_tz(const struct timezone *tz)
34 {
35+ int ret = 1;
36 #if LIBC_IS_MUSL
37 /* musl libc does not pass tz argument to syscall
38 * because "it's deprecated by POSIX, therefore it's fine
39@@ -140,9 +141,11 @@ static void set_kernel_tz(const struct timezone *tz)
40 #if !defined(SYS_settimeofday) && defined(SYS_settimeofday_time32)
41 # define SYS_settimeofday SYS_settimeofday_time32
42 #endif
43- int ret = syscall(SYS_settimeofday, NULL, tz);
44+#if defined(SYS_settimeofday)
45+ ret = syscall(SYS_settimeofday, NULL, tz);
46+#endif
47 #else
48- int ret = settimeofday(NULL, tz);
49+ ret = settimeofday(NULL, tz);
50 #endif
51 if (ret)
52 bb_simple_perror_msg_and_die("settimeofday");
diff --git a/meta/recipes-core/busybox/busybox_1.37.0.bb b/meta/recipes-core/busybox/busybox_1.37.0.bb
index 85f22ada53..9f7ded3354 100644
--- a/meta/recipes-core/busybox/busybox_1.37.0.bb
+++ b/meta/recipes-core/busybox/busybox_1.37.0.bb
@@ -54,6 +54,7 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
54 file://0002-start-stop-daemon-fix-tests.patch \ 54 file://0002-start-stop-daemon-fix-tests.patch \
55 file://0003-start-stop-false.patch \ 55 file://0003-start-stop-false.patch \
56 file://0001-archival-disallow-path-traversals-CVE-2023-39810.patch \ 56 file://0001-archival-disallow-path-traversals-CVE-2023-39810.patch \
57 file://0001-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch \
57 " 58 "
58SRC_URI:append:libc-musl = " file://musl.cfg" 59SRC_URI:append:libc-musl = " file://musl.cfg"
59SRC_URI:append:x86-64 = " file://sha_accel.cfg" 60SRC_URI:append:x86-64 = " file://sha_accel.cfg"