diff options
| author | Yash Shinde <Yash.Shinde@windriver.com> | 2023-10-05 04:02:07 -0700 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2023-10-05 14:19:57 -1000 |
| commit | c71b397ea0e5853f4c6de9656af63afc89eead14 (patch) | |
| tree | fd435e390011a5984586cf8e95aac747ad8b50dd | |
| parent | 9d5a1d14c9c5ab190c5b3f0919571c5d276e5bf3 (diff) | |
| download | poky-c71b397ea0e5853f4c6de9656af63afc89eead14.tar.gz | |
glibc: stable 2.37 branch updates.
b4e23c75ae tunables: Terminate if end of input is reached (CVE-2023-4911)
2dfd8c77b5 i686: Regenerate ulps
94ef701365 Document CVE-2023-4806 and CVE-2023-5156 in NEWS
4473d1b87d Fix leak in getaddrinfo introduced by the fix for CVE-2023-4806 [BZ #30843]
9d5c6e27ed x86: Fix for cache computation on AMD legacy cpus.
79310b45af x86/dl-cacheinfo: remove unsused parameter from handle_amd
6529a7466c getaddrinfo: Fix use after free in getcanonname (CVE-2023-4806)
b752934602 CVE-2023-4527: Stack read overflow with large TCP responses in no-aaaa mode
1a7cbe52c8 elf: Move l_init_called_next to old place of l_text_end in link map
bdb594afa5 elf: Remove unused l_text_end field from struct link_map
a7e34a6675 elf: Always call destructors in reverse constructor order (bug 30785)
3d24d1903d elf: Do not run constructors for proxy objects
be26b29262 io: Fix record locking contants for powerpc64 with __USE_FILE_OFFSET64
0d500bfdc0 hurd: Make exception subcode a long
f94ff95e93 x86: Fix incorrect scope of setting `shared_per_thread` [BZ# 30745]
cc8243fb0b x86: Use `3/4*sizeof(per-thread-L3)` as low bound for NT threshold.
80a8c858a5 x86: Fix slight bug in `shared_per_thread` cache size calculation.
1caf955269 x86: Increase `non_temporal_threshold` to roughly `sizeof_L3 / 4`
Dropped 0023-CVE-2023-4527.patch and 0024-CVE-2023-4806.patch files as they are
present in glibc version update.
(From OE-Core rev: 9e7aaefc0d764eaecf35582bb19490cc6262f966)
Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-core/glibc/glibc-version.inc | 2 | ||||
| -rw-r--r-- | meta/recipes-core/glibc/glibc/0023-CVE-2023-4527.patch | 219 | ||||
| -rw-r--r-- | meta/recipes-core/glibc/glibc/0024-CVE-2023-4806.patch | 342 | ||||
| -rw-r--r-- | meta/recipes-core/glibc/glibc_2.37.bb | 5 |
4 files changed, 4 insertions, 564 deletions
diff --git a/meta/recipes-core/glibc/glibc-version.inc b/meta/recipes-core/glibc/glibc-version.inc index ff2b2ade9d..7eacfec778 100644 --- a/meta/recipes-core/glibc/glibc-version.inc +++ b/meta/recipes-core/glibc/glibc-version.inc | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | SRCBRANCH ?= "release/2.37/master" | 1 | SRCBRANCH ?= "release/2.37/master" |
| 2 | PV = "2.37" | 2 | PV = "2.37" |
| 3 | SRCREV_glibc ?= "58f7431fd77c0a6dd8df08d50c51ee3e7f09825f" | 3 | SRCREV_glibc ?= "b4e23c75aea756b4bddc4abcf27a1c6dca8b6bd3" |
| 4 | SRCREV_localedef ?= "794da69788cbf9bf57b59a852f9f11307663fa87" | 4 | SRCREV_localedef ?= "794da69788cbf9bf57b59a852f9f11307663fa87" |
| 5 | 5 | ||
| 6 | GLIBC_GIT_URI ?= "git://sourceware.org/git/glibc.git;protocol=https" | 6 | GLIBC_GIT_URI ?= "git://sourceware.org/git/glibc.git;protocol=https" |
diff --git a/meta/recipes-core/glibc/glibc/0023-CVE-2023-4527.patch b/meta/recipes-core/glibc/glibc/0023-CVE-2023-4527.patch deleted file mode 100644 index 211249211a..0000000000 --- a/meta/recipes-core/glibc/glibc/0023-CVE-2023-4527.patch +++ /dev/null | |||
| @@ -1,219 +0,0 @@ | |||
| 1 | From 4ea972b7edd7e36610e8cde18bf7a8149d7bac4f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Florian Weimer <fweimer@redhat.com> | ||
| 3 | Date: Wed, 13 Sep 2023 14:10:56 +0200 | ||
| 4 | Subject: [PATCH] CVE-2023-4527: Stack read overflow with large TCP responses | ||
| 5 | in no-aaaa mode | ||
| 6 | |||
| 7 | Without passing alt_dns_packet_buffer, __res_context_search can only | ||
| 8 | store 2048 bytes (what fits into dns_packet_buffer). However, | ||
| 9 | the function returns the total packet size, and the subsequent | ||
| 10 | DNS parsing code in _nss_dns_gethostbyname4_r reads beyond the end | ||
| 11 | of the stack-allocated buffer. | ||
| 12 | |||
| 13 | Fixes commit f282cdbe7f436c75864e5640a4 ("resolv: Implement no-aaaa | ||
| 14 | stub resolver option") and bug 30842. | ||
| 15 | |||
| 16 | (cherry picked from commit bd77dd7e73e3530203be1c52c8a29d08270cb25d) | ||
| 17 | |||
| 18 | Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=4ea972b7edd7e36610e8cde18bf7a8149d7bac4f] | ||
| 19 | CVE: CVE-2023-4527 | ||
| 20 | |||
| 21 | Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com> | ||
| 22 | |||
| 23 | --- | ||
| 24 | NEWS | 7 ++ | ||
| 25 | resolv/Makefile | 2 + | ||
| 26 | resolv/nss_dns/dns-host.c | 2 +- | ||
| 27 | resolv/tst-resolv-noaaaa-vc.c | 129 ++++++++++++++++++++++++++++++++++ | ||
| 28 | 4 files changed, 139 insertions(+), 1 deletion(-) | ||
| 29 | create mode 100644 resolv/tst-resolv-noaaaa-vc.c | ||
| 30 | |||
| 31 | diff --git a/NEWS b/NEWS | ||
| 32 | --- a/NEWS | ||
| 33 | +++ b/NEWS | ||
| 34 | @@ -25,6 +25,7 @@ | ||
| 35 | [30101] gmon: fix memory corruption issues | ||
| 36 | [30125] dynamic-link: [regression, bisected] glibc-2.37 creates new | ||
| 37 | symlink for libraries without soname | ||
| 38 | + [30842] Stack read overflow in getaddrinfo in no-aaaa mode (CVE-2023-4527) | ||
| 39 | [30151] gshadow: Matching sgetsgent, sgetsgent_r ERANGE handling | ||
| 40 | [30163] posix: Fix system blocks SIGCHLD erroneously | ||
| 41 | [30305] x86_64: Fix asm constraints in feraiseexcept | ||
| 42 | @@ -54,6 +55,12 @@ | ||
| 43 | heap and prints it to the target log file, potentially revealing a | ||
| 44 | portion of the contents of the heap. | ||
| 45 | |||
| 46 | + CVE-2023-4527: If the system is configured in no-aaaa mode via | ||
| 47 | + /etc/resolv.conf, getaddrinfo is called for the AF_UNSPEC address | ||
| 48 | + family, and a DNS response is received over TCP that is larger than | ||
| 49 | + 2048 bytes, getaddrinfo may potentially disclose stack contents via | ||
| 50 | + the returned address data, or crash. | ||
| 51 | + | ||
| 52 | The following bugs are resolved with this release: | ||
| 53 | |||
| 54 | [12154] network: Cannot resolve hosts which have wildcard aliases | ||
| 55 | diff --git a/resolv/Makefile b/resolv/Makefile | ||
| 56 | --- a/resolv/Makefile | ||
| 57 | +++ b/resolv/Makefile | ||
| 58 | @@ -101,6 +101,7 @@ | ||
| 59 | tst-resolv-invalid-cname \ | ||
| 60 | tst-resolv-network \ | ||
| 61 | tst-resolv-noaaaa \ | ||
| 62 | + tst-resolv-noaaaa-vc \ | ||
| 63 | tst-resolv-nondecimal \ | ||
| 64 | tst-resolv-res_init-multi \ | ||
| 65 | tst-resolv-search \ | ||
| 66 | @@ -292,6 +293,7 @@ | ||
| 67 | $(objpfx)tst-resolv-invalid-cname: $(objpfx)libresolv.so \ | ||
| 68 | $(shared-thread-library) | ||
| 69 | $(objpfx)tst-resolv-noaaaa: $(objpfx)libresolv.so $(shared-thread-library) | ||
| 70 | +$(objpfx)tst-resolv-noaaaa-vc: $(objpfx)libresolv.so $(shared-thread-library) | ||
| 71 | $(objpfx)tst-resolv-nondecimal: $(objpfx)libresolv.so $(shared-thread-library) | ||
| 72 | $(objpfx)tst-resolv-qtypes: $(objpfx)libresolv.so $(shared-thread-library) | ||
| 73 | $(objpfx)tst-resolv-rotate: $(objpfx)libresolv.so $(shared-thread-library) | ||
| 74 | diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c | ||
| 75 | --- a/resolv/nss_dns/dns-host.c | ||
| 76 | +++ b/resolv/nss_dns/dns-host.c | ||
| 77 | @@ -427,7 +427,7 @@ | ||
| 78 | { | ||
| 79 | n = __res_context_search (ctx, name, C_IN, T_A, | ||
| 80 | dns_packet_buffer, sizeof (dns_packet_buffer), | ||
| 81 | - NULL, NULL, NULL, NULL, NULL); | ||
| 82 | + &alt_dns_packet_buffer, NULL, NULL, NULL, NULL); | ||
| 83 | if (n >= 0) | ||
| 84 | status = gaih_getanswer_noaaaa (alt_dns_packet_buffer, n, | ||
| 85 | &abuf, pat, errnop, herrnop, ttlp); | ||
| 86 | diff --git a/resolv/tst-resolv-noaaaa-vc.c b/resolv/tst-resolv-noaaaa-vc.c | ||
| 87 | new file mode 100644 | ||
| 88 | --- /dev/null | ||
| 89 | +++ b/resolv/tst-resolv-noaaaa-vc.c | ||
| 90 | @@ -0,0 +1,129 @@ | ||
| 91 | +/* Test the RES_NOAAAA resolver option with a large response. | ||
| 92 | + Copyright (C) 2022-2023 Free Software Foundation, Inc. | ||
| 93 | + This file is part of the GNU C Library. | ||
| 94 | + | ||
| 95 | + The GNU C Library is free software; you can redistribute it and/or | ||
| 96 | + modify it under the terms of the GNU Lesser General Public | ||
| 97 | + License as published by the Free Software Foundation; either | ||
| 98 | + version 2.1 of the License, or (at your option) any later version. | ||
| 99 | + | ||
| 100 | + The GNU C Library is distributed in the hope that it will be useful, | ||
| 101 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 102 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 103 | + Lesser General Public License for more details. | ||
| 104 | + | ||
| 105 | + You should have received a copy of the GNU Lesser General Public | ||
| 106 | + License along with the GNU C Library; if not, see | ||
| 107 | + <https://www.gnu.org/licenses/>. */ | ||
| 108 | + | ||
| 109 | +#include <errno.h> | ||
| 110 | +#include <netdb.h> | ||
| 111 | +#include <resolv.h> | ||
| 112 | +#include <stdbool.h> | ||
| 113 | +#include <stdlib.h> | ||
| 114 | +#include <support/check.h> | ||
| 115 | +#include <support/check_nss.h> | ||
| 116 | +#include <support/resolv_test.h> | ||
| 117 | +#include <support/support.h> | ||
| 118 | +#include <support/xmemstream.h> | ||
| 119 | + | ||
| 120 | +/* Used to keep track of the number of queries. */ | ||
| 121 | +static volatile unsigned int queries; | ||
| 122 | + | ||
| 123 | +/* If true, add a large TXT record at the start of the answer section. */ | ||
| 124 | +static volatile bool stuff_txt; | ||
| 125 | + | ||
| 126 | +static void | ||
| 127 | +response (const struct resolv_response_context *ctx, | ||
| 128 | + struct resolv_response_builder *b, | ||
| 129 | + const char *qname, uint16_t qclass, uint16_t qtype) | ||
| 130 | +{ | ||
| 131 | + /* If not using TCP, just force its use. */ | ||
| 132 | + if (!ctx->tcp) | ||
| 133 | + { | ||
| 134 | + struct resolv_response_flags flags = {.tc = true}; | ||
| 135 | + resolv_response_init (b, flags); | ||
| 136 | + resolv_response_add_question (b, qname, qclass, qtype); | ||
| 137 | + return; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + /* The test needs to send four queries, the first three are used to | ||
| 141 | + grow the NSS buffer via the ERANGE handshake. */ | ||
| 142 | + ++queries; | ||
| 143 | + TEST_VERIFY (queries <= 4); | ||
| 144 | + | ||
| 145 | + /* AAAA queries are supposed to be disabled. */ | ||
| 146 | + TEST_COMPARE (qtype, T_A); | ||
| 147 | + TEST_COMPARE (qclass, C_IN); | ||
| 148 | + TEST_COMPARE_STRING (qname, "example.com"); | ||
| 149 | + | ||
| 150 | + struct resolv_response_flags flags = {}; | ||
| 151 | + resolv_response_init (b, flags); | ||
| 152 | + resolv_response_add_question (b, qname, qclass, qtype); | ||
| 153 | + | ||
| 154 | + resolv_response_section (b, ns_s_an); | ||
| 155 | + | ||
| 156 | + if (stuff_txt) | ||
| 157 | + { | ||
| 158 | + resolv_response_open_record (b, qname, qclass, T_TXT, 60); | ||
| 159 | + int zero = 0; | ||
| 160 | + for (int i = 0; i <= 15000; ++i) | ||
| 161 | + resolv_response_add_data (b, &zero, sizeof (zero)); | ||
| 162 | + resolv_response_close_record (b); | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + for (int i = 0; i < 200; ++i) | ||
| 166 | + { | ||
| 167 | + resolv_response_open_record (b, qname, qclass, qtype, 60); | ||
| 168 | + char ipv4[4] = {192, 0, 2, i + 1}; | ||
| 169 | + resolv_response_add_data (b, &ipv4, sizeof (ipv4)); | ||
| 170 | + resolv_response_close_record (b); | ||
| 171 | + } | ||
| 172 | +} | ||
| 173 | + | ||
| 174 | +static int | ||
| 175 | +do_test (void) | ||
| 176 | +{ | ||
| 177 | + struct resolv_test *obj = resolv_test_start | ||
| 178 | + ((struct resolv_redirect_config) | ||
| 179 | + { | ||
| 180 | + .response_callback = response | ||
| 181 | + }); | ||
| 182 | + | ||
| 183 | + _res.options |= RES_NOAAAA; | ||
| 184 | + | ||
| 185 | + for (int do_stuff_txt = 0; do_stuff_txt < 2; ++do_stuff_txt) | ||
| 186 | + { | ||
| 187 | + queries = 0; | ||
| 188 | + stuff_txt = do_stuff_txt; | ||
| 189 | + | ||
| 190 | + struct addrinfo *ai = NULL; | ||
| 191 | + int ret; | ||
| 192 | + ret = getaddrinfo ("example.com", "80", | ||
| 193 | + &(struct addrinfo) | ||
| 194 | + { | ||
| 195 | + .ai_family = AF_UNSPEC, | ||
| 196 | + .ai_socktype = SOCK_STREAM, | ||
| 197 | + }, &ai); | ||
| 198 | + | ||
| 199 | + char *expected_result; | ||
| 200 | + { | ||
| 201 | + struct xmemstream mem; | ||
| 202 | + xopen_memstream (&mem); | ||
| 203 | + for (int i = 0; i < 200; ++i) | ||
| 204 | + fprintf (mem.out, "address: STREAM/TCP 192.0.2.%d 80\n", i + 1); | ||
| 205 | + xfclose_memstream (&mem); | ||
| 206 | + expected_result = mem.buffer; | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + check_addrinfo ("example.com", ai, ret, expected_result); | ||
| 210 | + | ||
| 211 | + free (expected_result); | ||
| 212 | + freeaddrinfo (ai); | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + resolv_test_end (obj); | ||
| 216 | + return 0; | ||
| 217 | +} | ||
| 218 | + | ||
| 219 | +#include <support/test-driver.c> | ||
diff --git a/meta/recipes-core/glibc/glibc/0024-CVE-2023-4806.patch b/meta/recipes-core/glibc/glibc/0024-CVE-2023-4806.patch deleted file mode 100644 index 42d91fd340..0000000000 --- a/meta/recipes-core/glibc/glibc/0024-CVE-2023-4806.patch +++ /dev/null | |||
| @@ -1,342 +0,0 @@ | |||
| 1 | From 973fe93a5675c42798b2161c6f29c01b0e243994 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Siddhesh Poyarekar <siddhesh@sourceware.org> | ||
| 3 | Date: Fri, 15 Sep 2023 13:51:12 -0400 | ||
| 4 | Subject: [PATCH] getaddrinfo: Fix use after free in getcanonname | ||
| 5 | (CVE-2023-4806) | ||
| 6 | |||
| 7 | When an NSS plugin only implements the _gethostbyname2_r and | ||
| 8 | _getcanonname_r callbacks, getaddrinfo could use memory that was freed | ||
| 9 | during tmpbuf resizing, through h_name in a previous query response. | ||
| 10 | |||
| 11 | The backing store for res->at->name when doing a query with | ||
| 12 | gethostbyname3_r or gethostbyname2_r is tmpbuf, which is reallocated in | ||
| 13 | gethosts during the query. For AF_INET6 lookup with AI_ALL | | ||
| 14 | AI_V4MAPPED, gethosts gets called twice, once for a v6 lookup and second | ||
| 15 | for a v4 lookup. In this case, if the first call reallocates tmpbuf | ||
| 16 | enough number of times, resulting in a malloc, th->h_name (that | ||
| 17 | res->at->name refers to) ends up on a heap allocated storage in tmpbuf. | ||
| 18 | Now if the second call to gethosts also causes the plugin callback to | ||
| 19 | return NSS_STATUS_TRYAGAIN, tmpbuf will get freed, resulting in a UAF | ||
| 20 | reference in res->at->name. This then gets dereferenced in the | ||
| 21 | getcanonname_r plugin call, resulting in the use after free. | ||
| 22 | |||
| 23 | Fix this by copying h_name over and freeing it at the end. This | ||
| 24 | resolves BZ #30843, which is assigned CVE-2023-4806. | ||
| 25 | |||
| 26 | Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=973fe93a5675c42798b2161c6f29c01b0e243994] | ||
| 27 | CVE: CVE-2023-4806 | ||
| 28 | |||
| 29 | Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> | ||
| 30 | |||
| 31 | Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com> | ||
| 32 | --- | ||
| 33 | nss/Makefile | 15 ++++- | ||
| 34 | nss/nss_test_gai_hv2_canonname.c | 56 +++++++++++++++++ | ||
| 35 | nss/tst-nss-gai-hv2-canonname.c | 63 +++++++++++++++++++ | ||
| 36 | nss/tst-nss-gai-hv2-canonname.h | 1 + | ||
| 37 | .../postclean.req | 0 | ||
| 38 | .../tst-nss-gai-hv2-canonname.script | 2 + | ||
| 39 | sysdeps/posix/getaddrinfo.c | 25 +++++--- | ||
| 40 | 7 files changed, 152 insertions(+), 10 deletions(-) | ||
| 41 | create mode 100644 nss/nss_test_gai_hv2_canonname.c | ||
| 42 | create mode 100644 nss/tst-nss-gai-hv2-canonname.c | ||
| 43 | create mode 100644 nss/tst-nss-gai-hv2-canonname.h | ||
| 44 | create mode 100644 nss/tst-nss-gai-hv2-canonname.root/postclean.req | ||
| 45 | create mode 100644 nss/tst-nss-gai-hv2-canonname.root/tst-nss-gai-hv2-canonname.script | ||
| 46 | |||
| 47 | diff --git a/nss/Makefile b/nss/Makefile | ||
| 48 | index 06fcdc450f..8a5126ecf3 100644 | ||
| 49 | --- a/nss/Makefile | ||
| 50 | +++ b/nss/Makefile | ||
| 51 | @@ -82,6 +82,7 @@ tests-container := \ | ||
| 52 | tst-nss-test3 \ | ||
| 53 | tst-reload1 \ | ||
| 54 | tst-reload2 \ | ||
| 55 | + tst-nss-gai-hv2-canonname \ | ||
| 56 | # tests-container | ||
| 57 | |||
| 58 | # Tests which need libdl | ||
| 59 | @@ -145,7 +146,8 @@ libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes)) | ||
| 60 | ifeq ($(build-static-nss),yes) | ||
| 61 | tests-static += tst-nss-static | ||
| 62 | endif | ||
| 63 | -extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os | ||
| 64 | +extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os \ | ||
| 65 | + nss_test_gai_hv2_canonname.os | ||
| 66 | |||
| 67 | include ../Rules | ||
| 68 | |||
| 69 | @@ -180,12 +182,16 @@ rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver | ||
| 70 | libof-nss_test1 = extramodules | ||
| 71 | libof-nss_test2 = extramodules | ||
| 72 | libof-nss_test_errno = extramodules | ||
| 73 | +libof-nss_test_gai_hv2_canonname = extramodules | ||
| 74 | $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps) | ||
| 75 | $(build-module) | ||
| 76 | $(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps) | ||
| 77 | $(build-module) | ||
| 78 | $(objpfx)/libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps) | ||
| 79 | $(build-module) | ||
| 80 | +$(objpfx)/libnss_test_gai_hv2_canonname.so: \ | ||
| 81 | + $(objpfx)nss_test_gai_hv2_canonname.os $(link-libc-deps) | ||
| 82 | + $(build-module) | ||
| 83 | $(objpfx)nss_test2.os : nss_test1.c | ||
| 84 | # Use the nss_files suffix for these objects as well. | ||
| 85 | $(objpfx)/libnss_test1.so$(libnss_files.so-version): $(objpfx)/libnss_test1.so | ||
| 86 | @@ -195,10 +201,14 @@ $(objpfx)/libnss_test2.so$(libnss_files.so-version): $(objpfx)/libnss_test2.so | ||
| 87 | $(objpfx)/libnss_test_errno.so$(libnss_files.so-version): \ | ||
| 88 | $(objpfx)/libnss_test_errno.so | ||
| 89 | $(make-link) | ||
| 90 | +$(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \ | ||
| 91 | + $(objpfx)/libnss_test_gai_hv2_canonname.so | ||
| 92 | + $(make-link) | ||
| 93 | $(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \ | ||
| 94 | $(objpfx)/libnss_test1.so$(libnss_files.so-version) \ | ||
| 95 | $(objpfx)/libnss_test2.so$(libnss_files.so-version) \ | ||
| 96 | - $(objpfx)/libnss_test_errno.so$(libnss_files.so-version) | ||
| 97 | + $(objpfx)/libnss_test_errno.so$(libnss_files.so-version) \ | ||
| 98 | + $(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version) | ||
| 99 | |||
| 100 | ifeq (yes,$(have-thread-library)) | ||
| 101 | $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library) | ||
| 102 | @@ -215,3 +225,4 @@ LDFLAGS-tst-nss-test3 = -Wl,--disable-new-dtags | ||
| 103 | LDFLAGS-tst-nss-test4 = -Wl,--disable-new-dtags | ||
| 104 | LDFLAGS-tst-nss-test5 = -Wl,--disable-new-dtags | ||
| 105 | LDFLAGS-tst-nss-test_errno = -Wl,--disable-new-dtags | ||
| 106 | +LDFLAGS-tst-nss-test_gai_hv2_canonname = -Wl,--disable-new-dtags | ||
| 107 | diff --git a/nss/nss_test_gai_hv2_canonname.c b/nss/nss_test_gai_hv2_canonname.c | ||
| 108 | new file mode 100644 | ||
| 109 | index 0000000000..4439c83c9f | ||
| 110 | --- /dev/null | ||
| 111 | +++ b/nss/nss_test_gai_hv2_canonname.c | ||
| 112 | @@ -0,0 +1,56 @@ | ||
| 113 | +/* NSS service provider that only provides gethostbyname2_r. | ||
| 114 | + Copyright The GNU Toolchain Authors. | ||
| 115 | + This file is part of the GNU C Library. | ||
| 116 | + | ||
| 117 | + The GNU C Library is free software; you can redistribute it and/or | ||
| 118 | + modify it under the terms of the GNU Lesser General Public | ||
| 119 | + License as published by the Free Software Foundation; either | ||
| 120 | + version 2.1 of the License, or (at your option) any later version. | ||
| 121 | + | ||
| 122 | + The GNU C Library is distributed in the hope that it will be useful, | ||
| 123 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 124 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 125 | + Lesser General Public License for more details. | ||
| 126 | + | ||
| 127 | + You should have received a copy of the GNU Lesser General Public | ||
| 128 | + License along with the GNU C Library; if not, see | ||
| 129 | + <https://www.gnu.org/licenses/>. */ | ||
| 130 | + | ||
| 131 | +#include <nss.h> | ||
| 132 | +#include <stdlib.h> | ||
| 133 | +#include <string.h> | ||
| 134 | +#include "nss/tst-nss-gai-hv2-canonname.h" | ||
| 135 | + | ||
| 136 | +/* Catch misnamed and functions. */ | ||
| 137 | +#pragma GCC diagnostic error "-Wmissing-prototypes" | ||
| 138 | +NSS_DECLARE_MODULE_FUNCTIONS (test_gai_hv2_canonname) | ||
| 139 | + | ||
| 140 | +extern enum nss_status _nss_files_gethostbyname2_r (const char *, int, | ||
| 141 | + struct hostent *, char *, | ||
| 142 | + size_t, int *, int *); | ||
| 143 | + | ||
| 144 | +enum nss_status | ||
| 145 | +_nss_test_gai_hv2_canonname_gethostbyname2_r (const char *name, int af, | ||
| 146 | + struct hostent *result, | ||
| 147 | + char *buffer, size_t buflen, | ||
| 148 | + int *errnop, int *herrnop) | ||
| 149 | +{ | ||
| 150 | + return _nss_files_gethostbyname2_r (name, af, result, buffer, buflen, errnop, | ||
| 151 | + herrnop); | ||
| 152 | +} | ||
| 153 | + | ||
| 154 | +enum nss_status | ||
| 155 | +_nss_test_gai_hv2_canonname_getcanonname_r (const char *name, char *buffer, | ||
| 156 | + size_t buflen, char **result, | ||
| 157 | + int *errnop, int *h_errnop) | ||
| 158 | +{ | ||
| 159 | + /* We expect QUERYNAME, which is a small enough string that it shouldn't fail | ||
| 160 | + the test. */ | ||
| 161 | + if (memcmp (QUERYNAME, name, sizeof (QUERYNAME)) | ||
| 162 | + || buflen < sizeof (QUERYNAME)) | ||
| 163 | + abort (); | ||
| 164 | + | ||
| 165 | + strncpy (buffer, name, buflen); | ||
| 166 | + *result = buffer; | ||
| 167 | + return NSS_STATUS_SUCCESS; | ||
| 168 | +} | ||
| 169 | diff --git a/nss/tst-nss-gai-hv2-canonname.c b/nss/tst-nss-gai-hv2-canonname.c | ||
| 170 | new file mode 100644 | ||
| 171 | index 0000000000..d5f10c07d6 | ||
| 172 | --- /dev/null | ||
| 173 | +++ b/nss/tst-nss-gai-hv2-canonname.c | ||
| 174 | @@ -0,0 +1,63 @@ | ||
| 175 | +/* Test NSS query path for plugins that only implement gethostbyname2 | ||
| 176 | + (#30843). | ||
| 177 | + Copyright The GNU Toolchain Authors. | ||
| 178 | + This file is part of the GNU C Library. | ||
| 179 | + | ||
| 180 | + The GNU C Library is free software; you can redistribute it and/or | ||
| 181 | + modify it under the terms of the GNU Lesser General Public | ||
| 182 | + License as published by the Free Software Foundation; either | ||
| 183 | + version 2.1 of the License, or (at your option) any later version. | ||
| 184 | + | ||
| 185 | + The GNU C Library is distributed in the hope that it will be useful, | ||
| 186 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 187 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 188 | + Lesser General Public License for more details. | ||
| 189 | + | ||
| 190 | + You should have received a copy of the GNU Lesser General Public | ||
| 191 | + License along with the GNU C Library; if not, see | ||
| 192 | + <https://www.gnu.org/licenses/>. */ | ||
| 193 | + | ||
| 194 | +#include <nss.h> | ||
| 195 | +#include <netdb.h> | ||
| 196 | +#include <stdlib.h> | ||
| 197 | +#include <string.h> | ||
| 198 | +#include <support/check.h> | ||
| 199 | +#include <support/xstdio.h> | ||
| 200 | +#include "nss/tst-nss-gai-hv2-canonname.h" | ||
| 201 | + | ||
| 202 | +#define PREPARE do_prepare | ||
| 203 | + | ||
| 204 | +static void do_prepare (int a, char **av) | ||
| 205 | +{ | ||
| 206 | + FILE *hosts = xfopen ("/etc/hosts", "w"); | ||
| 207 | + for (unsigned i = 2; i < 255; i++) | ||
| 208 | + { | ||
| 209 | + fprintf (hosts, "ff01::ff02:ff03:%u:2\ttest.example.com\n", i); | ||
| 210 | + fprintf (hosts, "192.168.0.%u\ttest.example.com\n", i); | ||
| 211 | + } | ||
| 212 | + xfclose (hosts); | ||
| 213 | +} | ||
| 214 | + | ||
| 215 | +static int | ||
| 216 | +do_test (void) | ||
| 217 | +{ | ||
| 218 | + __nss_configure_lookup ("hosts", "test_gai_hv2_canonname"); | ||
| 219 | + | ||
| 220 | + struct addrinfo hints = {}; | ||
| 221 | + struct addrinfo *result = NULL; | ||
| 222 | + | ||
| 223 | + hints.ai_family = AF_INET6; | ||
| 224 | + hints.ai_flags = AI_ALL | AI_V4MAPPED | AI_CANONNAME; | ||
| 225 | + | ||
| 226 | + int ret = getaddrinfo (QUERYNAME, NULL, &hints, &result); | ||
| 227 | + | ||
| 228 | + if (ret != 0) | ||
| 229 | + FAIL_EXIT1 ("getaddrinfo failed: %s\n", gai_strerror (ret)); | ||
| 230 | + | ||
| 231 | + TEST_COMPARE_STRING (result->ai_canonname, QUERYNAME); | ||
| 232 | + | ||
| 233 | + freeaddrinfo(result); | ||
| 234 | + return 0; | ||
| 235 | +} | ||
| 236 | + | ||
| 237 | +#include <support/test-driver.c> | ||
| 238 | diff --git a/nss/tst-nss-gai-hv2-canonname.h b/nss/tst-nss-gai-hv2-canonname.h | ||
| 239 | new file mode 100644 | ||
| 240 | index 0000000000..14f2a9cb08 | ||
| 241 | --- /dev/null | ||
| 242 | +++ b/nss/tst-nss-gai-hv2-canonname.h | ||
| 243 | @@ -0,0 +1 @@ | ||
| 244 | +#define QUERYNAME "test.example.com" | ||
| 245 | diff --git a/nss/tst-nss-gai-hv2-canonname.root/postclean.req b/nss/tst-nss-gai-hv2-canonname.root/postclean.req | ||
| 246 | new file mode 100644 | ||
| 247 | index 0000000000..e69de29bb2 | ||
| 248 | diff --git a/nss/tst-nss-gai-hv2-canonname.root/tst-nss-gai-hv2-canonname.script b/nss/tst-nss-gai-hv2-canonname.root/tst-nss-gai-hv2-canonname.script | ||
| 249 | new file mode 100644 | ||
| 250 | index 0000000000..31848b4a28 | ||
| 251 | --- /dev/null | ||
| 252 | +++ b/nss/tst-nss-gai-hv2-canonname.root/tst-nss-gai-hv2-canonname.script | ||
| 253 | @@ -0,0 +1,2 @@ | ||
| 254 | +cp $B/nss/libnss_test_gai_hv2_canonname.so $L/libnss_test_gai_hv2_canonname.so.2 | ||
| 255 | +su | ||
| 256 | diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c | ||
| 257 | index 6ae6744fe4..47f421fddf 100644 | ||
| 258 | --- a/sysdeps/posix/getaddrinfo.c | ||
| 259 | +++ b/sysdeps/posix/getaddrinfo.c | ||
| 260 | @@ -120,6 +120,7 @@ struct gaih_result | ||
| 261 | { | ||
| 262 | struct gaih_addrtuple *at; | ||
| 263 | char *canon; | ||
| 264 | + char *h_name; | ||
| 265 | bool free_at; | ||
| 266 | bool got_ipv6; | ||
| 267 | }; | ||
| 268 | @@ -165,6 +166,7 @@ gaih_result_reset (struct gaih_result *res) | ||
| 269 | if (res->free_at) | ||
| 270 | free (res->at); | ||
| 271 | free (res->canon); | ||
| 272 | + free (res->h_name); | ||
| 273 | memset (res, 0, sizeof (*res)); | ||
| 274 | } | ||
| 275 | |||
| 276 | @@ -203,9 +205,8 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp, | ||
| 277 | return 0; | ||
| 278 | } | ||
| 279 | |||
| 280 | -/* Convert struct hostent to a list of struct gaih_addrtuple objects. h_name | ||
| 281 | - is not copied, and the struct hostent object must not be deallocated | ||
| 282 | - prematurely. The new addresses are appended to the tuple array in RES. */ | ||
| 283 | +/* Convert struct hostent to a list of struct gaih_addrtuple objects. The new | ||
| 284 | + addresses are appended to the tuple array in RES. */ | ||
| 285 | static bool | ||
| 286 | convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, int family, | ||
| 287 | struct hostent *h, struct gaih_result *res) | ||
| 288 | @@ -238,6 +239,15 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, int family, | ||
| 289 | res->at = array; | ||
| 290 | res->free_at = true; | ||
| 291 | |||
| 292 | + /* Duplicate h_name because it may get reclaimed when the underlying storage | ||
| 293 | + is freed. */ | ||
| 294 | + if (res->h_name == NULL) | ||
| 295 | + { | ||
| 296 | + res->h_name = __strdup (h->h_name); | ||
| 297 | + if (res->h_name == NULL) | ||
| 298 | + return false; | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | /* Update the next pointers on reallocation. */ | ||
| 302 | for (size_t i = 0; i < old; i++) | ||
| 303 | array[i].next = array + i + 1; | ||
| 304 | @@ -262,7 +272,6 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, int family, | ||
| 305 | } | ||
| 306 | array[i].next = array + i + 1; | ||
| 307 | } | ||
| 308 | - array[0].name = h->h_name; | ||
| 309 | array[count - 1].next = NULL; | ||
| 310 | |||
| 311 | return true; | ||
| 312 | @@ -324,15 +333,15 @@ gethosts (nss_gethostbyname3_r fct, int family, const char *name, | ||
| 313 | memory allocation failure. The returned string is allocated on the | ||
| 314 | heap; the caller has to free it. */ | ||
| 315 | static char * | ||
| 316 | -getcanonname (nss_action_list nip, struct gaih_addrtuple *at, const char *name) | ||
| 317 | +getcanonname (nss_action_list nip, const char *hname, const char *name) | ||
| 318 | { | ||
| 319 | nss_getcanonname_r *cfct = __nss_lookup_function (nip, "getcanonname_r"); | ||
| 320 | char *s = (char *) name; | ||
| 321 | if (cfct != NULL) | ||
| 322 | { | ||
| 323 | char buf[256]; | ||
| 324 | - if (DL_CALL_FCT (cfct, (at->name ?: name, buf, sizeof (buf), | ||
| 325 | - &s, &errno, &h_errno)) != NSS_STATUS_SUCCESS) | ||
| 326 | + if (DL_CALL_FCT (cfct, (hname ?: name, buf, sizeof (buf), &s, &errno, | ||
| 327 | + &h_errno)) != NSS_STATUS_SUCCESS) | ||
| 328 | /* If the canonical name cannot be determined, use the passed | ||
| 329 | string. */ | ||
| 330 | s = (char *) name; | ||
| 331 | @@ -771,7 +780,7 @@ get_nss_addresses (const char *name, const struct addrinfo *req, | ||
| 332 | if ((req->ai_flags & AI_CANONNAME) != 0 | ||
| 333 | && res->canon == NULL) | ||
| 334 | { | ||
| 335 | - char *canonbuf = getcanonname (nip, res->at, name); | ||
| 336 | + char *canonbuf = getcanonname (nip, res->h_name, name); | ||
| 337 | if (canonbuf == NULL) | ||
| 338 | { | ||
| 339 | __resolv_context_put (res_ctx); | ||
| 340 | -- | ||
| 341 | 2.39.3 | ||
| 342 | |||
diff --git a/meta/recipes-core/glibc/glibc_2.37.bb b/meta/recipes-core/glibc/glibc_2.37.bb index bce566acd4..e807f6974d 100644 --- a/meta/recipes-core/glibc/glibc_2.37.bb +++ b/meta/recipes-core/glibc/glibc_2.37.bb | |||
| @@ -17,6 +17,9 @@ CVE_CHECK_IGNORE += "CVE-2019-1010025" | |||
| 17 | # This is integrated into the 2.37 branch as of 07b9521fc6 | 17 | # This is integrated into the 2.37 branch as of 07b9521fc6 |
| 18 | CVE_CHECK_IGNORE += "CVE-2023-25139" | 18 | CVE_CHECK_IGNORE += "CVE-2023-25139" |
| 19 | 19 | ||
| 20 | # This is integrated into the 2.37 branch as of b4e23c75ae | ||
| 21 | +CVE_CHECK_IGNORE += "CVE-2023-4806 CVE-2023-4527 CVE-2023-4911" | ||
| 22 | |||
| 20 | DEPENDS += "gperf-native bison-native" | 23 | DEPENDS += "gperf-native bison-native" |
| 21 | 24 | ||
| 22 | NATIVESDKFIXES ?= "" | 25 | NATIVESDKFIXES ?= "" |
| @@ -49,8 +52,6 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ | |||
| 49 | file://0020-tzselect.ksh-Use-bin-sh-default-shell-interpreter.patch \ | 52 | file://0020-tzselect.ksh-Use-bin-sh-default-shell-interpreter.patch \ |
| 50 | file://0021-fix-create-thread-failed-in-unprivileged-process-BZ-.patch \ | 53 | file://0021-fix-create-thread-failed-in-unprivileged-process-BZ-.patch \ |
| 51 | file://0022-Avoid-hardcoded-build-time-paths-in-the-output-binar.patch \ | 54 | file://0022-Avoid-hardcoded-build-time-paths-in-the-output-binar.patch \ |
| 52 | file://0023-CVE-2023-4527.patch \ | ||
| 53 | file://0024-CVE-2023-4806.patch \ | ||
| 54 | " | 55 | " |
| 55 | S = "${WORKDIR}/git" | 56 | S = "${WORKDIR}/git" |
| 56 | B = "${WORKDIR}/build-${TARGET_SYS}" | 57 | B = "${WORKDIR}/build-${TARGET_SYS}" |
