From: Greg Kroah-Hartman Date: Thu, 26 Jan 2023 08:59:53 +0000 (+0100) Subject: 4.19-stable patches X-Git-Tag: v5.10.166~76 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9aa164edfbbea1837bdf4845eb31fd7706d92a7d;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: perf-env-do-not-return-pointers-to-local-variables.patch --- diff --git a/queue-4.19/perf-env-do-not-return-pointers-to-local-variables.patch b/queue-4.19/perf-env-do-not-return-pointers-to-local-variables.patch new file mode 100644 index 00000000000..d19deecf782 --- /dev/null +++ b/queue-4.19/perf-env-do-not-return-pointers-to-local-variables.patch @@ -0,0 +1,49 @@ +From ebcb9464a2ae3a547e97de476575c82ece0e93e2 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Mon, 2 Mar 2020 11:23:03 -0300 +Subject: perf env: Do not return pointers to local variables + +From: Arnaldo Carvalho de Melo + +commit ebcb9464a2ae3a547e97de476575c82ece0e93e2 upstream. + +It is possible to return a pointer to a local variable when looking up +the architecture name for the running system and no normalization is +done on that value, i.e. we may end up returning the uts.machine local +variable. + +While this doesn't happen on most arches, as normalization takes place, +lets fix this by making that a static variable and optimize it a bit by +not always running uname(), only the first time. + +Noticed in fedora rawhide running with: + + [perfbuilder@a5ff49d6e6e4 ~]$ gcc --version + gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8) + +Reported-by: Jiri Olsa +Cc: Adrian Hunter +Cc: Namhyung Kim +Signed-off-by: Arnaldo Carvalho de Melo +Cc: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman +--- + tools/perf/util/env.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/tools/perf/util/env.c ++++ b/tools/perf/util/env.c +@@ -163,11 +163,11 @@ static const char *normalize_arch(char * + + const char *perf_env__arch(struct perf_env *env) + { +- struct utsname uts; + char *arch_name; + + if (!env || !env->arch) { /* Assume local operation */ +- if (uname(&uts) < 0) ++ static struct utsname uts = { .machine[0] = '\0', }; ++ if (uts.machine[0] == '\0' && uname(&uts) < 0) + return NULL; + arch_name = uts.machine; + } else diff --git a/queue-4.19/series b/queue-4.19/series index f7ee4b7a670..e1c8b664cba 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -36,3 +36,4 @@ mmc-sdhci-esdhc-imx-disable-the-cmd-crc-check-for-st.patch mmc-sdhci-esdhc-imx-correct-the-tuning-start-tap-and.patch netfilter-conntrack-do-not-renew-entry-stuck-in-tcp-.patch block-fix-and-cleanup-bio_check_ro.patch +perf-env-do-not-return-pointers-to-local-variables.patch