aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-14 16:14:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-14 16:14:10 -0400
commitca4b40629f4edd3a961bedcd118e3ad05439ec71 (patch)
treeed11cd9cf386d6bb38772d4975aae497717f9e2a
parent280664f558c9d973315d48f125eb664cc607d089 (diff)
parentca976bfb3154c7bc67c4651ecd144fdf67ccaee7 (diff)
Merge tag 'kgdb-5.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux
Pull kgdb updates from Daniel Thompson: "Mostly cleanups but there are also a couple of fixes for out-of-bounds accesses (including a potential write to the byte before a static buffer). The main changes are: - Fixes to 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" * tag 'kgdb-5.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux: kdb: Fix bound check compiler warning kdb: do a sanity check on the cpu in kdb_per_cpu() kdb: Get rid of broken attempt to print CCVERSION in kdb summary misc: kgdbts: fix out-of-bounds access in function param_set_kgdbts_var kdb: kdb_support: replace strcpy() by strscpy() gdbstub: Replace strcpy() by strscpy() gdbstub: mark expected switch fall-throughs
-rw-r--r--kernel/debug/gdbstub.c9
-rw-r--r--kernel/debug/kdb/Makefile1
-rw-r--r--kernel/debug/kdb/kdb_io.c2
-rw-r--r--kernel/debug/kdb/kdb_main.c3
-rw-r--r--kernel/debug/kdb/kdb_support.c2
5 files changed, 8 insertions, 9 deletions
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index 7510dc687c0d..4b280fc7dd67 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -1033,13 +1033,14 @@ int gdb_serial_stub(struct kgdb_state *ks)
1033 return DBG_PASS_EVENT; 1033 return DBG_PASS_EVENT;
1034 } 1034 }
1035#endif 1035#endif
1036 /* Fall through */
1036 case 'C': /* Exception passing */ 1037 case 'C': /* Exception passing */
1037 tmp = gdb_cmd_exception_pass(ks); 1038 tmp = gdb_cmd_exception_pass(ks);
1038 if (tmp > 0) 1039 if (tmp > 0)
1039 goto default_handle; 1040 goto default_handle;
1040 if (tmp == 0) 1041 if (tmp == 0)
1041 break; 1042 break;
1042 /* Fall through on tmp < 0 */ 1043 /* Fall through - on tmp < 0 */
1043 case 'c': /* Continue packet */ 1044 case 'c': /* Continue packet */
1044 case 's': /* Single step packet */ 1045 case 's': /* Single step packet */
1045 if (kgdb_contthread && kgdb_contthread != current) { 1046 if (kgdb_contthread && kgdb_contthread != current) {
@@ -1048,7 +1049,7 @@ int gdb_serial_stub(struct kgdb_state *ks)
1048 break; 1049 break;
1049 } 1050 }
1050 dbg_activate_sw_breakpoints(); 1051 dbg_activate_sw_breakpoints();
1051 /* Fall through to default processing */ 1052 /* Fall through - to default processing */
1052 default: 1053 default:
1053default_handle: 1054default_handle:
1054 error = kgdb_arch_handle_exception(ks->ex_vector, 1055 error = kgdb_arch_handle_exception(ks->ex_vector,
@@ -1094,10 +1095,10 @@ int gdbstub_state(struct kgdb_state *ks, char *cmd)
1094 return error; 1095 return error;
1095 case 's': 1096 case 's':
1096 case 'c': 1097 case 'c':
1097 strcpy(remcom_in_buffer, cmd); 1098 strscpy(remcom_in_buffer, cmd, sizeof(remcom_in_buffer));
1098 return 0; 1099 return 0;
1099 case '$': 1100 case '$':
1100 strcpy(remcom_in_buffer, cmd); 1101 strscpy(remcom_in_buffer, cmd, sizeof(remcom_in_buffer));
1101 gdbstub_use_prev_in_buf = strlen(remcom_in_buffer); 1102 gdbstub_use_prev_in_buf = strlen(remcom_in_buffer);
1102 gdbstub_prev_in_buf_pos = 0; 1103 gdbstub_prev_in_buf_pos = 0;
1103 return 0; 1104 return 0;
diff --git a/kernel/debug/kdb/Makefile b/kernel/debug/kdb/Makefile
index d4fc58f4b88d..efac857c5511 100644
--- a/kernel/debug/kdb/Makefile
+++ b/kernel/debug/kdb/Makefile
@@ -6,7 +6,6 @@
6# Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved. 6# Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved.
7# 7#
8 8
9CCVERSION := $(shell $(CC) -v 2>&1 | sed -ne '$$p')
10obj-y := kdb_io.o kdb_main.o kdb_support.o kdb_bt.o gen-kdb_cmds.o kdb_bp.o kdb_debugger.o 9obj-y := kdb_io.o kdb_main.o kdb_support.o kdb_bt.o gen-kdb_cmds.o kdb_bp.o kdb_debugger.o
11obj-$(CONFIG_KDB_KEYBOARD) += kdb_keyboard.o 10obj-$(CONFIG_KDB_KEYBOARD) += kdb_keyboard.o
12 11
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 6a4b41484afe..3a5184eb6977 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -446,7 +446,7 @@ poll_again:
446char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt) 446char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt)
447{ 447{
448 if (prompt && kdb_prompt_str != prompt) 448 if (prompt && kdb_prompt_str != prompt)
449 strncpy(kdb_prompt_str, prompt, CMD_BUFLEN); 449 strscpy(kdb_prompt_str, prompt, CMD_BUFLEN);
450 kdb_printf(kdb_prompt_str); 450 kdb_printf(kdb_prompt_str);
451 kdb_nextline = 1; /* Prompt and input resets line number */ 451 kdb_nextline = 1; /* Prompt and input resets line number */
452 return kdb_read(buffer, bufsize); 452 return kdb_read(buffer, bufsize);
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 82a3b32a7cfc..9ecfa37c7fbf 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -2522,7 +2522,6 @@ static int kdb_summary(int argc, const char **argv)
2522 kdb_printf("machine %s\n", init_uts_ns.name.machine); 2522 kdb_printf("machine %s\n", init_uts_ns.name.machine);
2523 kdb_printf("nodename %s\n", init_uts_ns.name.nodename); 2523 kdb_printf("nodename %s\n", init_uts_ns.name.nodename);
2524 kdb_printf("domainname %s\n", init_uts_ns.name.domainname); 2524 kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
2525 kdb_printf("ccversion %s\n", __stringify(CCVERSION));
2526 2525
2527 now = __ktime_get_real_seconds(); 2526 now = __ktime_get_real_seconds();
2528 time64_to_tm(now, 0, &tm); 2527 time64_to_tm(now, 0, &tm);
@@ -2584,7 +2583,7 @@ static int kdb_per_cpu(int argc, const char **argv)
2584 diag = kdbgetularg(argv[3], &whichcpu); 2583 diag = kdbgetularg(argv[3], &whichcpu);
2585 if (diag) 2584 if (diag)
2586 return diag; 2585 return diag;
2587 if (!cpu_online(whichcpu)) { 2586 if (whichcpu >= nr_cpu_ids || !cpu_online(whichcpu)) {
2588 kdb_printf("cpu %ld is not online\n", whichcpu); 2587 kdb_printf("cpu %ld is not online\n", whichcpu);
2589 return KDB_BADCPUNUM; 2588 return KDB_BADCPUNUM;
2590 } 2589 }
diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c
index 50bf9b119bad..b8e6306e7e13 100644
--- a/kernel/debug/kdb/kdb_support.c
+++ b/kernel/debug/kdb/kdb_support.c
@@ -192,7 +192,7 @@ int kallsyms_symbol_complete(char *prefix_name, int max_len)
192 192
193 while ((name = kdb_walk_kallsyms(&pos))) { 193 while ((name = kdb_walk_kallsyms(&pos))) {
194 if (strncmp(name, prefix_name, prefix_len) == 0) { 194 if (strncmp(name, prefix_name, prefix_len) == 0) {
195 strcpy(ks_namebuf, name); 195 strscpy(ks_namebuf, name, sizeof(ks_namebuf));
196 /* Work out the longest name that matches the prefix */ 196 /* Work out the longest name that matches the prefix */
197 if (++number == 1) { 197 if (++number == 1) {
198 prev_len = min_t(int, max_len-1, 198 prev_len = min_t(int, max_len-1,