]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Feb 2019 11:36:52 +0000 (12:36 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Feb 2019 11:36:52 +0000 (12:36 +0100)
added patches:
string-drop-__must_check-from-strscpy-and-restore-strscpy-usages-in-cgroup.patch
test_hexdump-use-memcpy-instead-of-strncpy.patch
tipc-use-destination-length-for-copy-string.patch

queue-4.4/series
queue-4.4/string-drop-__must_check-from-strscpy-and-restore-strscpy-usages-in-cgroup.patch [new file with mode: 0644]
queue-4.4/test_hexdump-use-memcpy-instead-of-strncpy.patch [new file with mode: 0644]
queue-4.4/tipc-use-destination-length-for-copy-string.patch [new file with mode: 0644]

index cf6664c7c85b620e8803bd66aaef1f26f452c620..4a2a423a1dac4efc571d789652dafdb0665b8370 100644 (file)
@@ -76,3 +76,6 @@ kernel-hung_task.c-break-rcu-locks-based-on-jiffies.patch
 fs-epoll-drop-ovflist-branch-prediction.patch
 exec-load_script-don-t-blindly-truncate-shebang-stri.patch
 thermal-hwmon-inline-helpers-when-config_thermal_hwmon-is-not-set.patch
+test_hexdump-use-memcpy-instead-of-strncpy.patch
+tipc-use-destination-length-for-copy-string.patch
+string-drop-__must_check-from-strscpy-and-restore-strscpy-usages-in-cgroup.patch
diff --git a/queue-4.4/string-drop-__must_check-from-strscpy-and-restore-strscpy-usages-in-cgroup.patch b/queue-4.4/string-drop-__must_check-from-strscpy-and-restore-strscpy-usages-in-cgroup.patch
new file mode 100644 (file)
index 0000000..3e5c052
--- /dev/null
@@ -0,0 +1,65 @@
+From 5c067898febcbe6f10ebc2d3c576eba629739326 Mon Sep 17 00:00:00 2001
+From: Tejun Heo <tj@kernel.org>
+Date: Tue, 9 Jan 2018 07:21:15 -0800
+Subject: string: drop __must_check from strscpy() and restore strscpy() usages in cgroup
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Tejun Heo <tj@kernel.org>
+
+commit 08a77676f9c5fc69a681ccd2cd8140e65dcb26c7 upstream.
+
+e7fd37ba1217 ("cgroup: avoid copying strings longer than the buffers")
+converted possibly unsafe strncpy() usages in cgroup to strscpy().
+However, although the callsites are completely fine with truncated
+copied, because strscpy() is marked __must_check, it led to the
+following warnings.
+
+  kernel/cgroup/cgroup.c: In function ‘cgroup_file_name’:
+  kernel/cgroup/cgroup.c:1400:10: warning: ignoring return value of ‘strscpy’, declared with attribute warn_unused_result [-Wunused-result]
+     strscpy(buf, cft->name, CGROUP_FILE_NAME_MAX);
+              ^
+
+To avoid the warnings, 50034ed49645 ("cgroup: use strlcpy() instead of
+strscpy() to avoid spurious warning") switched them to strlcpy().
+
+strlcpy() is worse than strlcpy() because it unconditionally runs
+strlen() on the source string, and the only reason we switched to
+strlcpy() here was because it was lacking __must_check, which doesn't
+reflect any material differences between the two function.  It's just
+that someone added __must_check to strscpy() and not to strlcpy().
+
+These basic string copy operations are used in variety of ways, and
+one of not-so-uncommon use cases is safely handling truncated copies,
+where the caller naturally doesn't care about the return value.  The
+__must_check doesn't match the actual use cases and forces users to
+opt for inferior variants which lack __must_check by happenstance or
+spread ugly (void) casts.
+
+Remove __must_check from strscpy() and restore strscpy() usages in
+cgroup.
+
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
+Cc: Arnd Bergmann <arnd@arndb.de>
+Cc: Chris Metcalf <cmetcalf@ezchip.com>
+[backport only the string.h portion to remove build warnings starting to show up - gregkh]
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/string.h |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/include/linux/string.h
++++ b/include/linux/string.h
+@@ -26,7 +26,7 @@ extern char * strncpy(char *,const char
+ size_t strlcpy(char *, const char *, size_t);
+ #endif
+ #ifndef __HAVE_ARCH_STRSCPY
+-ssize_t __must_check strscpy(char *, const char *, size_t);
++ssize_t strscpy(char *, const char *, size_t);
+ #endif
+ #ifndef __HAVE_ARCH_STRCAT
+ extern char * strcat(char *, const char *);
diff --git a/queue-4.4/test_hexdump-use-memcpy-instead-of-strncpy.patch b/queue-4.4/test_hexdump-use-memcpy-instead-of-strncpy.patch
new file mode 100644 (file)
index 0000000..593afd3
--- /dev/null
@@ -0,0 +1,38 @@
+From b1286ed7158e9b62787508066283ab0b8850b518 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Fri, 30 Nov 2018 12:13:15 -0800
+Subject: test_hexdump: use memcpy instead of strncpy
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit b1286ed7158e9b62787508066283ab0b8850b518 upstream.
+
+New versions of gcc reasonably warn about the odd pattern of
+
+       strncpy(p, q, strlen(q));
+
+which really doesn't make sense: the strncpy() ends up being just a slow
+and odd way to write memcpy() in this case.
+
+Apparently there was a patch for this floating around earlier, but it
+got lost.
+
+Acked-again-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ lib/test-hexdump.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/lib/test-hexdump.c
++++ b/lib/test-hexdump.c
+@@ -81,7 +81,7 @@ static void __init test_hexdump(size_t l
+               const char *q = *result++;
+               size_t amount = strlen(q);
+-              strncpy(p, q, amount);
++              memcpy(p, q, amount);
+               p += amount + 1;
+       }
+       if (i)
diff --git a/queue-4.4/tipc-use-destination-length-for-copy-string.patch b/queue-4.4/tipc-use-destination-length-for-copy-string.patch
new file mode 100644 (file)
index 0000000..6a6d622
--- /dev/null
@@ -0,0 +1,43 @@
+From 29e270fc32192e7729057963ae7120663856c93e Mon Sep 17 00:00:00 2001
+From: Guoqing Jiang <gqjiang@suse.com>
+Date: Fri, 19 Oct 2018 12:08:22 +0800
+Subject: tipc: use destination length for copy string
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Guoqing Jiang <gqjiang@suse.com>
+
+commit 29e270fc32192e7729057963ae7120663856c93e upstream.
+
+Got below warning with gcc 8.2 compiler.
+
+net/tipc/topsrv.c: In function ‘tipc_topsrv_start’:
+net/tipc/topsrv.c:660:2: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
+  strncpy(srv->name, name, strlen(name) + 1);
+  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+net/tipc/topsrv.c:660:27: note: length computed here
+  strncpy(srv->name, name, strlen(name) + 1);
+                           ^~~~~~~~~~~~
+So change it to correct length and use strscpy.
+
+Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
+Acked-by: Ying Xue <ying.xue@windriver.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ net/tipc/subscr.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/tipc/subscr.c
++++ b/net/tipc/subscr.c
+@@ -337,7 +337,7 @@ int tipc_topsrv_start(struct net *net)
+       topsrv->tipc_conn_new           = tipc_subscrb_connect_cb;
+       topsrv->tipc_conn_shutdown      = tipc_subscrb_shutdown_cb;
+-      strncpy(topsrv->name, name, strlen(name) + 1);
++      strscpy(topsrv->name, name, sizeof(topsrv->name));
+       tn->topsrv = topsrv;
+       atomic_set(&tn->subscription_count, 0);