Commit a37372f6 authored by Jason Wessel's avatar Jason Wessel

kdb: Prevent kernel oops with kdb_defcmd

The kdb_defcmd can only be used to display the available command aliases
while using the kernel debug shell.  If you try to define a new macro
while the kernel debugger is active it will oops.  The debug shell
macros must use pre-allocated memory set aside at the time kdb_init()
is run, and the kdb_defcmd is restricted to only working at the time
that the kdb_init sequence is being run, which only occurs if you
actually activate the kernel debugger.
Signed-off-by: default avatarJason Wessel <jason.wessel@windriver.com>
parent 1b2caa2d
...@@ -681,6 +681,10 @@ static int kdb_defcmd(int argc, const char **argv) ...@@ -681,6 +681,10 @@ static int kdb_defcmd(int argc, const char **argv)
} }
if (argc != 3) if (argc != 3)
return KDB_ARGCOUNT; return KDB_ARGCOUNT;
if (in_dbg_master()) {
kdb_printf("Command only available during kdb_init()\n");
return KDB_NOTIMP;
}
defcmd_set = kmalloc((defcmd_set_count + 1) * sizeof(*defcmd_set), defcmd_set = kmalloc((defcmd_set_count + 1) * sizeof(*defcmd_set),
GFP_KDB); GFP_KDB);
if (!defcmd_set) if (!defcmd_set)
...@@ -2796,8 +2800,8 @@ static void __init kdb_inittab(void) ...@@ -2796,8 +2800,8 @@ static void __init kdb_inittab(void)
"Stack traceback", 1, KDB_REPEAT_NONE); "Stack traceback", 1, KDB_REPEAT_NONE);
kdb_register_repeat("btp", kdb_bt, "<pid>", kdb_register_repeat("btp", kdb_bt, "<pid>",
"Display stack for process <pid>", 0, KDB_REPEAT_NONE); "Display stack for process <pid>", 0, KDB_REPEAT_NONE);
kdb_register_repeat("bta", kdb_bt, "[DRSTCZEUIMA]", kdb_register_repeat("bta", kdb_bt, "[D|R|S|T|C|Z|E|U|I|M|A]",
"Display stack all processes", 0, KDB_REPEAT_NONE); "Backtrace all processes matching state flag", 0, KDB_REPEAT_NONE);
kdb_register_repeat("btc", kdb_bt, "", kdb_register_repeat("btc", kdb_bt, "",
"Backtrace current process on each cpu", 0, KDB_REPEAT_NONE); "Backtrace current process on each cpu", 0, KDB_REPEAT_NONE);
kdb_register_repeat("btt", kdb_bt, "<vaddr>", kdb_register_repeat("btt", kdb_bt, "<vaddr>",
......
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