History

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()

Linus Torvalds committed 6 years ago

Commit f2c3bec2 parents a943353 ad99b511 file · +12 −8Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/debug/kdb/kdb_main.c+12−8
@@ -398,6 +398,13 @@ int kdb_set(int argc, const char **argv) · 397 unmodified lines
398398 if (argc != 2)
399399 return KDB_ARGCOUNT;
400400
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+
401408 /*
402409 * Check for internal variables
403410 */
@@ -1102,12 +1109,12 @@ static int handle_ctrl_cmd(char *cmd) · 698 unmodified lines
11021109 case CTRL_P:
11031110 if (cmdptr != cmd_tail)
11041111 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);
11061113 return 1;
11071114 case CTRL_N:
11081115 if (cmdptr != cmd_head)
11091116 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);
11111118 return 1;
11121119 }
11131120 return 0;
@@ -1298,12 +1305,9 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, · 184 unmodified lines
12981305 *(cmd_hist[cmd_head]) = '\0';
12991306
13001307 do_full_getstr:
1301−#if defined(CONFIG_SMP)
1308+ /* PROMPT can only be set if we have MEM_READ permission. */
13021309 snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"),
13031310 raw_smp_processor_id());
1304−#else
1305− snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"));
1306−#endif
13071311 if (defcmd_in_progress)
13081312 strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN);
13091313
@@ -1314,7 +1318,7 @@ do_full_getstr: · 4 unmodified lines
13141318 if (*cmdbuf != '\n') {
13151319 if (*cmdbuf < 32) {
13161320 if (cmdptr == cmd_head) {
1317− strncpy(cmd_hist[cmd_head], cmd_cur,
1321+ strscpy(cmd_hist[cmd_head], cmd_cur,
13181322 CMD_BUFLEN);
13191323 *(cmd_hist[cmd_head] +
13201324 strlen(cmd_hist[cmd_head])-1) = '\0';
@@ -1324,7 +1328,7 @@ do_full_getstr: · 3 unmodified lines
13241328 cmdbuf = cmd_cur;
13251329 goto do_full_getstr;
13261330 } else {
1327− strncpy(cmd_hist[cmd_head], cmd_cur,
1331+ strscpy(cmd_hist[cmd_head], cmd_cur,
13281332 CMD_BUFLEN);
13291333 }
13301334

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t