From: Greg Kroah-Hartman Date: Tue, 25 Jun 2019 08:06:39 +0000 (+0800) Subject: 4.19-stable patches X-Git-Tag: v4.4.184~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d855f08fd197a22e9c78bb7263d00d6a718d0c9d;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: perf-header-fix-unchecked-usage-of-strncpy.patch perf-help-remove-needless-use-of-strncpy.patch perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch --- diff --git a/queue-4.19/perf-header-fix-unchecked-usage-of-strncpy.patch b/queue-4.19/perf-header-fix-unchecked-usage-of-strncpy.patch new file mode 100644 index 00000000000..e790bb716bf --- /dev/null +++ b/queue-4.19/perf-header-fix-unchecked-usage-of-strncpy.patch @@ -0,0 +1,46 @@ +From 5192bde7d98c99f2cd80225649e3c2e7493722f7 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Thu, 6 Dec 2018 11:09:46 -0300 +Subject: perf header: Fix unchecked usage of strncpy() + +From: Arnaldo Carvalho de Melo + +commit 5192bde7d98c99f2cd80225649e3c2e7493722f7 upstream. + +The strncpy() function may leave the destination string buffer +unterminated, better use strlcpy() that we have a __weak fallback +implementation for systems without it. + +This fixes this warning on an Alpine Linux Edge system with gcc 8.2: + + util/header.c: In function 'perf_event__synthesize_event_update_name': + util/header.c:3625:2: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] + strncpy(ev->data, evsel->name, len); + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + util/header.c:3618:15: note: length computed here + size_t len = strlen(evsel->name); + ^~~~~~~~~~~~~~~~~~~ + +Cc: Adrian Hunter +Cc: Jiri Olsa +Cc: Namhyung Kim +Fixes: a6e5281780d1 ("perf tools: Add event_update event unit type") +Link: https://lkml.kernel.org/n/tip-wycz66iy8dl2z3yifgqf894p@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman + +--- + tools/perf/util/header.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/perf/util/header.c ++++ b/tools/perf/util/header.c +@@ -3562,7 +3562,7 @@ perf_event__synthesize_event_update_name + if (ev == NULL) + return -ENOMEM; + +- strncpy(ev->data, evsel->name, len); ++ strlcpy(ev->data, evsel->name, len + 1); + err = process(tool, (union perf_event*) ev, NULL, NULL); + free(ev); + return err; diff --git a/queue-4.19/perf-help-remove-needless-use-of-strncpy.patch b/queue-4.19/perf-help-remove-needless-use-of-strncpy.patch new file mode 100644 index 00000000000..45e6cbc0d95 --- /dev/null +++ b/queue-4.19/perf-help-remove-needless-use-of-strncpy.patch @@ -0,0 +1,48 @@ +From b6313899f4ed2e76b8375cf8069556f5b94fbff0 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Thu, 6 Dec 2018 11:20:21 -0300 +Subject: perf help: Remove needless use of strncpy() + +From: Arnaldo Carvalho de Melo + +commit b6313899f4ed2e76b8375cf8069556f5b94fbff0 upstream. + +Since we make sure the destination buffer has at least strlen(orig) + 1, +no need to do a strncpy(dest, orig, strlen(orig)), just use strcpy(dest, +orig). + +This silences this gcc 8.2 warning on Alpine Linux: + + In function 'add_man_viewer', + inlined from 'perf_help_config' at builtin-help.c:284:3: + builtin-help.c:192:2: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] + strncpy((*p)->name, name, len); + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + builtin-help.c: In function 'perf_help_config': + builtin-help.c:187:15: note: length computed here + size_t len = strlen(name); + ^~~~~~~~~~~~ + +Cc: Adrian Hunter +Cc: Jiri Olsa +Cc: Namhyung Kim +Fixes: 078006012401 ("perf_counter tools: add in basic glue from Git") +Link: https://lkml.kernel.org/n/tip-2f69l7drca427ob4km8i7kvo@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman + +--- + tools/perf/builtin-help.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/perf/builtin-help.c ++++ b/tools/perf/builtin-help.c +@@ -189,7 +189,7 @@ static void add_man_viewer(const char *n + while (*p) + p = &((*p)->next); + *p = zalloc(sizeof(**p) + len + 1); +- strncpy((*p)->name, name, len); ++ strcpy((*p)->name, name); + } + + static int supported_man_viewer(const char *name, size_t len) diff --git a/queue-4.19/perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch b/queue-4.19/perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch new file mode 100644 index 00000000000..d730cc13e53 --- /dev/null +++ b/queue-4.19/perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch @@ -0,0 +1,49 @@ +From 4d0f16d059ddb91424480d88473f7392f24aebdc Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Thu, 6 Dec 2018 11:41:03 -0300 +Subject: perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit set nul + +From: Arnaldo Carvalho de Melo + +commit 4d0f16d059ddb91424480d88473f7392f24aebdc upstream. + +The strncpy() function may leave the destination string buffer +unterminated, better use strlcpy() that we have a __weak fallback +implementation for systems without it. + +In this case we are actually setting the null byte at the right place, +but since we pass the buffer size as the limit to strncpy() and not +it minus one, gcc ends up warning us about that, see below. So, lets +just switch to the shorter form provided by strlcpy(). + +This fixes this warning on an Alpine Linux Edge system with gcc 8.2: + + ui/tui/helpline.c: In function 'tui_helpline__push': + ui/tui/helpline.c:27:2: error: 'strncpy' specified bound 512 equals destination size [-Werror=stringop-truncation] + strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0'; + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + cc1: all warnings being treated as errors + +Cc: Adrian Hunter +Cc: Jiri Olsa +Cc: Namhyung Kim +Fixes: e6e904687949 ("perf ui: Introduce struct ui_helpline") +Link: https://lkml.kernel.org/n/tip-d1wz0hjjsh19xbalw69qpytj@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman + +--- + tools/perf/ui/tui/helpline.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/perf/ui/tui/helpline.c ++++ b/tools/perf/ui/tui/helpline.c +@@ -24,7 +24,7 @@ static void tui_helpline__push(const cha + SLsmg_set_color(0); + SLsmg_write_nstring((char *)msg, SLtt_Screen_Cols); + SLsmg_refresh(); +- strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0'; ++ strlcpy(ui_helpline__current, msg, sz); + } + + static int tui_helpline__show(const char *format, va_list ap) diff --git a/queue-4.19/series b/queue-4.19/series new file mode 100644 index 00000000000..1419671bd60 --- /dev/null +++ b/queue-4.19/series @@ -0,0 +1,3 @@ +perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch +perf-help-remove-needless-use-of-strncpy.patch +perf-header-fix-unchecked-usage-of-strncpy.patch