diff options
Diffstat (limited to 'drivers/misc/lkdtm.c')
| -rw-r--r-- | drivers/misc/lkdtm.c | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c index 343b5d8ea697..81d7fa4ec0db 100644 --- a/drivers/misc/lkdtm.c +++ b/drivers/misc/lkdtm.c | |||
| @@ -52,32 +52,32 @@ | |||
| 52 | #define REC_NUM_DEFAULT 10 | 52 | #define REC_NUM_DEFAULT 10 |
| 53 | 53 | ||
| 54 | enum cname { | 54 | enum cname { |
| 55 | INVALID, | 55 | CN_INVALID, |
| 56 | INT_HARDWARE_ENTRY, | 56 | CN_INT_HARDWARE_ENTRY, |
| 57 | INT_HW_IRQ_EN, | 57 | CN_INT_HW_IRQ_EN, |
| 58 | INT_TASKLET_ENTRY, | 58 | CN_INT_TASKLET_ENTRY, |
| 59 | FS_DEVRW, | 59 | CN_FS_DEVRW, |
| 60 | MEM_SWAPOUT, | 60 | CN_MEM_SWAPOUT, |
| 61 | TIMERADD, | 61 | CN_TIMERADD, |
| 62 | SCSI_DISPATCH_CMD, | 62 | CN_SCSI_DISPATCH_CMD, |
| 63 | IDE_CORE_CP, | 63 | CN_IDE_CORE_CP, |
| 64 | DIRECT, | 64 | CN_DIRECT, |
| 65 | }; | 65 | }; |
| 66 | 66 | ||
| 67 | enum ctype { | 67 | enum ctype { |
| 68 | NONE, | 68 | CT_NONE, |
| 69 | PANIC, | 69 | CT_PANIC, |
| 70 | BUG, | 70 | CT_BUG, |
| 71 | EXCEPTION, | 71 | CT_EXCEPTION, |
| 72 | LOOP, | 72 | CT_LOOP, |
| 73 | OVERFLOW, | 73 | CT_OVERFLOW, |
| 74 | CORRUPT_STACK, | 74 | CT_CORRUPT_STACK, |
| 75 | UNALIGNED_LOAD_STORE_WRITE, | 75 | CT_UNALIGNED_LOAD_STORE_WRITE, |
| 76 | OVERWRITE_ALLOCATION, | 76 | CT_OVERWRITE_ALLOCATION, |
| 77 | WRITE_AFTER_FREE, | 77 | CT_WRITE_AFTER_FREE, |
| 78 | SOFTLOCKUP, | 78 | CT_SOFTLOCKUP, |
| 79 | HARDLOCKUP, | 79 | CT_HARDLOCKUP, |
| 80 | HUNG_TASK, | 80 | CT_HUNG_TASK, |
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | static char* cp_name[] = { | 83 | static char* cp_name[] = { |
| @@ -117,8 +117,8 @@ static char* cpoint_type; | |||
| 117 | static int cpoint_count = DEFAULT_COUNT; | 117 | static int cpoint_count = DEFAULT_COUNT; |
| 118 | static int recur_count = REC_NUM_DEFAULT; | 118 | static int recur_count = REC_NUM_DEFAULT; |
| 119 | 119 | ||
| 120 | static enum cname cpoint = INVALID; | 120 | static enum cname cpoint = CN_INVALID; |
| 121 | static enum ctype cptype = NONE; | 121 | static enum ctype cptype = CT_NONE; |
| 122 | static int count = DEFAULT_COUNT; | 122 | static int count = DEFAULT_COUNT; |
| 123 | 123 | ||
| 124 | module_param(recur_count, int, 0644); | 124 | module_param(recur_count, int, 0644); |
| @@ -207,12 +207,12 @@ static enum ctype parse_cp_type(const char *what, size_t count) | |||
| 207 | return i + 1; | 207 | return i + 1; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | return NONE; | 210 | return CT_NONE; |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | static const char *cp_type_to_str(enum ctype type) | 213 | static const char *cp_type_to_str(enum ctype type) |
| 214 | { | 214 | { |
| 215 | if (type == NONE || type < 0 || type > ARRAY_SIZE(cp_type)) | 215 | if (type == CT_NONE || type < 0 || type > ARRAY_SIZE(cp_type)) |
| 216 | return "None"; | 216 | return "None"; |
| 217 | 217 | ||
| 218 | return cp_type[type - 1]; | 218 | return cp_type[type - 1]; |
| @@ -220,7 +220,7 @@ static const char *cp_type_to_str(enum ctype type) | |||
| 220 | 220 | ||
| 221 | static const char *cp_name_to_str(enum cname name) | 221 | static const char *cp_name_to_str(enum cname name) |
| 222 | { | 222 | { |
| 223 | if (name == INVALID || name < 0 || name > ARRAY_SIZE(cp_name)) | 223 | if (name == CN_INVALID || name < 0 || name > ARRAY_SIZE(cp_name)) |
| 224 | return "INVALID"; | 224 | return "INVALID"; |
| 225 | 225 | ||
| 226 | return cp_name[name - 1]; | 226 | return cp_name[name - 1]; |
| @@ -245,7 +245,7 @@ static int lkdtm_parse_commandline(void) | |||
| 245 | return -EINVAL; | 245 | return -EINVAL; |
| 246 | 246 | ||
| 247 | cptype = parse_cp_type(cpoint_type, strlen(cpoint_type)); | 247 | cptype = parse_cp_type(cpoint_type, strlen(cpoint_type)); |
| 248 | if (cptype == NONE) | 248 | if (cptype == CT_NONE) |
| 249 | return -EINVAL; | 249 | return -EINVAL; |
| 250 | 250 | ||
| 251 | for (i = 0; i < ARRAY_SIZE(cp_name); i++) { | 251 | for (i = 0; i < ARRAY_SIZE(cp_name); i++) { |
| @@ -274,30 +274,30 @@ static int recursive_loop(int a) | |||
| 274 | static void lkdtm_do_action(enum ctype which) | 274 | static void lkdtm_do_action(enum ctype which) |
| 275 | { | 275 | { |
| 276 | switch (which) { | 276 | switch (which) { |
| 277 | case PANIC: | 277 | case CT_PANIC: |
| 278 | panic("dumptest"); | 278 | panic("dumptest"); |
| 279 | break; | 279 | break; |
| 280 | case BUG: | 280 | case CT_BUG: |
| 281 | BUG(); | 281 | BUG(); |
| 282 | break; | 282 | break; |
| 283 | case EXCEPTION: | 283 | case CT_EXCEPTION: |
| 284 | *((int *) 0) = 0; | 284 | *((int *) 0) = 0; |
| 285 | break; | 285 | break; |
| 286 | case LOOP: | 286 | case CT_LOOP: |
| 287 | for (;;) | 287 | for (;;) |
| 288 | ; | 288 | ; |
| 289 | break; | 289 | break; |
| 290 | case OVERFLOW: | 290 | case CT_OVERFLOW: |
| 291 | (void) recursive_loop(0); | 291 | (void) recursive_loop(0); |
| 292 | break; | 292 | break; |
| 293 | case CORRUPT_STACK: { | 293 | case CT_CORRUPT_STACK: { |
| 294 | volatile u32 data[8]; | 294 | volatile u32 data[8]; |
| 295 | volatile u32 *p = data; | 295 | volatile u32 *p = data; |
| 296 | 296 | ||
| 297 | p[12] = 0x12345678; | 297 | p[12] = 0x12345678; |
| 298 | break; | 298 | break; |
| 299 | } | 299 | } |
| 300 | case UNALIGNED_LOAD_STORE_WRITE: { | 300 | case CT_UNALIGNED_LOAD_STORE_WRITE: { |
| 301 | static u8 data[5] __attribute__((aligned(4))) = {1, 2, | 301 | static u8 data[5] __attribute__((aligned(4))) = {1, 2, |
| 302 | 3, 4, 5}; | 302 | 3, 4, 5}; |
| 303 | u32 *p; | 303 | u32 *p; |
| @@ -309,7 +309,7 @@ static void lkdtm_do_action(enum ctype which) | |||
| 309 | *p = val; | 309 | *p = val; |
| 310 | break; | 310 | break; |
| 311 | } | 311 | } |
| 312 | case OVERWRITE_ALLOCATION: { | 312 | case CT_OVERWRITE_ALLOCATION: { |
| 313 | size_t len = 1020; | 313 | size_t len = 1020; |
| 314 | u32 *data = kmalloc(len, GFP_KERNEL); | 314 | u32 *data = kmalloc(len, GFP_KERNEL); |
| 315 | 315 | ||
| @@ -317,7 +317,7 @@ static void lkdtm_do_action(enum ctype which) | |||
| 317 | kfree(data); | 317 | kfree(data); |
| 318 | break; | 318 | break; |
| 319 | } | 319 | } |
| 320 | case WRITE_AFTER_FREE: { | 320 | case CT_WRITE_AFTER_FREE: { |
| 321 | size_t len = 1024; | 321 | size_t len = 1024; |
| 322 | u32 *data = kmalloc(len, GFP_KERNEL); | 322 | u32 *data = kmalloc(len, GFP_KERNEL); |
| 323 | 323 | ||
| @@ -326,21 +326,21 @@ static void lkdtm_do_action(enum ctype which) | |||
| 326 | memset(data, 0x78, len); | 326 | memset(data, 0x78, len); |
| 327 | break; | 327 | break; |
| 328 | } | 328 | } |
| 329 | case SOFTLOCKUP: | 329 | case CT_SOFTLOCKUP: |
| 330 | preempt_disable(); | 330 | preempt_disable(); |
| 331 | for (;;) | 331 | for (;;) |
| 332 | cpu_relax(); | 332 | cpu_relax(); |
| 333 | break; | 333 | break; |
| 334 | case HARDLOCKUP: | 334 | case CT_HARDLOCKUP: |
| 335 | local_irq_disable(); | 335 | local_irq_disable(); |
| 336 | for (;;) | 336 | for (;;) |
| 337 | cpu_relax(); | 337 | cpu_relax(); |
| 338 | break; | 338 | break; |
| 339 | case HUNG_TASK: | 339 | case CT_HUNG_TASK: |
| 340 | set_current_state(TASK_UNINTERRUPTIBLE); | 340 | set_current_state(TASK_UNINTERRUPTIBLE); |
| 341 | schedule(); | 341 | schedule(); |
| 342 | break; | 342 | break; |
| 343 | case NONE: | 343 | case CT_NONE: |
| 344 | default: | 344 | default: |
| 345 | break; | 345 | break; |
| 346 | } | 346 | } |
| @@ -363,43 +363,43 @@ static int lkdtm_register_cpoint(enum cname which) | |||
| 363 | { | 363 | { |
| 364 | int ret; | 364 | int ret; |
| 365 | 365 | ||
| 366 | cpoint = INVALID; | 366 | cpoint = CN_INVALID; |
| 367 | if (lkdtm.entry != NULL) | 367 | if (lkdtm.entry != NULL) |
| 368 | unregister_jprobe(&lkdtm); | 368 | unregister_jprobe(&lkdtm); |
| 369 | 369 | ||
| 370 | switch (which) { | 370 | switch (which) { |
| 371 | case DIRECT: | 371 | case CN_DIRECT: |
| 372 | lkdtm_do_action(cptype); | 372 | lkdtm_do_action(cptype); |
| 373 | return 0; | 373 | return 0; |
| 374 | case INT_HARDWARE_ENTRY: | 374 | case CN_INT_HARDWARE_ENTRY: |
| 375 | lkdtm.kp.symbol_name = "do_IRQ"; | 375 | lkdtm.kp.symbol_name = "do_IRQ"; |
| 376 | lkdtm.entry = (kprobe_opcode_t*) jp_do_irq; | 376 | lkdtm.entry = (kprobe_opcode_t*) jp_do_irq; |
| 377 | break; | 377 | break; |
| 378 | case INT_HW_IRQ_EN: | 378 | case CN_INT_HW_IRQ_EN: |
| 379 | lkdtm.kp.symbol_name = "handle_IRQ_event"; | 379 | lkdtm.kp.symbol_name = "handle_IRQ_event"; |
| 380 | lkdtm.entry = (kprobe_opcode_t*) jp_handle_irq_event; | 380 | lkdtm.entry = (kprobe_opcode_t*) jp_handle_irq_event; |
| 381 | break; | 381 | break; |
| 382 | case INT_TASKLET_ENTRY: | 382 | case CN_INT_TASKLET_ENTRY: |
| 383 | lkdtm.kp.symbol_name = "tasklet_action"; | 383 | lkdtm.kp.symbol_name = "tasklet_action"; |
| 384 | lkdtm.entry = (kprobe_opcode_t*) jp_tasklet_action; | 384 | lkdtm.entry = (kprobe_opcode_t*) jp_tasklet_action; |
| 385 | break; | 385 | break; |
| 386 | case FS_DEVRW: | 386 | case CN_FS_DEVRW: |
| 387 | lkdtm.kp.symbol_name = "ll_rw_block"; | 387 | lkdtm.kp.symbol_name = "ll_rw_block"; |
| 388 | lkdtm.entry = (kprobe_opcode_t*) jp_ll_rw_block; | 388 | lkdtm.entry = (kprobe_opcode_t*) jp_ll_rw_block; |
| 389 | break; | 389 | break; |
| 390 | case MEM_SWAPOUT: | 390 | case CN_MEM_SWAPOUT: |
| 391 | lkdtm.kp.symbol_name = "shrink_inactive_list"; | 391 | lkdtm.kp.symbol_name = "shrink_inactive_list"; |
| 392 | lkdtm.entry = (kprobe_opcode_t*) jp_shrink_inactive_list; | 392 | lkdtm.entry = (kprobe_opcode_t*) jp_shrink_inactive_list; |
| 393 | break; | 393 | break; |
| 394 | case TIMERADD: | 394 | case CN_TIMERADD: |
| 395 | lkdtm.kp.symbol_name = "hrtimer_start"; | 395 | lkdtm.kp.symbol_name = "hrtimer_start"; |
| 396 | lkdtm.entry = (kprobe_opcode_t*) jp_hrtimer_start; | 396 | lkdtm.entry = (kprobe_opcode_t*) jp_hrtimer_start; |
| 397 | break; | 397 | break; |
| 398 | case SCSI_DISPATCH_CMD: | 398 | case CN_SCSI_DISPATCH_CMD: |
| 399 | lkdtm.kp.symbol_name = "scsi_dispatch_cmd"; | 399 | lkdtm.kp.symbol_name = "scsi_dispatch_cmd"; |
| 400 | lkdtm.entry = (kprobe_opcode_t*) jp_scsi_dispatch_cmd; | 400 | lkdtm.entry = (kprobe_opcode_t*) jp_scsi_dispatch_cmd; |
| 401 | break; | 401 | break; |
| 402 | case IDE_CORE_CP: | 402 | case CN_IDE_CORE_CP: |
| 403 | #ifdef CONFIG_IDE | 403 | #ifdef CONFIG_IDE |
| 404 | lkdtm.kp.symbol_name = "generic_ide_ioctl"; | 404 | lkdtm.kp.symbol_name = "generic_ide_ioctl"; |
| 405 | lkdtm.entry = (kprobe_opcode_t*) jp_generic_ide_ioctl; | 405 | lkdtm.entry = (kprobe_opcode_t*) jp_generic_ide_ioctl; |
| @@ -416,7 +416,7 @@ static int lkdtm_register_cpoint(enum cname which) | |||
| 416 | cpoint = which; | 416 | cpoint = which; |
| 417 | if ((ret = register_jprobe(&lkdtm)) < 0) { | 417 | if ((ret = register_jprobe(&lkdtm)) < 0) { |
| 418 | printk(KERN_INFO "lkdtm: Couldn't register jprobe\n"); | 418 | printk(KERN_INFO "lkdtm: Couldn't register jprobe\n"); |
| 419 | cpoint = INVALID; | 419 | cpoint = CN_INVALID; |
| 420 | } | 420 | } |
| 421 | 421 | ||
| 422 | return ret; | 422 | return ret; |
| @@ -445,7 +445,7 @@ static ssize_t do_register_entry(enum cname which, struct file *f, | |||
| 445 | cptype = parse_cp_type(buf, count); | 445 | cptype = parse_cp_type(buf, count); |
| 446 | free_page((unsigned long) buf); | 446 | free_page((unsigned long) buf); |
| 447 | 447 | ||
| 448 | if (cptype == NONE) | 448 | if (cptype == CT_NONE) |
| 449 | return -EINVAL; | 449 | return -EINVAL; |
| 450 | 450 | ||
| 451 | err = lkdtm_register_cpoint(which); | 451 | err = lkdtm_register_cpoint(which); |
| @@ -487,49 +487,49 @@ static int lkdtm_debugfs_open(struct inode *inode, struct file *file) | |||
| 487 | static ssize_t int_hardware_entry(struct file *f, const char __user *buf, | 487 | static ssize_t int_hardware_entry(struct file *f, const char __user *buf, |
| 488 | size_t count, loff_t *off) | 488 | size_t count, loff_t *off) |
| 489 | { | 489 | { |
| 490 | return do_register_entry(INT_HARDWARE_ENTRY, f, buf, count, off); | 490 | return do_register_entry(CN_INT_HARDWARE_ENTRY, f, buf, count, off); |
| 491 | } | 491 | } |
| 492 | 492 | ||
| 493 | static ssize_t int_hw_irq_en(struct file *f, const char __user *buf, | 493 | static ssize_t int_hw_irq_en(struct file *f, const char __user *buf, |
| 494 | size_t count, loff_t *off) | 494 | size_t count, loff_t *off) |
| 495 | { | 495 | { |
| 496 | return do_register_entry(INT_HW_IRQ_EN, f, buf, count, off); | 496 | return do_register_entry(CN_INT_HW_IRQ_EN, f, buf, count, off); |
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | static ssize_t int_tasklet_entry(struct file *f, const char __user *buf, | 499 | static ssize_t int_tasklet_entry(struct file *f, const char __user *buf, |
| 500 | size_t count, loff_t *off) | 500 | size_t count, loff_t *off) |
| 501 | { | 501 | { |
| 502 | return do_register_entry(INT_TASKLET_ENTRY, f, buf, count, off); | 502 | return do_register_entry(CN_INT_TASKLET_ENTRY, f, buf, count, off); |
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | static ssize_t fs_devrw_entry(struct file *f, const char __user *buf, | 505 | static ssize_t fs_devrw_entry(struct file *f, const char __user *buf, |
| 506 | size_t count, loff_t *off) | 506 | size_t count, loff_t *off) |
| 507 | { | 507 | { |
| 508 | return do_register_entry(FS_DEVRW, f, buf, count, off); | 508 | return do_register_entry(CN_FS_DEVRW, f, buf, count, off); |
| 509 | } | 509 | } |
| 510 | 510 | ||
| 511 | static ssize_t mem_swapout_entry(struct file *f, const char __user *buf, | 511 | static ssize_t mem_swapout_entry(struct file *f, const char __user *buf, |
| 512 | size_t count, loff_t *off) | 512 | size_t count, loff_t *off) |
| 513 | { | 513 | { |
| 514 | return do_register_entry(MEM_SWAPOUT, f, buf, count, off); | 514 | return do_register_entry(CN_MEM_SWAPOUT, f, buf, count, off); |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | static ssize_t timeradd_entry(struct file *f, const char __user *buf, | 517 | static ssize_t timeradd_entry(struct file *f, const char __user *buf, |
| 518 | size_t count, loff_t *off) | 518 | size_t count, loff_t *off) |
| 519 | { | 519 | { |
| 520 | return do_register_entry(TIMERADD, f, buf, count, off); | 520 | return do_register_entry(CN_TIMERADD, f, buf, count, off); |
| 521 | } | 521 | } |
| 522 | 522 | ||
| 523 | static ssize_t scsi_dispatch_cmd_entry(struct file *f, | 523 | static ssize_t scsi_dispatch_cmd_entry(struct file *f, |
| 524 | const char __user *buf, size_t count, loff_t *off) | 524 | const char __user *buf, size_t count, loff_t *off) |
| 525 | { | 525 | { |
| 526 | return do_register_entry(SCSI_DISPATCH_CMD, f, buf, count, off); | 526 | return do_register_entry(CN_SCSI_DISPATCH_CMD, f, buf, count, off); |
| 527 | } | 527 | } |
| 528 | 528 | ||
| 529 | static ssize_t ide_core_cp_entry(struct file *f, const char __user *buf, | 529 | static ssize_t ide_core_cp_entry(struct file *f, const char __user *buf, |
| 530 | size_t count, loff_t *off) | 530 | size_t count, loff_t *off) |
| 531 | { | 531 | { |
| 532 | return do_register_entry(IDE_CORE_CP, f, buf, count, off); | 532 | return do_register_entry(CN_IDE_CORE_CP, f, buf, count, off); |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | /* Special entry to just crash directly. Available without KPROBEs */ | 535 | /* Special entry to just crash directly. Available without KPROBEs */ |
| @@ -557,7 +557,7 @@ static ssize_t direct_entry(struct file *f, const char __user *user_buf, | |||
| 557 | 557 | ||
| 558 | type = parse_cp_type(buf, count); | 558 | type = parse_cp_type(buf, count); |
| 559 | free_page((unsigned long) buf); | 559 | free_page((unsigned long) buf); |
| 560 | if (type == NONE) | 560 | if (type == CT_NONE) |
| 561 | return -EINVAL; | 561 | return -EINVAL; |
| 562 | 562 | ||
| 563 | printk(KERN_INFO "lkdtm: Performing direct entry %s\n", | 563 | printk(KERN_INFO "lkdtm: Performing direct entry %s\n", |
| @@ -649,7 +649,7 @@ static int __init lkdtm_module_init(void) | |||
| 649 | goto out_err; | 649 | goto out_err; |
| 650 | } | 650 | } |
| 651 | 651 | ||
| 652 | if (cpoint != INVALID && cptype != NONE) { | 652 | if (cpoint != CN_INVALID && cptype != CT_NONE) { |
| 653 | ret = lkdtm_register_cpoint(cpoint); | 653 | ret = lkdtm_register_cpoint(cpoint); |
| 654 | if (ret < 0) { | 654 | if (ret < 0) { |
| 655 | printk(KERN_INFO "lkdtm: Invalid crash point %d\n", | 655 | printk(KERN_INFO "lkdtm: Invalid crash point %d\n", |
