kgdb patches for 5.2-rc1

Mostly clean ups but there are also a couple of out-of-bounds accesses
(including a potential write to the byte before a static buffer).

The main changes are:

 * Fixes those out-of-bounds access (empty string to configure
   test module could write the byte before a buffer, high cpu counts
   could read outside of per-cpu structures).

 * Improvements to string handling problems picked up by new compiler
   warnings and other static checks. Most are fixing benign issues that
   can't be tickled without code changes but still reduce the wtf factor
   a little.

 * Tidy up the terminal output.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
kdb: Fix bound check compiler warning

The strncpy() function may leave the destination string buffer
unterminated, better use strscpy() instead.

This fixes the following warning with gcc 8.2:

kernel/debug/kdb/kdb_io.c: In function 'kdb_getstr':
kernel/debug/kdb/kdb_io.c:449:3: warning: 'strncpy' specified bound 256 equals destination size [-Wstringop-truncation]
   strncpy(kdb_prompt_str, prompt, CMD_BUFLEN);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
1 file changed