kdb: use memmove instead of overlapping memcpy
authorArnd Bergmann <arnd@arndb.de>
Fri, 2 Feb 2018 14:59:40 +0000 (15:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 8 Dec 2018 12:03:36 +0000 (13:03 +0100)
commit 2cf2f0d5b91fd1b06a6ae260462fc7945ea84add upstream.

gcc discovered that the memcpy() arguments in kdbnearsym() overlap, so
we should really use memmove(), which is defined to handle that correctly:

In function 'memcpy',
    inlined from 'kdbnearsym' at /git/arm-soc/kernel/debug/kdb/kdb_support.c:132:4:
/git/arm-soc/include/linux/string.h:353:9: error: '__builtin_memcpy' accessing 792 bytes at offsets 0 and 8 overlaps 784 bytes at offset 8 [-Werror=restrict]
  return __builtin_memcpy(p, q, size);

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/debug/kdb/kdb_support.c

index 014f6fbb3832771189ead391828cc8d831c6e363..b14b0925c1848e8e4f87cedd0fd6de4f96de8747 100644 (file)
@@ -129,13 +129,13 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
                }
                if (i >= ARRAY_SIZE(kdb_name_table)) {
                        debug_kfree(kdb_name_table[0]);
-                       memcpy(kdb_name_table, kdb_name_table+1,
+                       memmove(kdb_name_table, kdb_name_table+1,
                               sizeof(kdb_name_table[0]) *
                               (ARRAY_SIZE(kdb_name_table)-1));
                } else {
                        debug_kfree(knt1);
                        knt1 = kdb_name_table[i];
-                       memcpy(kdb_name_table+i, kdb_name_table+i+1,
+                       memmove(kdb_name_table+i, kdb_name_table+i+1,
                               sizeof(kdb_name_table[0]) *
                               (ARRAY_SIZE(kdb_name_table)-i-1));
                }