Skip to content

Commit feac6e2

Browse files
keesgregkh
authored andcommitted
lkdtm: convert to using pr_* for reports
Move to using pr_* calls instead of printk calls for reporting. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6bb948c commit feac6e2

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

drivers/misc/lkdtm.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*
3131
* See Documentation/fault-injection/provoke-crashes.txt for instructions
3232
*/
33+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3334

3435
#include <linux/kernel.h>
3536
#include <linux/fs.h>
@@ -493,8 +494,8 @@ static void lkdtm_handler(void)
493494

494495
spin_lock_irqsave(&count_lock, flags);
495496
count--;
496-
printk(KERN_INFO "lkdtm: Crash point %s of type %s hit, trigger in %d rounds\n",
497-
cp_name_to_str(cpoint), cp_type_to_str(cptype), count);
497+
pr_info("Crash point %s of type %s hit, trigger in %d rounds\n",
498+
cp_name_to_str(cpoint), cp_type_to_str(cptype), count);
498499

499500
if (count == 0) {
500501
do_it = true;
@@ -551,18 +552,18 @@ static int lkdtm_register_cpoint(enum cname which)
551552
lkdtm.kp.symbol_name = "generic_ide_ioctl";
552553
lkdtm.entry = (kprobe_opcode_t*) jp_generic_ide_ioctl;
553554
#else
554-
printk(KERN_INFO "lkdtm: Crash point not available\n");
555+
pr_info("Crash point not available\n");
555556
return -EINVAL;
556557
#endif
557558
break;
558559
default:
559-
printk(KERN_INFO "lkdtm: Invalid Crash Point\n");
560+
pr_info("Invalid Crash Point\n");
560561
return -EINVAL;
561562
}
562563

563564
cpoint = which;
564565
if ((ret = register_jprobe(&lkdtm)) < 0) {
565-
printk(KERN_INFO "lkdtm: Couldn't register jprobe\n");
566+
pr_info("Couldn't register jprobe\n");
566567
cpoint = CN_INVALID;
567568
}
568569

@@ -709,8 +710,7 @@ static ssize_t direct_entry(struct file *f, const char __user *user_buf,
709710
if (type == CT_NONE)
710711
return -EINVAL;
711712

712-
printk(KERN_INFO "lkdtm: Performing direct entry %s\n",
713-
cp_type_to_str(type));
713+
pr_info("Performing direct entry %s\n", cp_type_to_str(type));
714714
lkdtm_do_action(type);
715715
*off += count;
716716

@@ -772,7 +772,7 @@ static int __init lkdtm_module_init(void)
772772
/* Register debugfs interface */
773773
lkdtm_debugfs_root = debugfs_create_dir("provoke-crash", NULL);
774774
if (!lkdtm_debugfs_root) {
775-
printk(KERN_ERR "lkdtm: creating root dir failed\n");
775+
pr_err("creating root dir failed\n");
776776
return -ENODEV;
777777
}
778778

@@ -787,28 +787,26 @@ static int __init lkdtm_module_init(void)
787787
de = debugfs_create_file(cur->name, 0644, lkdtm_debugfs_root,
788788
NULL, &cur->fops);
789789
if (de == NULL) {
790-
printk(KERN_ERR "lkdtm: could not create %s\n",
791-
cur->name);
790+
pr_err("could not create %s\n", cur->name);
792791
goto out_err;
793792
}
794793
}
795794

796795
if (lkdtm_parse_commandline() == -EINVAL) {
797-
printk(KERN_INFO "lkdtm: Invalid command\n");
796+
pr_info("Invalid command\n");
798797
goto out_err;
799798
}
800799

801800
if (cpoint != CN_INVALID && cptype != CT_NONE) {
802801
ret = lkdtm_register_cpoint(cpoint);
803802
if (ret < 0) {
804-
printk(KERN_INFO "lkdtm: Invalid crash point %d\n",
805-
cpoint);
803+
pr_info("Invalid crash point %d\n", cpoint);
806804
goto out_err;
807805
}
808-
printk(KERN_INFO "lkdtm: Crash point %s of type %s registered\n",
809-
cpoint_name, cpoint_type);
806+
pr_info("Crash point %s of type %s registered\n",
807+
cpoint_name, cpoint_type);
810808
} else {
811-
printk(KERN_INFO "lkdtm: No crash points registered, enable through debugfs\n");
809+
pr_info("No crash points registered, enable through debugfs\n");
812810
}
813811

814812
return 0;
@@ -823,7 +821,7 @@ static void __exit lkdtm_module_exit(void)
823821
debugfs_remove_recursive(lkdtm_debugfs_root);
824822

825823
unregister_jprobe(&lkdtm);
826-
printk(KERN_INFO "lkdtm: Crash point unregistered\n");
824+
pr_info("Crash point unregistered\n");
827825
}
828826

829827
module_init(lkdtm_module_init);

0 commit comments

Comments
 (0)