Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'kgdb-fixes-4.20-rc3' of https://git.linaro.org/people/daniel.thompson/linux

Pull kgdb fixes from Daniel Thompson:
"The most important changes here are two fixes for kdb regressions
causes by the hashing of %p pointers together with a fix for a
potential overflow in kdb tab completion handling (and warning fix).

Also included are a set of changes in preparation to (eventually)
enable -Wimplicit-fallthrough"

* tag 'kgdb-fixes-4.20-rc3' of https://git.linaro.org/people/daniel.thompson/linux:
kdb: kdb_support: mark expected switch fall-throughs
kdb: kdb_keyboard: mark expected switch fall-throughs
kdb: kdb_main: refactor code in kdb_md_line
kdb: Use strscpy with destination buffer size
kdb: print real address of pointers instead of hashed addresses
kdb: use correct pointer when 'btc' calls 'btt'

+38 -50
+2 -2
kernel/debug/kdb/kdb_bt.c
··· 179 179 kdb_printf("no process for cpu %ld\n", cpu); 180 180 return 0; 181 181 } 182 - sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu)); 182 + sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu)); 183 183 kdb_parse(buf); 184 184 return 0; 185 185 } 186 186 kdb_printf("btc: cpu status: "); 187 187 kdb_parse("cpu\n"); 188 188 for_each_online_cpu(cpu) { 189 - sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu)); 189 + sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu)); 190 190 kdb_parse(buf); 191 191 touch_nmi_watchdog(); 192 192 }
+9 -6
kernel/debug/kdb/kdb_io.c
··· 216 216 int count; 217 217 int i; 218 218 int diag, dtab_count; 219 - int key; 219 + int key, buf_size, ret; 220 220 221 221 222 222 diag = kdbgetintenv("DTABCOUNT", &dtab_count); ··· 336 336 else 337 337 p_tmp = tmpbuffer; 338 338 len = strlen(p_tmp); 339 - count = kallsyms_symbol_complete(p_tmp, 340 - sizeof(tmpbuffer) - 341 - (p_tmp - tmpbuffer)); 339 + buf_size = sizeof(tmpbuffer) - (p_tmp - tmpbuffer); 340 + count = kallsyms_symbol_complete(p_tmp, buf_size); 342 341 if (tab == 2 && count > 0) { 343 342 kdb_printf("\n%d symbols are found.", count); 344 343 if (count > dtab_count) { ··· 349 350 } 350 351 kdb_printf("\n"); 351 352 for (i = 0; i < count; i++) { 352 - if (WARN_ON(!kallsyms_symbol_next(p_tmp, i))) 353 + ret = kallsyms_symbol_next(p_tmp, i, buf_size); 354 + if (WARN_ON(!ret)) 353 355 break; 354 - kdb_printf("%s ", p_tmp); 356 + if (ret != -E2BIG) 357 + kdb_printf("%s ", p_tmp); 358 + else 359 + kdb_printf("%s... ", p_tmp); 355 360 *(p_tmp + len) = '\0'; 356 361 } 357 362 if (i >= dtab_count)
+2 -2
kernel/debug/kdb/kdb_keyboard.c
··· 173 173 case KT_LATIN: 174 174 if (isprint(keychar)) 175 175 break; /* printable characters */ 176 - /* drop through */ 176 + /* fall through */ 177 177 case KT_SPEC: 178 178 if (keychar == K_ENTER) 179 179 break; 180 - /* drop through */ 180 + /* fall through */ 181 181 default: 182 182 return -1; /* ignore unprintables */ 183 183 }
+10 -25
kernel/debug/kdb/kdb_main.c
··· 1192 1192 if (reason == KDB_REASON_DEBUG) { 1193 1193 /* special case below */ 1194 1194 } else { 1195 - kdb_printf("\nEntering kdb (current=0x%p, pid %d) ", 1195 + kdb_printf("\nEntering kdb (current=0x%px, pid %d) ", 1196 1196 kdb_current, kdb_current ? kdb_current->pid : 0); 1197 1197 #if defined(CONFIG_SMP) 1198 1198 kdb_printf("on processor %d ", raw_smp_processor_id()); ··· 1208 1208 */ 1209 1209 switch (db_result) { 1210 1210 case KDB_DB_BPT: 1211 - kdb_printf("\nEntering kdb (0x%p, pid %d) ", 1211 + kdb_printf("\nEntering kdb (0x%px, pid %d) ", 1212 1212 kdb_current, kdb_current->pid); 1213 1213 #if defined(CONFIG_SMP) 1214 1214 kdb_printf("on processor %d ", raw_smp_processor_id()); ··· 1493 1493 char cbuf[32]; 1494 1494 char *c = cbuf; 1495 1495 int i; 1496 + int j; 1496 1497 unsigned long word; 1497 1498 1498 1499 memset(cbuf, '\0', sizeof(cbuf)); ··· 1539 1538 wc.word = word; 1540 1539 #define printable_char(c) \ 1541 1540 ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; }) 1542 - switch (bytesperword) { 1543 - case 8: 1541 + for (j = 0; j < bytesperword; j++) 1544 1542 *c++ = printable_char(*cp++); 1545 - *c++ = printable_char(*cp++); 1546 - *c++ = printable_char(*cp++); 1547 - *c++ = printable_char(*cp++); 1548 - addr += 4; 1549 - case 4: 1550 - *c++ = printable_char(*cp++); 1551 - *c++ = printable_char(*cp++); 1552 - addr += 2; 1553 - case 2: 1554 - *c++ = printable_char(*cp++); 1555 - addr++; 1556 - case 1: 1557 - *c++ = printable_char(*cp++); 1558 - addr++; 1559 - break; 1560 - } 1543 + addr += bytesperword; 1561 1544 #undef printable_char 1562 1545 } 1563 1546 } ··· 2033 2048 if (mod->state == MODULE_STATE_UNFORMED) 2034 2049 continue; 2035 2050 2036 - kdb_printf("%-20s%8u 0x%p ", mod->name, 2051 + kdb_printf("%-20s%8u 0x%px ", mod->name, 2037 2052 mod->core_layout.size, (void *)mod); 2038 2053 #ifdef CONFIG_MODULE_UNLOAD 2039 2054 kdb_printf("%4d ", module_refcount(mod)); ··· 2044 2059 kdb_printf(" (Loading)"); 2045 2060 else 2046 2061 kdb_printf(" (Live)"); 2047 - kdb_printf(" 0x%p", mod->core_layout.base); 2062 + kdb_printf(" 0x%px", mod->core_layout.base); 2048 2063 2049 2064 #ifdef CONFIG_MODULE_UNLOAD 2050 2065 { ··· 2326 2341 return; 2327 2342 2328 2343 cpu = kdb_process_cpu(p); 2329 - 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", 2330 2345 (void *)p, p->pid, p->parent->pid, 2331 2346 kdb_task_has_cpu(p), kdb_process_cpu(p), 2332 2347 kdb_task_state_char(p), ··· 2339 2354 } else { 2340 2355 if (KDB_TSK(cpu) != p) 2341 2356 kdb_printf(" Error: does not match running " 2342 - "process table (0x%p)\n", KDB_TSK(cpu)); 2357 + "process table (0x%px)\n", KDB_TSK(cpu)); 2343 2358 } 2344 2359 } 2345 2360 } ··· 2672 2687 for_each_kdbcmd(kp, i) { 2673 2688 if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) { 2674 2689 kdb_printf("Duplicate kdb command registered: " 2675 - "%s, func %p help %s\n", cmd, func, help); 2690 + "%s, func %px help %s\n", cmd, func, help); 2676 2691 return 1; 2677 2692 } 2678 2693 }
+1 -1
kernel/debug/kdb/kdb_private.h
··· 83 83 unsigned long sym_start; 84 84 unsigned long sym_end; 85 85 } kdb_symtab_t; 86 - extern int kallsyms_symbol_next(char *prefix_name, int flag); 86 + extern int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size); 87 87 extern int kallsyms_symbol_complete(char *prefix_name, int max_len); 88 88 89 89 /* Exported Symbols for kernel loadable modules to use. */
+14 -14
kernel/debug/kdb/kdb_support.c
··· 40 40 int kdbgetsymval(const char *symname, kdb_symtab_t *symtab) 41 41 { 42 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 44 symtab); 45 45 memset(symtab, 0, sizeof(*symtab)); 46 46 symtab->sym_start = kallsyms_lookup_name(symname); ··· 88 88 char *knt1 = NULL; 89 89 90 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 92 memset(symtab, 0, sizeof(*symtab)); 93 93 94 94 if (addr < 4096) ··· 149 149 symtab->mod_name = "kernel"; 150 150 if (KDB_DEBUG(AR)) 151 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 153 symtab->sym_start, symtab->mod_name, symtab->sym_name, 154 154 symtab->sym_name); 155 155 ··· 221 221 * Parameters: 222 222 * prefix_name prefix of a symbol name to lookup 223 223 * flag 0 means search from the head, 1 means continue search. 224 + * buf_size maximum length that can be written to prefix_name 225 + * buffer 224 226 * Returns: 225 227 * 1 if a symbol matches the given prefix. 226 228 * 0 if no string found 227 229 */ 228 - int kallsyms_symbol_next(char *prefix_name, int flag) 230 + int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size) 229 231 { 230 232 int prefix_len = strlen(prefix_name); 231 233 static loff_t pos; ··· 237 235 pos = 0; 238 236 239 237 while ((name = kdb_walk_kallsyms(&pos))) { 240 - if (strncmp(name, prefix_name, prefix_len) == 0) { 241 - strncpy(prefix_name, name, strlen(name)+1); 242 - return 1; 243 - } 238 + if (!strncmp(name, prefix_name, prefix_len)) 239 + return strscpy(prefix_name, name, buf_size); 244 240 } 245 241 return 0; 246 242 } ··· 432 432 *word = w8; 433 433 break; 434 434 } 435 - /* drop through */ 435 + /* fall through */ 436 436 default: 437 437 diag = KDB_BADWIDTH; 438 438 kdb_printf("kdb_getphysword: bad width %ld\n", (long) size); ··· 481 481 *word = w8; 482 482 break; 483 483 } 484 - /* drop through */ 484 + /* fall through */ 485 485 default: 486 486 diag = KDB_BADWIDTH; 487 487 kdb_printf("kdb_getword: bad width %ld\n", (long) size); ··· 525 525 diag = kdb_putarea(addr, w8); 526 526 break; 527 527 } 528 - /* drop through */ 528 + /* fall through */ 529 529 default: 530 530 diag = KDB_BADWIDTH; 531 531 kdb_printf("kdb_putword: bad width %ld\n", (long) size); ··· 887 887 __func__, dah_first); 888 888 if (dah_first) { 889 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 891 h_used->size); 892 892 } 893 893 do { 894 894 h_used = (struct debug_alloc_header *) 895 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 897 __func__, h_used, h_used->size, h_used->caller); 898 898 h_free = (struct debug_alloc_header *) 899 899 (debug_alloc_pool + h_free->next); ··· 902 902 ((char *)h_free + dah_overhead + h_free->size); 903 903 if ((char *)h_used - debug_alloc_pool != 904 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 906 __func__, h_used, h_used->size, h_used->caller); 907 907 out: 908 908 spin_unlock(&dap_lock);