!166 malloc: Initiate tcache shutdown even without allocations [BZ #28028]

From: @liqingqing_1229
Reviewed-by: @wangbin224
Signed-off-by: @wangbin224
This commit is contained in:
openeuler-ci-bot 2021-07-05 01:14:57 +00:00 committed by Gitee
commit 77d53dfe64
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

@ -60,7 +60,7 @@
##############################################################################
Name: glibc
Version: 2.33
Release: 5
Release: 6
Summary: The GNU libc libraries
License: %{all_license}
URL: http://www.gnu.org/software/glibc/
@ -82,6 +82,7 @@ Patch6000: backport-posix-tst-rfc3484-Fix-compile-failure-linking-to-loc.patch
Patch6001: backport-Use-__pthread_attr_copy-in-mq_notify-bug-27896.patch
Patch6002: backport-Fix-use-of-__pthread_attr_copy-in-mq_notify-bug-27896.patch
Patch6003: backport-CVE-2021-35942-wordexp-handle-overflow-in-positional-parameter-numb.patch
Patch6004: backport-malloc-Initiate-tcache-shutdown-even-without-allocat.patch
Patch9000: turn-REP_STOSB_THRESHOLD-from-2k-to-1M.patch
Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch
@ -1173,7 +1174,11 @@ fi
%doc hesiod/README.hesiod
%changelog
* Thu Jul 1 2021 QingqingLi<liqingqing3@huawei.com> - 2.33-5
* Sat Jul 3 2021 Qingqing Li<liqingqing3@huawei.com> - 2.33-6
- 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.33-5
- wordexp: Use strtoul instead of atoi so that overflow can be detected. (bug 28011)
https://sourceware.org/bugzilla/show_bug.cgi?id=28011