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> -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEELzVBU1D3lWq6cKzwfOMlXTn3iKEFAlza6CEACgkQfOMlXTn3 iKHkwA/8CmCq7UA3ZZsItHYn48Xa4YzxySErhpocsqa7U7tPh7f7ETv6NkfmjxEQ MGmQflKw/yU3avR6eHUfJcd4AO3+x0Vi5wR9fhevAVu3sfnjTjTjP0F2tDjWe+Y/ TJob4/gSssmDp1+DtFvOQdOmGVz9C7xMQ2wZFjQcpAwesLLbwu+KPZDcBPpyRnl1 zSOIUtTxHH6ay2PX57CNAWEmE4SFoUha7712GTHVHe3rykrC+CLYNeCRzUuyTSAz OaPTNzd/OFz+uLcsvTPothpc3wUfM4MUkuCkAVKpuMcB2D+/7WqqszUfHYWJ27bH oeYqRyeQaRa6COFkxZ4XZQRMBOYzzidVboTDjlTj391qq5L32tje75TtfHgCJ/p7 vlg0QdbrHOFaDF9aXcmqLr7kNRi83NxNPhg4XHA75MRHFBGvRkMd3jmuZdShFKc7 Yegr+pR0FJwivZz8+UcRPAdI5gdmSWLdpeB2GhtZqDk3975Qjvsy90ieG7GQnjR8 /ewoYsFQ5/qXwyZzJ+kHxAmTMWpGYx8Kge77j5UMljPsuSuHU56vUt4ovzSiSzuX dTAxLRmrYi6Dlri76EHEoE+1mx301ymK4MXMz8WnNVQhnPnkCcEXx7P3neCB/wuX w1O2VvMQ8b4si1/M71QFcAgQjMcJz7z8wGwhfnnqFPgZmVT5n/8= =SsRX -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
ca4b40629f
|
@ -1033,13 +1033,14 @@ int gdb_serial_stub(struct kgdb_state *ks)
|
|||
return DBG_PASS_EVENT;
|
||||
}
|
||||
#endif
|
||||
/* Fall through */
|
||||
case 'C': /* Exception passing */
|
||||
tmp = gdb_cmd_exception_pass(ks);
|
||||
if (tmp > 0)
|
||||
goto default_handle;
|
||||
if (tmp == 0)
|
||||
break;
|
||||
/* Fall through on tmp < 0 */
|
||||
/* Fall through - on tmp < 0 */
|
||||
case 'c': /* Continue packet */
|
||||
case 's': /* Single step packet */
|
||||
if (kgdb_contthread && kgdb_contthread != current) {
|
||||
|
@ -1048,7 +1049,7 @@ int gdb_serial_stub(struct kgdb_state *ks)
|
|||
break;
|
||||
}
|
||||
dbg_activate_sw_breakpoints();
|
||||
/* Fall through to default processing */
|
||||
/* Fall through - to default processing */
|
||||
default:
|
||||
default_handle:
|
||||
error = kgdb_arch_handle_exception(ks->ex_vector,
|
||||
|
@ -1094,10 +1095,10 @@ int gdbstub_state(struct kgdb_state *ks, char *cmd)
|
|||
return error;
|
||||
case 's':
|
||||
case 'c':
|
||||
strcpy(remcom_in_buffer, cmd);
|
||||
strscpy(remcom_in_buffer, cmd, sizeof(remcom_in_buffer));
|
||||
return 0;
|
||||
case '$':
|
||||
strcpy(remcom_in_buffer, cmd);
|
||||
strscpy(remcom_in_buffer, cmd, sizeof(remcom_in_buffer));
|
||||
gdbstub_use_prev_in_buf = strlen(remcom_in_buffer);
|
||||
gdbstub_prev_in_buf_pos = 0;
|
||||
return 0;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
# Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved.
|
||||
#
|
||||
|
||||
CCVERSION := $(shell $(CC) -v 2>&1 | sed -ne '$$p')
|
||||
obj-y := kdb_io.o kdb_main.o kdb_support.o kdb_bt.o gen-kdb_cmds.o kdb_bp.o kdb_debugger.o
|
||||
obj-$(CONFIG_KDB_KEYBOARD) += kdb_keyboard.o
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ poll_again:
|
|||
char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt)
|
||||
{
|
||||
if (prompt && kdb_prompt_str != prompt)
|
||||
strncpy(kdb_prompt_str, prompt, CMD_BUFLEN);
|
||||
strscpy(kdb_prompt_str, prompt, CMD_BUFLEN);
|
||||
kdb_printf(kdb_prompt_str);
|
||||
kdb_nextline = 1; /* Prompt and input resets line number */
|
||||
return kdb_read(buffer, bufsize);
|
||||
|
|
|
@ -2522,7 +2522,6 @@ static int kdb_summary(int argc, const char **argv)
|
|||
kdb_printf("machine %s\n", init_uts_ns.name.machine);
|
||||
kdb_printf("nodename %s\n", init_uts_ns.name.nodename);
|
||||
kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
|
||||
kdb_printf("ccversion %s\n", __stringify(CCVERSION));
|
||||
|
||||
now = __ktime_get_real_seconds();
|
||||
time64_to_tm(now, 0, &tm);
|
||||
|
@ -2584,7 +2583,7 @@ static int kdb_per_cpu(int argc, const char **argv)
|
|||
diag = kdbgetularg(argv[3], &whichcpu);
|
||||
if (diag)
|
||||
return diag;
|
||||
if (!cpu_online(whichcpu)) {
|
||||
if (whichcpu >= nr_cpu_ids || !cpu_online(whichcpu)) {
|
||||
kdb_printf("cpu %ld is not online\n", whichcpu);
|
||||
return KDB_BADCPUNUM;
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ int kallsyms_symbol_complete(char *prefix_name, int max_len)
|
|||
|
||||
while ((name = kdb_walk_kallsyms(&pos))) {
|
||||
if (strncmp(name, prefix_name, prefix_len) == 0) {
|
||||
strcpy(ks_namebuf, name);
|
||||
strscpy(ks_namebuf, name, sizeof(ks_namebuf));
|
||||
/* Work out the longest name that matches the prefix */
|
||||
if (++number == 1) {
|
||||
prev_len = min_t(int, max_len-1,
|
||||
|
|
Loading…
Reference in New Issue