]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Jun 2019 08:06:42 +0000 (16:06 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Jun 2019 08:06:42 +0000 (16:06 +0800)
added patches:
perf-help-remove-needless-use-of-strncpy.patch
perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch

queue-4.4/perf-help-remove-needless-use-of-strncpy.patch [new file with mode: 0644]
queue-4.4/perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/perf-help-remove-needless-use-of-strncpy.patch b/queue-4.4/perf-help-remove-needless-use-of-strncpy.patch
new file mode 100644 (file)
index 0000000..7bb7345
--- /dev/null
@@ -0,0 +1,48 @@
+From b6313899f4ed2e76b8375cf8069556f5b94fbff0 Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Thu, 6 Dec 2018 11:20:21 -0300
+Subject: perf help: Remove needless use of strncpy()
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+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 <adrian.hunter@intel.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+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 <acme@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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
+@@ -179,7 +179,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.4/perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch b/queue-4.4/perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch
new file mode 100644 (file)
index 0000000..8940ad3
--- /dev/null
@@ -0,0 +1,49 @@
+From 4d0f16d059ddb91424480d88473f7392f24aebdc Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+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 <acme@redhat.com>
+
+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 <adrian.hunter@intel.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+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 <acme@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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
+@@ -23,7 +23,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)
index 531057bc0b8ce1bdba4a90f815d6413facd47f3f..81d6829c903ac561e56ceba33e3f1fac221bfeda 100644 (file)
@@ -23,3 +23,5 @@ bluetooth-fix-regression-with-minimum-encryption-key-size-alignment.patch
 smb3-retry-on-status_insufficient_resources-instead-of-failing-write.patch
 cfg80211-fix-memory-leak-of-wiphy-device-name.patch
 mac80211-drop-robust-management-frames-from-unknown-ta.patch
+perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch
+perf-help-remove-needless-use-of-strncpy.patch