@@ -586,8 +586,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
586586 struct subprocess_info * sub_info ;
587587
588588 if (ispipe < 0 ) {
589- printk (KERN_WARNING "format_corename failed\n" );
590- printk (KERN_WARNING "Aborting core\n" );
589+ coredump_report_failure ("format_corename failed, aborting core" );
591590 goto fail_unlock ;
592591 }
593592
@@ -607,27 +606,21 @@ void do_coredump(const kernel_siginfo_t *siginfo)
607606 * right pid if a thread in a multi-threaded
608607 * core_pattern process dies.
609608 */
610- printk (KERN_WARNING
611- "Process %d(%s) has RLIMIT_CORE set to 1\n" ,
612- task_tgid_vnr (current ), current -> comm );
613- printk (KERN_WARNING "Aborting core\n" );
609+ coredump_report_failure ("RLIMIT_CORE is set to 1, aborting core" );
614610 goto fail_unlock ;
615611 }
616612 cprm .limit = RLIM_INFINITY ;
617613
618614 dump_count = atomic_inc_return (& core_dump_count );
619615 if (core_pipe_limit && (core_pipe_limit < dump_count )) {
620- printk (KERN_WARNING "Pid %d(%s) over core_pipe_limit\n" ,
621- task_tgid_vnr (current ), current -> comm );
622- printk (KERN_WARNING "Skipping core dump\n" );
616+ coredump_report_failure ("over core_pipe_limit, skipping core dump" );
623617 goto fail_dropcount ;
624618 }
625619
626620 helper_argv = kmalloc_array (argc + 1 , sizeof (* helper_argv ),
627621 GFP_KERNEL );
628622 if (!helper_argv ) {
629- printk (KERN_WARNING "%s failed to allocate memory\n" ,
630- __func__ );
623+ coredump_report_failure ("%s failed to allocate memory" , __func__ );
631624 goto fail_dropcount ;
632625 }
633626 for (argi = 0 ; argi < argc ; argi ++ )
@@ -644,8 +637,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
644637
645638 kfree (helper_argv );
646639 if (retval ) {
647- printk (KERN_INFO "Core dump to |%s pipe failed\n" ,
648- cn .corename );
640+ coredump_report_failure ("|%s pipe failed" , cn .corename );
649641 goto close_fail ;
650642 }
651643 } else {
@@ -658,10 +650,8 @@ void do_coredump(const kernel_siginfo_t *siginfo)
658650 goto fail_unlock ;
659651
660652 if (need_suid_safe && cn .corename [0 ] != '/' ) {
661- printk (KERN_WARNING "Pid %d(%s) can only dump core " \
662- "to fully qualified path!\n" ,
663- task_tgid_vnr (current ), current -> comm );
664- printk (KERN_WARNING "Skipping core dump\n" );
653+ coredump_report_failure (
654+ "this process can only dump core to a fully qualified path, skipping core dump" );
665655 goto fail_unlock ;
666656 }
667657
@@ -730,13 +720,13 @@ void do_coredump(const kernel_siginfo_t *siginfo)
730720 idmap = file_mnt_idmap (cprm .file );
731721 if (!vfsuid_eq_kuid (i_uid_into_vfsuid (idmap , inode ),
732722 current_fsuid ())) {
733- pr_info_ratelimited ("Core dump to %s aborted: cannot preserve file owner\n" ,
734- cn .corename );
723+ coredump_report_failure ("Core dump to %s aborted: "
724+ "cannot preserve file owner" , cn .corename );
735725 goto close_fail ;
736726 }
737727 if ((inode -> i_mode & 0677 ) != 0600 ) {
738- pr_info_ratelimited ("Core dump to %s aborted: cannot preserve file permissions\n" ,
739- cn .corename );
728+ coredump_report_failure ("Core dump to %s aborted: "
729+ "cannot preserve file permissions" , cn .corename );
740730 goto close_fail ;
741731 }
742732 if (!(cprm .file -> f_mode & FMODE_CAN_WRITE ))
@@ -757,7 +747,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
757747 * have this set to NULL.
758748 */
759749 if (!cprm .file ) {
760- pr_info ("Core dump to |%s disabled\n " , cn .corename );
750+ coredump_report_failure ("Core dump to |%s disabled" , cn .corename );
761751 goto close_fail ;
762752 }
763753 if (!dump_vma_snapshot (& cprm ))
@@ -983,11 +973,10 @@ void validate_coredump_safety(void)
983973{
984974 if (suid_dumpable == SUID_DUMP_ROOT &&
985975 core_pattern [0 ] != '/' && core_pattern [0 ] != '|' ) {
986- pr_warn (
987- "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
988- "Pipe handler or fully qualified core dump path required.\n"
989- "Set kernel.core_pattern before fs.suid_dumpable.\n"
990- );
976+
977+ coredump_report_failure ("Unsafe core_pattern used with fs.suid_dumpable=2: "
978+ "pipe handler or fully qualified core dump path required. "
979+ "Set kernel.core_pattern before fs.suid_dumpable." );
991980 }
992981}
993982
0 commit comments