diff --git a/RHEL-16549.patch b/RHEL-16549.patch new file mode 100644 index 0000000..4469759 --- /dev/null +++ b/RHEL-16549.patch @@ -0,0 +1,59 @@ +commit 0fef0bd60ff4b359a32da52262855dfe82fe51ae +gpg: Signature made Tue 14 Nov 2023 03:20:12 PM EST +gpg: using RSA key 4B35DCD2EA45C4E0783135BC8094BE9C9F4696A1 +gpg: Can't check signature: No public key +Author: Yichun Zhang (agentzh) +Date: Fri Nov 10 21:51:56 2023 -0800 + + PR31051: memory and uprobe leaks in early uprobe registraton code when errors happen + +diff --git a/runtime/linux/uprobes-inode.c b/runtime/linux/uprobes-inode.c +index 997f4528d..289cce00b 100644 +--- a/runtime/linux/uprobes-inode.c ++++ b/runtime/linux/uprobes-inode.c +@@ -529,6 +529,16 @@ stapiu_init(struct stapiu_consumer *consumers, size_t nconsumers) + } + + if (unlikely(ret != 0)) { ++ for ( ;; ) { ++ struct stapiu_consumer *c = &consumers[i]; ++ // protect against conceivable stapiu_refresh() at same time ++ mutex_lock(& c->consumer_lock); ++ stapiu_consumer_unreg(c); ++ mutex_unlock(& c->consumer_lock); ++ if (i == 0) ++ break; ++ i--; ++ } + return ret; + } + +@@ -545,7 +555,27 @@ stapiu_init(struct stapiu_consumer *consumers, size_t nconsumers) + break; + } + } +- return ret; ++ ++ if (unlikely(ret != 0)) { ++ int j; ++ for (j = 0; j < nconsumers; ++j) { ++ struct stapiu_consumer *c = &consumers[j]; ++ // protect against conceivable stapiu_refresh() at same time ++ mutex_lock(& c->consumer_lock); ++ stapiu_consumer_unreg(c); ++ mutex_unlock(& c->consumer_lock); ++ } ++ for ( ;; ) { ++ struct stapiu_consumer *c = &consumers[i]; ++ stap_cleanup_task_finder_target(&c->finder); ++ if (i == 0) ++ break; ++ i--; ++ } ++ return ret; ++ } ++ ++ return 0; + } + + diff --git a/systemtap.spec b/systemtap.spec index 585c72f..3b7d78d 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -116,7 +116,7 @@ m stapdev stapdev Name: systemtap # PRERELEASE Version: 5.0 -Release: 2%{?release_override}%{?dist} +Release: 3%{?release_override}%{?dist} # for version, see also configure.ac @@ -153,6 +153,8 @@ License: GPL-2.0-or-later URL: http://sourceware.org/systemtap/ Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz +Patch1: RHEL-16549.patch + # Build* BuildRequires: make BuildRequires: gcc-c++ @@ -579,6 +581,7 @@ or within a container. %prep %setup -q +%patch -P1 -p1 %build @@ -1298,6 +1301,9 @@ exit 0 # PRERELEASE %changelog +* Tue Nov 14 2023 Frank Ch. Eigler - 5.0-3 +- RHEL-16549 + * Mon Nov 06 2023 Frank Ch. Eigler - 5.0-2 - License header tweak