malloc: tcache shutdown sequence does not work if the thread never allocated anything. (bug 28028)

(cherry picked from commit a066d0d7e5c3e86d2294e6ae44a6c1d3fcd1bf73)
This commit is contained in:
liqingqing_1229 2021-07-03 15:47:42 +08:00 committed by openeuler-sync-bot
parent 023a802f7d
commit 07c001f883
2 changed files with 49 additions and 2 deletions

View File

@ -0,0 +1,42 @@
From dfec225ee1972488bb48a8b67a2c4a13010c334a Mon Sep 17 00:00:00 2001
From: JeffyChen <jeffy.chen@rock-chips.com>
Date: Fri, 2 Jul 2021 17:39:24 +0200
Subject: [PATCH] malloc: Initiate tcache shutdown even without allocations [BZ
#28028]
After commit 1e26d35193efbb29239c710a4c46a64708643320 ("malloc: Fix
tcache leak after thread destruction [BZ #22111]"),
tcache_shutting_down is still not early enough. When we detach a
thread with no tcache allocated, tcache_shutting_down would still be
false.
Reviewed-by: DJ Delorie <dj@redhat.com>
Conflict:NA
Reference:https://sourceware.org/git/?p=glibc.git;a=commit;h=dfec225ee1972488bb48a8b67a2c4a13010c334a
---
malloc/malloc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 0e2e1747e0..bb9a1642aa 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -3144,12 +3144,13 @@ tcache_thread_shutdown (void)
int i;
tcache_perthread_struct *tcache_tmp = tcache;
+ tcache_shutting_down = true;
+
if (!tcache)
return;
/* Disable the tcache and prevent it from being reinitialized. */
tcache = NULL;
- tcache_shutting_down = true;
/* Free all of the entries and the tcache itself back to the arena
heap for coalescing. */
--
2.27.0

View File

@ -59,7 +59,7 @@
##############################################################################
Name: glibc
Version: 2.28
Release: 72
Release: 73
Summary: The GNU libc libraries
License: %{all_license}
URL: http://www.gnu.org/software/glibc/
@ -130,6 +130,7 @@ Patch46: backport-aarch64-align-stack-in-clone-BZ-27939.patch
Patch47: backport-x86-64-Align-child-stack-to-16-bytes-BZ-27902.patch
Patch48: backport-ldconfig-handle-.dynstr-located-in-separate-segment-.patch
Patch49: backport-CVE-2021-35942-wordexp-handle-overflow-in-positional-parameter-numb.patch
Patch50: backport-malloc-Initiate-tcache-shutdown-even-without-allocat.patch
Provides: ldconfig rtld(GNU_HASH) bundled(gnulib)
@ -1154,7 +1155,11 @@ fi
%doc hesiod/README.hesiod
%changelog
* Thu Jul 1 2021 QingqingLi<liqingqing3@huawei.com> - 2.28-72
* Sat Jul 3 2021 Qingqing Li<liqingqing3@huawei.com> - 2.28-73
- malloc: tcache shutdown sequence does not work if the thread never allocated anything. (bug 28028)
https://sourceware.org/bugzilla/show_bug.cgi?id=28028
* Thu Jul 1 2021 Qingqing Li<liqingqing3@huawei.com> - 2.28-72
- wordexp: Use strtoul instead of atoi so that overflow can be detected. (bug 28011)
https://sourceware.org/bugzilla/show_bug.cgi?id=28011