aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/debug
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@c-s.fr>2018-09-27 13:17:57 -0400
committerDaniel Thompson <daniel.thompson@linaro.org>2018-11-13 15:27:37 -0500
commit568fb6f42ac6851320adaea25f8f1b94de14e40a (patch)
tree07c1ab9d9004257d7d0afcbac83a7581221cf841 /kernel/debug
parentdded2e159208a9edc21dd5c5f583afa28d378d39 (diff)
kdb: print real address of pointers instead of hashed addresses
Since commit ad67b74d2469 ("printk: hash addresses printed with %p"), all pointers printed with %p are printed with hashed addresses instead of real addresses in order to avoid leaking addresses in dmesg and syslog. But this applies to kdb too, with is unfortunate: Entering kdb (current=0x(ptrval), pid 329) due to Keyboard Entry kdb> ps 15 sleeping system daemon (state M) processes suppressed, use 'ps A' to see all. Task Addr Pid Parent [*] cpu State Thread Command 0x(ptrval) 329 328 1 0 R 0x(ptrval) *sh 0x(ptrval) 1 0 0 0 S 0x(ptrval) init 0x(ptrval) 3 2 0 0 D 0x(ptrval) rcu_gp 0x(ptrval) 4 2 0 0 D 0x(ptrval) rcu_par_gp 0x(ptrval) 5 2 0 0 D 0x(ptrval) kworker/0:0 0x(ptrval) 6 2 0 0 D 0x(ptrval) kworker/0:0H 0x(ptrval) 7 2 0 0 D 0x(ptrval) kworker/u2:0 0x(ptrval) 8 2 0 0 D 0x(ptrval) mm_percpu_wq 0x(ptrval) 10 2 0 0 D 0x(ptrval) rcu_preempt The whole purpose of kdb is to debug, and for debugging real addresses need to be known. In addition, data displayed by kdb doesn't go into dmesg. This patch replaces all %p by %px in kdb in order to display real addresses. Fixes: ad67b74d2469 ("printk: hash addresses printed with %p") Cc: <stable@vger.kernel.org> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Diffstat (limited to 'kernel/debug')
-rw-r--r--kernel/debug/kdb/kdb_main.c14
-rw-r--r--kernel/debug/kdb/kdb_support.c12
2 files changed, 13 insertions, 13 deletions
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index bb4fe4e1a601..959242084b40 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -1192,7 +1192,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
1192 if (reason == KDB_REASON_DEBUG) { 1192 if (reason == KDB_REASON_DEBUG) {
1193 /* special case below */ 1193 /* special case below */
1194 } else { 1194 } else {
1195 kdb_printf("\nEntering kdb (current=0x%p, pid %d) ", 1195 kdb_printf("\nEntering kdb (current=0x%px, pid %d) ",
1196 kdb_current, kdb_current ? kdb_current->pid : 0); 1196 kdb_current, kdb_current ? kdb_current->pid : 0);
1197#if defined(CONFIG_SMP) 1197#if defined(CONFIG_SMP)
1198 kdb_printf("on processor %d ", raw_smp_processor_id()); 1198 kdb_printf("on processor %d ", raw_smp_processor_id());
@@ -1208,7 +1208,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
1208 */ 1208 */
1209 switch (db_result) { 1209 switch (db_result) {
1210 case KDB_DB_BPT: 1210 case KDB_DB_BPT:
1211 kdb_printf("\nEntering kdb (0x%p, pid %d) ", 1211 kdb_printf("\nEntering kdb (0x%px, pid %d) ",
1212 kdb_current, kdb_current->pid); 1212 kdb_current, kdb_current->pid);
1213#if defined(CONFIG_SMP) 1213#if defined(CONFIG_SMP)
1214 kdb_printf("on processor %d ", raw_smp_processor_id()); 1214 kdb_printf("on processor %d ", raw_smp_processor_id());
@@ -2048,7 +2048,7 @@ static int kdb_lsmod(int argc, const char **argv)
2048 if (mod->state == MODULE_STATE_UNFORMED) 2048 if (mod->state == MODULE_STATE_UNFORMED)
2049 continue; 2049 continue;
2050 2050
2051 kdb_printf("%-20s%8u 0x%p ", mod->name, 2051 kdb_printf("%-20s%8u 0x%px ", mod->name,
2052 mod->core_layout.size, (void *)mod); 2052 mod->core_layout.size, (void *)mod);
2053#ifdef CONFIG_MODULE_UNLOAD 2053#ifdef CONFIG_MODULE_UNLOAD
2054 kdb_printf("%4d ", module_refcount(mod)); 2054 kdb_printf("%4d ", module_refcount(mod));
@@ -2059,7 +2059,7 @@ static int kdb_lsmod(int argc, const char **argv)
2059 kdb_printf(" (Loading)"); 2059 kdb_printf(" (Loading)");
2060 else 2060 else
2061 kdb_printf(" (Live)"); 2061 kdb_printf(" (Live)");
2062 kdb_printf(" 0x%p", mod->core_layout.base); 2062 kdb_printf(" 0x%px", mod->core_layout.base);
2063 2063
2064#ifdef CONFIG_MODULE_UNLOAD 2064#ifdef CONFIG_MODULE_UNLOAD
2065 { 2065 {
@@ -2341,7 +2341,7 @@ void kdb_ps1(const struct task_struct *p)
2341 return; 2341 return;
2342 2342
2343 cpu = kdb_process_cpu(p); 2343 cpu = kdb_process_cpu(p);
2344 kdb_printf("0x%p %8d %8d %d %4d %c 0x%p %c%s\n", 2344 kdb_printf("0x%px %8d %8d %d %4d %c 0x%px %c%s\n",
2345 (void *)p, p->pid, p->parent->pid, 2345 (void *)p, p->pid, p->parent->pid,
2346 kdb_task_has_cpu(p), kdb_process_cpu(p), 2346 kdb_task_has_cpu(p), kdb_process_cpu(p),
2347 kdb_task_state_char(p), 2347 kdb_task_state_char(p),
@@ -2354,7 +2354,7 @@ void kdb_ps1(const struct task_struct *p)
2354 } else { 2354 } else {
2355 if (KDB_TSK(cpu) != p) 2355 if (KDB_TSK(cpu) != p)
2356 kdb_printf(" Error: does not match running " 2356 kdb_printf(" Error: does not match running "
2357 "process table (0x%p)\n", KDB_TSK(cpu)); 2357 "process table (0x%px)\n", KDB_TSK(cpu));
2358 } 2358 }
2359 } 2359 }
2360} 2360}
@@ -2687,7 +2687,7 @@ int kdb_register_flags(char *cmd,
2687 for_each_kdbcmd(kp, i) { 2687 for_each_kdbcmd(kp, i) {
2688 if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) { 2688 if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) {
2689 kdb_printf("Duplicate kdb command registered: " 2689 kdb_printf("Duplicate kdb command registered: "
2690 "%s, func %p help %s\n", cmd, func, help); 2690 "%s, func %px help %s\n", cmd, func, help);
2691 return 1; 2691 return 1;
2692 } 2692 }
2693 } 2693 }
diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c
index 990b3cc526c8..987eb73284d2 100644
--- a/kernel/debug/kdb/kdb_support.c
+++ b/kernel/debug/kdb/kdb_support.c
@@ -40,7 +40,7 @@
40int kdbgetsymval(const char *symname, kdb_symtab_t *symtab) 40int kdbgetsymval(const char *symname, kdb_symtab_t *symtab)
41{ 41{
42 if (KDB_DEBUG(AR)) 42 if (KDB_DEBUG(AR))
43 kdb_printf("kdbgetsymval: symname=%s, symtab=%p\n", symname, 43 kdb_printf("kdbgetsymval: symname=%s, symtab=%px\n", symname,
44 symtab); 44 symtab);
45 memset(symtab, 0, sizeof(*symtab)); 45 memset(symtab, 0, sizeof(*symtab));
46 symtab->sym_start = kallsyms_lookup_name(symname); 46 symtab->sym_start = kallsyms_lookup_name(symname);
@@ -88,7 +88,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
88 char *knt1 = NULL; 88 char *knt1 = NULL;
89 89
90 if (KDB_DEBUG(AR)) 90 if (KDB_DEBUG(AR))
91 kdb_printf("kdbnearsym: addr=0x%lx, symtab=%p\n", addr, symtab); 91 kdb_printf("kdbnearsym: addr=0x%lx, symtab=%px\n", addr, symtab);
92 memset(symtab, 0, sizeof(*symtab)); 92 memset(symtab, 0, sizeof(*symtab));
93 93
94 if (addr < 4096) 94 if (addr < 4096)
@@ -149,7 +149,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
149 symtab->mod_name = "kernel"; 149 symtab->mod_name = "kernel";
150 if (KDB_DEBUG(AR)) 150 if (KDB_DEBUG(AR))
151 kdb_printf("kdbnearsym: returns %d symtab->sym_start=0x%lx, " 151 kdb_printf("kdbnearsym: returns %d symtab->sym_start=0x%lx, "
152 "symtab->mod_name=%p, symtab->sym_name=%p (%s)\n", ret, 152 "symtab->mod_name=%px, symtab->sym_name=%px (%s)\n", ret,
153 symtab->sym_start, symtab->mod_name, symtab->sym_name, 153 symtab->sym_start, symtab->mod_name, symtab->sym_name,
154 symtab->sym_name); 154 symtab->sym_name);
155 155
@@ -887,13 +887,13 @@ void debug_kusage(void)
887 __func__, dah_first); 887 __func__, dah_first);
888 if (dah_first) { 888 if (dah_first) {
889 h_used = (struct debug_alloc_header *)debug_alloc_pool; 889 h_used = (struct debug_alloc_header *)debug_alloc_pool;
890 kdb_printf("%s: h_used %p size %d\n", __func__, h_used, 890 kdb_printf("%s: h_used %px size %d\n", __func__, h_used,
891 h_used->size); 891 h_used->size);
892 } 892 }
893 do { 893 do {
894 h_used = (struct debug_alloc_header *) 894 h_used = (struct debug_alloc_header *)
895 ((char *)h_free + dah_overhead + h_free->size); 895 ((char *)h_free + dah_overhead + h_free->size);
896 kdb_printf("%s: h_used %p size %d caller %p\n", 896 kdb_printf("%s: h_used %px size %d caller %px\n",
897 __func__, h_used, h_used->size, h_used->caller); 897 __func__, h_used, h_used->size, h_used->caller);
898 h_free = (struct debug_alloc_header *) 898 h_free = (struct debug_alloc_header *)
899 (debug_alloc_pool + h_free->next); 899 (debug_alloc_pool + h_free->next);
@@ -902,7 +902,7 @@ void debug_kusage(void)
902 ((char *)h_free + dah_overhead + h_free->size); 902 ((char *)h_free + dah_overhead + h_free->size);
903 if ((char *)h_used - debug_alloc_pool != 903 if ((char *)h_used - debug_alloc_pool !=
904 sizeof(debug_alloc_pool_aligned)) 904 sizeof(debug_alloc_pool_aligned))
905 kdb_printf("%s: h_used %p size %d caller %p\n", 905 kdb_printf("%s: h_used %px size %d caller %px\n",
906 __func__, h_used, h_used->size, h_used->caller); 906 __func__, h_used, h_used->size, h_used->caller);
907out: 907out:
908 spin_unlock(&dap_lock); 908 spin_unlock(&dap_lock);