|
@@ -12,6 +12,7 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
#include <linux/ctype.h>
|
|
#include <linux/ctype.h>
|
|
|
|
+#include <linux/types.h>
|
|
#include <linux/string.h>
|
|
#include <linux/string.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/kmsg_dump.h>
|
|
#include <linux/kmsg_dump.h>
|
|
@@ -23,6 +24,7 @@
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/atomic.h>
|
|
#include <linux/atomic.h>
|
|
#include <linux/module.h>
|
|
#include <linux/module.h>
|
|
|
|
+#include <linux/moduleparam.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/init.h>
|
|
#include <linux/init.h>
|
|
#include <linux/kallsyms.h>
|
|
#include <linux/kallsyms.h>
|
|
@@ -42,6 +44,12 @@
|
|
#include <linux/slab.h>
|
|
#include <linux/slab.h>
|
|
#include "kdb_private.h"
|
|
#include "kdb_private.h"
|
|
|
|
|
|
|
|
+#undef MODULE_PARAM_PREFIX
|
|
|
|
+#define MODULE_PARAM_PREFIX "kdb."
|
|
|
|
+
|
|
|
|
+static int kdb_cmd_enabled;
|
|
|
|
+module_param_named(cmd_enable, kdb_cmd_enabled, int, 0600);
|
|
|
|
+
|
|
#define GREP_LEN 256
|
|
#define GREP_LEN 256
|
|
char kdb_grep_string[GREP_LEN];
|
|
char kdb_grep_string[GREP_LEN];
|
|
int kdb_grepping_flag;
|
|
int kdb_grepping_flag;
|
|
@@ -121,6 +129,7 @@ static kdbmsg_t kdbmsgs[] = {
|
|
KDBMSG(BADLENGTH, "Invalid length field"),
|
|
KDBMSG(BADLENGTH, "Invalid length field"),
|
|
KDBMSG(NOBP, "No Breakpoint exists"),
|
|
KDBMSG(NOBP, "No Breakpoint exists"),
|
|
KDBMSG(BADADDR, "Invalid address"),
|
|
KDBMSG(BADADDR, "Invalid address"),
|
|
|
|
+ KDBMSG(NOPERM, "Permission denied"),
|
|
};
|
|
};
|
|
#undef KDBMSG
|
|
#undef KDBMSG
|
|
|
|
|
|
@@ -495,6 +504,15 @@ int kdbgetaddrarg(int argc, const char **argv, int *nextarg,
|
|
char *cp;
|
|
char *cp;
|
|
kdb_symtab_t symtab;
|
|
kdb_symtab_t symtab;
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * If the enable flags prohibit both arbitrary memory access
|
|
|
|
+ * and flow control then there are no reasonable grounds to
|
|
|
|
+ * provide symbol lookup.
|
|
|
|
+ */
|
|
|
|
+ if (!kdb_check_flags(KDB_ENABLE_MEM_READ | KDB_ENABLE_FLOW_CTRL,
|
|
|
|
+ kdb_cmd_enabled, false))
|
|
|
|
+ return KDB_NOPERM;
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* Process arguments which follow the following syntax:
|
|
* Process arguments which follow the following syntax:
|
|
*
|
|
*
|
|
@@ -1028,6 +1046,10 @@ int kdb_parse(const char *cmdstr)
|
|
|
|
|
|
if (i < kdb_max_commands) {
|
|
if (i < kdb_max_commands) {
|
|
int result;
|
|
int result;
|
|
|
|
+
|
|
|
|
+ if (!kdb_check_flags(tp->cmd_flags, kdb_cmd_enabled, argc <= 1))
|
|
|
|
+ return KDB_NOPERM;
|
|
|
|
+
|
|
KDB_STATE_SET(CMD);
|
|
KDB_STATE_SET(CMD);
|
|
result = (*tp->cmd_func)(argc-1, (const char **)argv);
|
|
result = (*tp->cmd_func)(argc-1, (const char **)argv);
|
|
if (result && ignore_errors && result > KDB_CMD_GO)
|
|
if (result && ignore_errors && result > KDB_CMD_GO)
|
|
@@ -1939,10 +1961,14 @@ static int kdb_rm(int argc, const char **argv)
|
|
*/
|
|
*/
|
|
static int kdb_sr(int argc, const char **argv)
|
|
static int kdb_sr(int argc, const char **argv)
|
|
{
|
|
{
|
|
|
|
+ bool check_mask =
|
|
|
|
+ !kdb_check_flags(KDB_ENABLE_ALL, kdb_cmd_enabled, false);
|
|
|
|
+
|
|
if (argc != 1)
|
|
if (argc != 1)
|
|
return KDB_ARGCOUNT;
|
|
return KDB_ARGCOUNT;
|
|
|
|
+
|
|
kdb_trap_printk++;
|
|
kdb_trap_printk++;
|
|
- __handle_sysrq(*argv[1], false);
|
|
|
|
|
|
+ __handle_sysrq(*argv[1], check_mask);
|
|
kdb_trap_printk--;
|
|
kdb_trap_printk--;
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -2393,6 +2419,8 @@ static int kdb_help(int argc, const char **argv)
|
|
return 0;
|
|
return 0;
|
|
if (!kt->cmd_name)
|
|
if (!kt->cmd_name)
|
|
continue;
|
|
continue;
|
|
|
|
+ if (!kdb_check_flags(kt->cmd_flags, kdb_cmd_enabled, true))
|
|
|
|
+ continue;
|
|
if (strlen(kt->cmd_usage) > 20)
|
|
if (strlen(kt->cmd_usage) > 20)
|
|
space = "\n ";
|
|
space = "\n ";
|
|
kdb_printf("%-15.15s %-20s%s%s\n", kt->cmd_name,
|
|
kdb_printf("%-15.15s %-20s%s%s\n", kt->cmd_name,
|