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()
Unified · Split
| @@ -398,6 +398,13 @@ int kdb_set(int argc, const char **argv) · 397 unmodified lines | ||
| 398 | 398 | if (argc != 2) |
| 399 | 399 | return KDB_ARGCOUNT; |
| 400 | 400 | |
| 401 | + /* | |
| 402 | + * Censor sensitive variables | |
| 403 | + */ | |
| 404 | + if (strcmp(argv[1], "PROMPT") == 0 && | |
| 405 | + !kdb_check_flags(KDB_ENABLE_MEM_READ, kdb_cmd_enabled, false)) | |
| 406 | + return KDB_NOPERM; | |
| 407 | + | |
| 401 | 408 | /* |
| 402 | 409 | * Check for internal variables |
| 403 | 410 | */ |
| @@ -1102,12 +1109,12 @@ static int handle_ctrl_cmd(char *cmd) · 698 unmodified lines | ||
| 1102 | 1109 | case CTRL_P: |
| 1103 | 1110 | if (cmdptr != cmd_tail) |
| 1104 | 1111 | cmdptr = (cmdptr-1) % KDB_CMD_HISTORY_COUNT; |
| 1105 | − strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); | |
| 1112 | + strscpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); | |
| 1106 | 1113 | return 1; |
| 1107 | 1114 | case CTRL_N: |
| 1108 | 1115 | if (cmdptr != cmd_head) |
| 1109 | 1116 | cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT; |
| 1110 | − strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); | |
| 1117 | + strscpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN); | |
| 1111 | 1118 | return 1; |
| 1112 | 1119 | } |
| 1113 | 1120 | return 0; |
| @@ -1298,12 +1305,9 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, · 184 unmodified lines | ||
| 1298 | 1305 | *(cmd_hist[cmd_head]) = '\0'; |
| 1299 | 1306 | |
| 1300 | 1307 | do_full_getstr: |
| 1301 | −#if defined(CONFIG_SMP) | |
| 1308 | + /* PROMPT can only be set if we have MEM_READ permission. */ | |
| 1302 | 1309 | snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"), |
| 1303 | 1310 | raw_smp_processor_id()); |
| 1304 | −#else | |
| 1305 | − snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT")); | |
| 1306 | −#endif | |
| 1307 | 1311 | if (defcmd_in_progress) |
| 1308 | 1312 | strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN); |
| 1309 | 1313 | |
| @@ -1314,7 +1318,7 @@ do_full_getstr: · 4 unmodified lines | ||
| 1314 | 1318 | if (*cmdbuf != '\n') { |
| 1315 | 1319 | if (*cmdbuf < 32) { |
| 1316 | 1320 | if (cmdptr == cmd_head) { |
| 1317 | − strncpy(cmd_hist[cmd_head], cmd_cur, | |
| 1321 | + strscpy(cmd_hist[cmd_head], cmd_cur, | |
| 1318 | 1322 | CMD_BUFLEN); |
| 1319 | 1323 | *(cmd_hist[cmd_head] + |
| 1320 | 1324 | strlen(cmd_hist[cmd_head])-1) = '\0'; |
| @@ -1324,7 +1328,7 @@ do_full_getstr: · 3 unmodified lines | ||
| 1324 | 1328 | cmdbuf = cmd_cur; |
| 1325 | 1329 | goto do_full_getstr; |
| 1326 | 1330 | } else { |
| 1327 | − strncpy(cmd_hist[cmd_head], cmd_cur, | |
| 1331 | + strscpy(cmd_hist[cmd_head], cmd_cur, | |
| 1328 | 1332 | CMD_BUFLEN); |
| 1329 | 1333 | } |
| 1330 | 1334 | |