diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2020-12-17 02:09:10 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-12-20 00:03:04 +0000 |
commit | 8c4e5c046625daa64501a968c17670bee8ccb9aa (patch) | |
tree | 3bc1bf9df1d5bdfb40c0240a6dbb73c795eccc2b | |
parent | 87b38ee1c14d5fa0d4ad8256b1828fb218951bdd (diff) | |
download | poky-8c4e5c046625daa64501a968c17670bee8ccb9aa.tar.gz |
glibc: Make adjtime() for 32 bit support being called with delta == NULL
This backports a fix from glibc's master branch, which solves a
regression in 2.32 with adjtime() where it would seg fault if being
called with delta == NULL on 32 bit machines.
(From OE-Core rev: aeecccf17c45c840c070e2de95c602a3c7e9d30e)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-core/glibc/glibc/0031-linux-Allow-adjtime-with-NULL-argument-BZ-26833.patch | 110 | ||||
-rw-r--r-- | meta/recipes-core/glibc/glibc_2.32.bb | 1 |
2 files changed, 111 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/0031-linux-Allow-adjtime-with-NULL-argument-BZ-26833.patch b/meta/recipes-core/glibc/glibc/0031-linux-Allow-adjtime-with-NULL-argument-BZ-26833.patch new file mode 100644 index 0000000000..a458a2a223 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0031-linux-Allow-adjtime-with-NULL-argument-BZ-26833.patch | |||
@@ -0,0 +1,110 @@ | |||
1 | From 75a193b7611bade31a150dfcc528b973e3d46231 Mon Sep 17 00:00:00 2001 | ||
2 | From: Adhemerval Zanella <adhemerval.zanella@linaro.org> | ||
3 | Date: Mon, 2 Nov 2020 16:18:29 -0300 | ||
4 | Subject: [PATCH] linux: Allow adjtime with NULL argument [BZ #26833] | ||
5 | |||
6 | The adjtime interface allows return the amount of time remaining | ||
7 | from any previous adjustment that has not yet been completed by | ||
8 | passing a NULL as first argument. This was introduced with y2038 | ||
9 | support 0308077e3a. | ||
10 | |||
11 | Checked on i686-linux-gnu. | ||
12 | |||
13 | Reviewed-by: Lukasz Majewski <lukma@denx.de> | ||
14 | Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=75a193b7611bade31a150dfcc528b973e3d46231] | ||
15 | Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> | ||
16 | --- | ||
17 | sysdeps/unix/sysv/linux/adjtime.c | 11 +++++--- | ||
18 | time/Makefile | 3 ++- | ||
19 | time/tst-adjtime.c | 44 +++++++++++++++++++++++++++++++ | ||
20 | 3 files changed, 54 insertions(+), 4 deletions(-) | ||
21 | create mode 100644 time/tst-adjtime.c | ||
22 | |||
23 | diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c | ||
24 | index 3f9a4ea2eb..6d1d1b6af2 100644 | ||
25 | --- a/sysdeps/unix/sysv/linux/adjtime.c | ||
26 | +++ b/sysdeps/unix/sysv/linux/adjtime.c | ||
27 | @@ -68,11 +68,16 @@ libc_hidden_def (__adjtime64) | ||
28 | int | ||
29 | __adjtime (const struct timeval *itv, struct timeval *otv) | ||
30 | { | ||
31 | - struct __timeval64 itv64, otv64; | ||
32 | + struct __timeval64 itv64, *pitv64 = NULL; | ||
33 | + struct __timeval64 otv64; | ||
34 | int retval; | ||
35 | |||
36 | - itv64 = valid_timeval_to_timeval64 (*itv); | ||
37 | - retval = __adjtime64 (&itv64, otv != NULL ? &otv64 : NULL); | ||
38 | + if (itv != NULL) | ||
39 | + { | ||
40 | + itv64 = valid_timeval_to_timeval64 (*itv); | ||
41 | + pitv64 = &itv64; | ||
42 | + } | ||
43 | + retval = __adjtime64 (pitv64, otv != NULL ? &otv64 : NULL); | ||
44 | if (otv != NULL) | ||
45 | *otv = valid_timeval64_to_timeval (otv64); | ||
46 | |||
47 | diff --git a/time/Makefile b/time/Makefile | ||
48 | index 26aa835166..f27a75a115 100644 | ||
49 | --- a/time/Makefile | ||
50 | +++ b/time/Makefile | ||
51 | @@ -47,7 +47,8 @@ tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \ | ||
52 | tst-mktime3 tst-strptime2 bug-asctime bug-asctime_r bug-mktime1 \ | ||
53 | tst-strptime3 bug-getdate1 tst-strptime-whitespace tst-ftime \ | ||
54 | tst-tzname tst-y2039 bug-mktime4 tst-strftime2 tst-strftime3 \ | ||
55 | - tst-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1 | ||
56 | + tst-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1 \ | ||
57 | + tst-adjtime | ||
58 | |||
59 | include ../Rules | ||
60 | |||
61 | diff --git a/time/tst-adjtime.c b/time/tst-adjtime.c | ||
62 | new file mode 100644 | ||
63 | index 0000000000..ae2b37cdab | ||
64 | --- /dev/null | ||
65 | +++ b/time/tst-adjtime.c | ||
66 | @@ -0,0 +1,44 @@ | ||
67 | +/* Basic tests for adjtime. | ||
68 | + Copyright (C) 2020 Free Software Foundation, Inc. | ||
69 | + This file is part of the GNU C Library. | ||
70 | + | ||
71 | + The GNU C Library is free software; you can redistribute it and/or | ||
72 | + modify it under the terms of the GNU Lesser General Public | ||
73 | + License as published by the Free Software Foundation; either | ||
74 | + version 2.1 of the License, or (at your option) any later version. | ||
75 | + | ||
76 | + The GNU C Library is distributed in the hope that it will be useful, | ||
77 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
78 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
79 | + Lesser General Public License for more details. | ||
80 | + | ||
81 | + You should have received a copy of the GNU Lesser General Public | ||
82 | + License along with the GNU C Library; if not, see | ||
83 | + <https://www.gnu.org/licenses/>. */ | ||
84 | + | ||
85 | +#include <sys/time.h> | ||
86 | +#include <stdlib.h> | ||
87 | + | ||
88 | +#include <errno.h> | ||
89 | +#include <support/check.h> | ||
90 | + | ||
91 | + | ||
92 | +static int | ||
93 | +do_test (void) | ||
94 | +{ | ||
95 | + /* Check if the interface allows getting the amount of time remaining | ||
96 | + from any previous adjustment that has not yet been completed. This | ||
97 | + is a non-privileged function of adjtime. */ | ||
98 | + struct timeval tv; | ||
99 | + int r = adjtime (NULL, &tv); | ||
100 | + if (r == -1) | ||
101 | + { | ||
102 | + if (errno == ENOSYS) | ||
103 | + FAIL_UNSUPPORTED ("adjtime unsupported"); | ||
104 | + FAIL_EXIT1 ("adjtime (NULL, ...) failed: %m"); | ||
105 | + } | ||
106 | + | ||
107 | + return 0; | ||
108 | +} | ||
109 | + | ||
110 | +#include <support/test-driver.c> | ||
diff --git a/meta/recipes-core/glibc/glibc_2.32.bb b/meta/recipes-core/glibc/glibc_2.32.bb index 6d42f33822..b850c28c78 100644 --- a/meta/recipes-core/glibc/glibc_2.32.bb +++ b/meta/recipes-core/glibc/glibc_2.32.bb | |||
@@ -43,6 +43,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ | |||
43 | file://0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch \ | 43 | file://0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch \ |
44 | file://0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch \ | 44 | file://0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch \ |
45 | file://0030-powerpc-Do-not-ask-compiler-for-finding-arch.patch \ | 45 | file://0030-powerpc-Do-not-ask-compiler-for-finding-arch.patch \ |
46 | file://0031-linux-Allow-adjtime-with-NULL-argument-BZ-26833.patch \ | ||
46 | file://CVE-2020-29562.patch \ | 47 | file://CVE-2020-29562.patch \ |
47 | file://CVE-2020-29573.patch \ | 48 | file://CVE-2020-29573.patch \ |
48 | " | 49 | " |