Commit f2c3bec3 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'kgdb-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux

Pull kgdb updates from Daniel Thompson:
 "Pretty quiet this cycle. Just a couple of small fixes from myself both
  of which were reviewed by Doug Anderson to keep me honest (thanks)"

* tag 'kgdb-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux:
  kdb: Censor attempts to set PROMPT without ENABLE_MEM_READ
  kdb: Eliminate strncpy() warnings by replacing with strscpy()
parents a943353d ad99b510
...@@ -398,6 +398,13 @@ int kdb_set(int argc, const char **argv) ...@@ -398,6 +398,13 @@ int kdb_set(int argc, const char **argv)
if (argc != 2) if (argc != 2)
return KDB_ARGCOUNT; return KDB_ARGCOUNT;
/*
* Censor sensitive variables
*/
if (strcmp(argv[1], "PROMPT") == 0 &&
!kdb_check_flags(KDB_ENABLE_MEM_READ, kdb_cmd_enabled, false))
return KDB_NOPERM;
/* /*
* Check for internal variables * Check for internal variables
*/ */
...@@ -1102,12 +1109,12 @@ static int handle_ctrl_cmd(char *cmd) ...@@ -1102,12 +1109,12 @@ static int handle_ctrl_cmd(char *cmd)
case CTRL_P: case CTRL_P:
if (cmdptr != cmd_tail) if (cmdptr != cmd_tail)
cmdptr = (cmdptr-1) % KDB_CMD_HISTORY_COUNT; cmdptr = (cmdptr-1) % KDB_CMD_HISTORY_COUNT;
strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); strscpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
return 1; return 1;
case CTRL_N: case CTRL_N:
if (cmdptr != cmd_head) if (cmdptr != cmd_head)
cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT; cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT;
strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); strscpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
return 1; return 1;
} }
return 0; return 0;
...@@ -1298,12 +1305,9 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, ...@@ -1298,12 +1305,9 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
*(cmd_hist[cmd_head]) = '\0'; *(cmd_hist[cmd_head]) = '\0';
do_full_getstr: do_full_getstr:
#if defined(CONFIG_SMP) /* PROMPT can only be set if we have MEM_READ permission. */
snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"), snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"),
raw_smp_processor_id()); raw_smp_processor_id());
#else
snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"));
#endif
if (defcmd_in_progress) if (defcmd_in_progress)
strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN); strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN);
...@@ -1314,7 +1318,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, ...@@ -1314,7 +1318,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
if (*cmdbuf != '\n') { if (*cmdbuf != '\n') {
if (*cmdbuf < 32) { if (*cmdbuf < 32) {
if (cmdptr == cmd_head) { if (cmdptr == cmd_head) {
strncpy(cmd_hist[cmd_head], cmd_cur, strscpy(cmd_hist[cmd_head], cmd_cur,
CMD_BUFLEN); CMD_BUFLEN);
*(cmd_hist[cmd_head] + *(cmd_hist[cmd_head] +
strlen(cmd_hist[cmd_head])-1) = '\0'; strlen(cmd_hist[cmd_head])-1) = '\0';
...@@ -1324,7 +1328,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, ...@@ -1324,7 +1328,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
cmdbuf = cmd_cur; cmdbuf = cmd_cur;
goto do_full_getstr; goto do_full_getstr;
} else { } else {
strncpy(cmd_hist[cmd_head], cmd_cur, strscpy(cmd_hist[cmd_head], cmd_cur,
CMD_BUFLEN); CMD_BUFLEN);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment