diff mbox series

[1/1] package/busybox: Fix hwclock for glibc 2.31+

Message ID 20201112164844.18731-1-klaus@linux.vnet.ibm.com
State Accepted
Headers show
Series [1/1] package/busybox: Fix hwclock for glibc 2.31+ | expand

Commit Message

Klaus Heinrich Kiwi Nov. 12, 2020, 4:48 p.m. UTC
Pick the below patch from upstream, in order to fix
'settimeofday: Invalid argument' introduced by using glibc v2.31+.
(busybox hasn't tagged a new version since).

See https://bugs.busybox.net/show_bug.cgi?id=12756 for more info.

---
  commit 1a5d6fcbb5e606ab4acdf22afa26361a25f1d43b
  Author: Eddie James <eajames@linux.ibm.com>

      hwclock: Fix settimeofday for glibc v2.31+
---

Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>

Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
---
 ...ock-Fix-settimeofday-for-glibc-v2.31.patch | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 package/busybox/0003-hwclock-Fix-settimeofday-for-glibc-v2.31.patch

Comments

Peter Korsgaard Nov. 12, 2020, 9:04 p.m. UTC | #1
>>>>> "Klaus" == Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com> writes:

 > Pick the below patch from upstream, in order to fix
 > 'settimeofday: Invalid argument' introduced by using glibc v2.31+.
 > (busybox hasn't tagged a new version since).

 > See https://bugs.busybox.net/show_bug.cgi?id=12756 for more info.

 > ---
 >   commit 1a5d6fcbb5e606ab4acdf22afa26361a25f1d43b
 >   Author: Eddie James <eajames@linux.ibm.com>

 >       hwclock: Fix settimeofday for glibc v2.31+
 > ---
 > +++ b/package/busybox/0003-hwclock-Fix-settimeofday-for-glibc-v2.31.patch
 > @@ -0,0 +1,58 @@
 > +From a4faa9af79c2a0f2b501c0fd507842e4966fc23b Mon Sep 17 00:00:00 2001

How did you end up with a different git hash here?

Committed after fixing that, thanks.
Klaus Heinrich Kiwi Nov. 12, 2020, 10:48 p.m. UTC | #2
On 11/12/2020 6:04 PM, Peter Korsgaard wrote:
>>>>>> "Klaus" == Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com> writes:
>   > ---
>   > +++ b/package/busybox/0003-hwclock-Fix-settimeofday-for-glibc-v2.31.patch
>   > @@ -0,0 +1,58 @@
>   > +From a4faa9af79c2a0f2b501c0fd507842e4966fc23b Mon Sep 17 00:00:00 2001
> 
> How did you end up with a different git hash here?

I took busybox tag 1_32_0, applied the patches found on buildroot/package/busybox,
then cherry-picked the above patch and git format-patch HEAD^

Guess I was being too cautious by applying the patches locally first?

At any rate, I'm sending a second version where I format-patch'ed the patch itself
(i.e., from busybox master), instead of applying it on top of a local 1_32_0 tree
along with other buildroot build-time patches.

> 
> Committed after fixing that, thanks.
> 


Thanks,

  -Klaus
Peter Korsgaard Nov. 13, 2020, 10:03 a.m. UTC | #3
>>>>> "Klaus" == Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com> writes:

 > On 11/12/2020 6:04 PM, Peter Korsgaard wrote:
 >>>>>>> "Klaus" == Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com> writes:
 >> > ---
 >> > +++ b/package/busybox/0003-hwclock-Fix-settimeofday-for-glibc-v2.31.patch
 >> > @@ -0,0 +1,58 @@
 >> > +From a4faa9af79c2a0f2b501c0fd507842e4966fc23b Mon Sep 17 00:00:00 2001
 >> 
 >> How did you end up with a different git hash here?

 > I took busybox tag 1_32_0, applied the patches found on buildroot/package/busybox,
 > then cherry-picked the above patch and git format-patch HEAD^

 > Guess I was being too cautious by applying the patches locally first?

That is also fine, but then use the -x option to git cherry-pick so the
original git hash is tracked.

 > At any rate, I'm sending a second version where I format-patch'ed the patch itself
 > (i.e., from busybox master), instead of applying it on top of a local 1_32_0 tree
 > along with other buildroot build-time patches.

That is not needed as I already applied this patch.

Thanks!
Klaus Heinrich Kiwi Nov. 13, 2020, 12:02 p.m. UTC | #4
On 11/13/2020 7:03 AM, Peter Korsgaard wrote:
> 
> That is also fine, but then use the -x option to git cherry-pick so the
> original git hash is tracked.

Odd, I kinda always automatically cherry-pick with -xs, not sure how I missed that this time.

> 
>   > At any rate, I'm sending a second version where I format-patch'ed the patch itself
>   > (i.e., from busybox master), instead of applying it on top of a local 1_32_0 tree
>   > along with other buildroot build-time patches.
> 
> That is not needed as I already applied this patch.
> 
> Thanks!
> 

Thanks!

I'll send a similar patch to buildroot 2020.08.1 (hopefully this is still active?) and 2020.02.7
(in case it's really affected - need to double check) - but those will require a small change to
apply on top of busybox 1_31_1..

  -Klaus
Peter Korsgaard Nov. 13, 2020, 1:45 p.m. UTC | #5
>>>>> "Klaus" == Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com> writes:

Hi,

 > Thanks!

 > I'll send a similar patch to buildroot 2020.08.1 (hopefully this is
 > still active?) and 2020.02.7 (in case it's really affected - need to
 > double check) - but those will require a small change to apply on top
 > of busybox 1_31_1..

Yes, 2020.02.x (until April 2021) and 2020.08.x (until January 2021) are
still supported. 2020.02.x uses glibc 2.30 though, so it isn't needed
there.
diff mbox series

Patch

diff --git a/package/busybox/0003-hwclock-Fix-settimeofday-for-glibc-v2.31.patch b/package/busybox/0003-hwclock-Fix-settimeofday-for-glibc-v2.31.patch
new file mode 100644
index 0000000000..98a0b01430
--- /dev/null
+++ b/package/busybox/0003-hwclock-Fix-settimeofday-for-glibc-v2.31.patch
@@ -0,0 +1,58 @@ 
+From a4faa9af79c2a0f2b501c0fd507842e4966fc23b Mon Sep 17 00:00:00 2001
+From: Eddie James <eajames@linux.ibm.com>
+Date: Mon, 10 Aug 2020 09:59:02 -0500
+Subject: [PATCH] hwclock: Fix settimeofday for glibc v2.31+
+
+The glibc implementation changed for settimeofday, resulting in "invalid
+argument" error when attempting to set both timezone and time with a single
+call. Fix this by calling settimeofday twice
+
+Signed-off-by: Eddie James <eajames@linux.ibm.com>
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+ util-linux/hwclock.c | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
+index dc97d8fb4..2479e7416 100644
+--- a/util-linux/hwclock.c
++++ b/util-linux/hwclock.c
+@@ -122,16 +122,20 @@ static void to_sys_clock(const char **pp_rtcname, int utc)
+ 	struct timeval tv;
+ 	struct timezone tz;
+ 
+-	tz.tz_minuteswest = timezone/60;
++	tz.tz_minuteswest = timezone / 60;
+ 	/* ^^^ used to also subtract 60*daylight, but it's wrong:
+ 	 * daylight!=0 means "this timezone has some DST
+ 	 * during the year", not "DST is in effect now".
+ 	 */
+ 	tz.tz_dsttime = 0;
+ 
++	/* glibc v2.31+ returns an error if both args are non-NULL */
++	if (settimeofday(NULL, &tz))
++		bb_simple_perror_msg_and_die("settimeofday");
++
+ 	tv.tv_sec = read_rtc(pp_rtcname, NULL, utc);
+ 	tv.tv_usec = 0;
+-	if (settimeofday(&tv, &tz))
++	if (settimeofday(&tv, NULL))
+ 		bb_simple_perror_msg_and_die("settimeofday");
+ }
+ 
+@@ -283,7 +287,11 @@ static void set_system_clock_timezone(int utc)
+ 	gettimeofday(&tv, NULL);
+ 	if (!utc)
+ 		tv.tv_sec += tz.tz_minuteswest * 60;
+-	if (settimeofday(&tv, &tz))
++
++	/* glibc v2.31+ returns an error if both args are non-NULL */
++	if (settimeofday(NULL, &tz))
++		bb_simple_perror_msg_and_die("settimeofday");
++	if (settimeofday(&tv, NULL))
+ 		bb_simple_perror_msg_and_die("settimeofday");
+ }
+ 
+-- 
+2.17.1
+