All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-oe][PATCH] ltrace: Fix build on ppc64 with gcc12
@ 2022-04-20  1:54 Khem Raj
  0 siblings, 0 replies; only message in thread
From: Khem Raj @ 2022-04-20  1:54 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Khem Raj

gcc-12 has a better static analyser and finds additional use-after-free
case, addressed by removing the double free

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...01-ppc-plt-do-not-free-symbol-libsym.patch | 29 +++++++++++++++++++
 meta-oe/recipes-devtools/ltrace/ltrace_git.bb |  1 +
 2 files changed, 30 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/ltrace/ltrace/0001-ppc-plt-do-not-free-symbol-libsym.patch

diff --git a/meta-oe/recipes-devtools/ltrace/ltrace/0001-ppc-plt-do-not-free-symbol-libsym.patch b/meta-oe/recipes-devtools/ltrace/ltrace/0001-ppc-plt-do-not-free-symbol-libsym.patch
new file mode 100644
index 0000000000..4793e561c0
--- /dev/null
+++ b/meta-oe/recipes-devtools/ltrace/ltrace/0001-ppc-plt-do-not-free-symbol-libsym.patch
@@ -0,0 +1,29 @@
+From f47672bed5905ae382e80b09dafca9a8da45aa67 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 19 Apr 2022 18:44:36 -0700
+Subject: [PATCH] ppc/plt: do not free symbol libsym
+
+delete_symbol_chain() will call free as well if sybol is non-null
+it also fixes use-after-free warnings that compiler emits
+
+Upstream-Status: Submitted [https://gitlab.com/cespedes/ltrace/-/merge_requests/2]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ sysdeps/linux-gnu/ppc/plt.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
+index 5f81889..7c1c025 100644
+--- a/sysdeps/linux-gnu/ppc/plt.c
++++ b/sysdeps/linux-gnu/ppc/plt.c
+@@ -687,7 +687,6 @@ arch_elf_add_func_entry(struct process *proc, struct ltelf *lte,
+ 		if (libsym == NULL
+ 		    || library_symbol_init(libsym, addr, full_name, 1,
+ 					   LS_TOPLT_NONE) < 0) {
+-			free(libsym);
+ 			delete_symbol_chain(libsym);
+ 			libsym = NULL;
+ 			fprintf(stderr, "Couldn't add symbol %s"
+-- 
+2.36.0
+
diff --git a/meta-oe/recipes-devtools/ltrace/ltrace_git.bb b/meta-oe/recipes-devtools/ltrace/ltrace_git.bb
index ad58428718..72bec301fb 100644
--- a/meta-oe/recipes-devtools/ltrace/ltrace_git.bb
+++ b/meta-oe/recipes-devtools/ltrace/ltrace_git.bb
@@ -30,6 +30,7 @@ SRC_URI = "git://github.com/sparkleholic/ltrace.git;branch=master;protocol=http;
            file://0001-ensure-the-struct-pointers-are-null-initilized.patch \
            file://0001-ppc-Remove-unused-host_powerpc64-function.patch \
            file://0001-mips-Use-hardcodes-values-for-ABI-syscall-bases.patch \
+           file://0001-ppc-plt-do-not-free-symbol-libsym.patch \
            "
 SRC_URI:append:libc-musl = " file://add_ppc64le.patch"
 
-- 
2.36.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-21 16:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20  1:54 [meta-oe][PATCH] ltrace: Fix build on ppc64 with gcc12 Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.