From: Greg Kroah-Hartman Date: Mon, 1 Nov 2021 08:23:49 +0000 (+0100) Subject: 5.4-stable patches X-Git-Tag: v4.4.291~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6860408cd754fa81655bb88738d1abc66c036ee7;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: perf-script-check-session-header.env.arch-before-using-it.patch --- diff --git a/queue-5.4/perf-script-check-session-header.env.arch-before-using-it.patch b/queue-5.4/perf-script-check-session-header.env.arch-before-using-it.patch new file mode 100644 index 00000000000..fa80bfe1a5a --- /dev/null +++ b/queue-5.4/perf-script-check-session-header.env.arch-before-using-it.patch @@ -0,0 +1,56 @@ +From 29c77550eef31b0d72a45b49eeab03b8963264e8 Mon Sep 17 00:00:00 2001 +From: Song Liu +Date: Sun, 3 Oct 2021 22:32:38 -0700 +Subject: perf script: Check session->header.env.arch before using it + +From: Song Liu + +commit 29c77550eef31b0d72a45b49eeab03b8963264e8 upstream. + +When perf.data is not written cleanly, we would like to process existing +data as much as possible (please see f_header.data.size == 0 condition +in perf_session__read_header). However, perf.data with partial data may +crash perf. Specifically, we see crash in 'perf script' for NULL +session->header.env.arch. + +Fix this by checking session->header.env.arch before using it to determine +native_arch. Also split the if condition so it is easier to read. + +Committer notes: + +If it is a pipe, we already assume is a native arch, so no need to check +session->header.env.arch. + +Signed-off-by: Song Liu +Cc: Peter Zijlstra +Cc: kernel-team@fb.com +Cc: stable@vger.kernel.org +Link: http://lore.kernel.org/lkml/20211004053238.514936-1-songliubraving@fb.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman +--- + tools/perf/builtin-script.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +--- a/tools/perf/builtin-script.c ++++ b/tools/perf/builtin-script.c +@@ -3779,11 +3779,15 @@ int cmd_script(int argc, const char **ar + goto out_delete; + + uname(&uts); +- if (data.is_pipe || /* assume pipe_mode indicates native_arch */ +- !strcmp(uts.machine, session->header.env.arch) || +- (!strcmp(uts.machine, "x86_64") && +- !strcmp(session->header.env.arch, "i386"))) ++ if (data.is_pipe) { /* Assume pipe_mode indicates native_arch */ + native_arch = true; ++ } else if (session->header.env.arch) { ++ if (!strcmp(uts.machine, session->header.env.arch)) ++ native_arch = true; ++ else if (!strcmp(uts.machine, "x86_64") && ++ !strcmp(session->header.env.arch, "i386")) ++ native_arch = true; ++ } + + script.session = session; + script__setup_sample_type(&script); diff --git a/queue-5.4/series b/queue-5.4/series index 0029fef4d5b..08384e5c586 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -48,3 +48,4 @@ net-use-netif_is_bridge_port-to-check-for-iff_bridge.patch cfg80211-correct-bridge-4addr-mode-check.patch kvm-s390-clear-kicked_mask-before-sleeping-again.patch kvm-s390-preserve-deliverable_mask-in-__airqs_kick_s.patch +perf-script-check-session-header.env.arch-before-using-it.patch