aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/debug
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2013-02-04 11:35:33 -0500
committerJason Wessel <jason.wessel@windriver.com>2013-03-02 09:52:19 -0500
commita37372f6c3c03dc7613eaae8bb3458c8068f5fff (patch)
treecf64786123ce7c2d47002d1d6b122967abca0eb5 /kernel/debug
parent1b2caa2dcb8f18d2be9c5c3c992cb6da03f1a70a (diff)
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: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'kernel/debug')
-rw-r--r--kernel/debug/kdb/kdb_main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index cdfc0a7e583e..496f596aa807 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -681,6 +681,10 @@ static int kdb_defcmd(int argc, const char **argv)
681 } 681 }
682 if (argc != 3) 682 if (argc != 3)
683 return KDB_ARGCOUNT; 683 return KDB_ARGCOUNT;
684 if (in_dbg_master()) {
685 kdb_printf("Command only available during kdb_init()\n");
686 return KDB_NOTIMP;
687 }
684 defcmd_set = kmalloc((defcmd_set_count + 1) * sizeof(*defcmd_set), 688 defcmd_set = kmalloc((defcmd_set_count + 1) * sizeof(*defcmd_set),
685 GFP_KDB); 689 GFP_KDB);
686 if (!defcmd_set) 690 if (!defcmd_set)
@@ -2796,8 +2800,8 @@ static void __init kdb_inittab(void)
2796 "Stack traceback", 1, KDB_REPEAT_NONE); 2800 "Stack traceback", 1, KDB_REPEAT_NONE);
2797 kdb_register_repeat("btp", kdb_bt, "<pid>", 2801 kdb_register_repeat("btp", kdb_bt, "<pid>",
2798 "Display stack for process <pid>", 0, KDB_REPEAT_NONE); 2802 "Display stack for process <pid>", 0, KDB_REPEAT_NONE);
2799 kdb_register_repeat("bta", kdb_bt, "[DRSTCZEUIMA]", 2803 kdb_register_repeat("bta", kdb_bt, "[D|R|S|T|C|Z|E|U|I|M|A]",
2800 "Display stack all processes", 0, KDB_REPEAT_NONE); 2804 "Backtrace all processes matching state flag", 0, KDB_REPEAT_NONE);
2801 kdb_register_repeat("btc", kdb_bt, "", 2805 kdb_register_repeat("btc", kdb_bt, "",
2802 "Backtrace current process on each cpu", 0, KDB_REPEAT_NONE); 2806 "Backtrace current process on each cpu", 0, KDB_REPEAT_NONE);
2803 kdb_register_repeat("btt", kdb_bt, "<vaddr>", 2807 kdb_register_repeat("btt", kdb_bt, "<vaddr>",