glibc/sysdeps
Siddhesh Poyarekar 00ae4f10b5 getaddrinfo: Fix use after free in getcanonname (CVE-2023-4806)
When an NSS plugin only implements the _gethostbyname2_r and
_getcanonname_r callbacks, getaddrinfo could use memory that was freed
during tmpbuf resizing, through h_name in a previous query response.

The backing store for res->at->name when doing a query with
gethostbyname3_r or gethostbyname2_r is tmpbuf, which is reallocated in
gethosts during the query.  For AF_INET6 lookup with AI_ALL |
AI_V4MAPPED, gethosts gets called twice, once for a v6 lookup and second
for a v4 lookup.  In this case, if the first call reallocates tmpbuf
enough number of times, resulting in a malloc, th->h_name (that
res->at->name refers to) ends up on a heap allocated storage in tmpbuf.
Now if the second call to gethosts also causes the plugin callback to
return NSS_STATUS_TRYAGAIN, tmpbuf will get freed, resulting in a UAF
reference in res->at->name.  This then gets dereferenced in the
getcanonname_r plugin call, resulting in the use after free.

Fix this by copying h_name over and freeing it at the end.  This
resolves BZ #30843, which is assigned CVE-2023-4806.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 973fe93a56)
2023-09-15 14:41:36 -04:00
..
aarch64 configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
alpha configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
arc configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
arm configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
csky configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
generic elf: Always call destructors in reverse constructor order (bug 30785) 2023-09-11 09:29:49 +02:00
gnu configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
hppa configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
htl Fix misspellings in sysdeps/ -- BZ 25337 2023-05-30 23:02:29 +00:00
hurd hurd: Fix using interposable hurd_thread_self 2023-05-19 20:45:51 +02:00
i386 i686: Fix build with --disable-multiarch 2023-08-17 23:38:14 +02:00
ia64 configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
ieee754 configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
loongarch configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
m68k configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
mach configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
microblaze configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
mips MIPS: Update mips32 and mip64 libm test ulps 2023-07-25 22:20:57 +02:00
nios2 configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
nptl Fix misspellings in sysdeps/ -- BZ 25337 2023-05-30 23:02:29 +00:00
or1k configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
posix getaddrinfo: Fix use after free in getcanonname (CVE-2023-4806) 2023-09-15 14:41:36 -04:00
powerpc powerpc: Fix powerpc64 strchrnul build with old gcc 2023-07-26 09:45:22 -03:00
pthread Exclude routines from fortification 2023-07-05 16:59:48 +02:00
riscv riscv: Update rvd libm test ulps 2023-07-22 15:55:33 +02:00
s390 configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
sh configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
sparc configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
unix io: Fix record locking contants for powerpc64 with __USE_FILE_OFFSET64 2023-09-07 22:45:43 +02:00
wordsize-32 Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wordsize-64 hurd: Fix tst-writev test 2023-05-01 13:01:30 +02:00
x86 x86: Fix incorrect scope of setting shared_per_thread [BZ# 30745] 2023-08-12 23:59:04 -05:00
x86_64 x86_64: Fix build with --disable-multiarch (BZ 30721) 2023-08-17 23:37:28 +02:00