@@ -1314,6 +1314,11 @@ static int load_elf_binary(struct linux_binprm *bprm)
13141314 emulate the SVr4 behavior. Sigh. */
13151315 error = vm_mmap (NULL , 0 , PAGE_SIZE , PROT_READ | PROT_EXEC ,
13161316 MAP_FIXED | MAP_PRIVATE , 0 );
1317+
1318+ retval = do_mseal (0 , PAGE_SIZE , 0 );
1319+ if (retval )
1320+ pr_warn_ratelimited ("pid=%d, couldn't seal address 0, ret=%d.\n" ,
1321+ task_pid_nr (current ), retval );
13171322 }
13181323
13191324 regs = current_pt_regs ();
@@ -2027,8 +2032,10 @@ static int elf_core_dump(struct coredump_params *cprm)
20272032 * Collect all the non-memory information about the process for the
20282033 * notes. This also sets up the file header.
20292034 */
2030- if (!fill_note_info (& elf , e_phnum , & info , cprm ))
2035+ if (!fill_note_info (& elf , e_phnum , & info , cprm )) {
2036+ coredump_report_failure ("Error collecting note info" );
20312037 goto end_coredump ;
2038+ }
20322039
20332040 has_dumped = 1 ;
20342041
@@ -2043,8 +2050,10 @@ static int elf_core_dump(struct coredump_params *cprm)
20432050 sz += elf_coredump_extra_notes_size ();
20442051
20452052 phdr4note = kmalloc (sizeof (* phdr4note ), GFP_KERNEL );
2046- if (!phdr4note )
2053+ if (!phdr4note ) {
2054+ coredump_report_failure ("Error allocating program headers note entry" );
20472055 goto end_coredump ;
2056+ }
20482057
20492058 fill_elf_note_phdr (phdr4note , sz , offset );
20502059 offset += sz ;
@@ -2058,18 +2067,24 @@ static int elf_core_dump(struct coredump_params *cprm)
20582067
20592068 if (e_phnum == PN_XNUM ) {
20602069 shdr4extnum = kmalloc (sizeof (* shdr4extnum ), GFP_KERNEL );
2061- if (!shdr4extnum )
2070+ if (!shdr4extnum ) {
2071+ coredump_report_failure ("Error allocating extra program headers" );
20622072 goto end_coredump ;
2073+ }
20632074 fill_extnum_info (& elf , shdr4extnum , e_shoff , segs );
20642075 }
20652076
20662077 offset = dataoff ;
20672078
2068- if (!dump_emit (cprm , & elf , sizeof (elf )))
2079+ if (!dump_emit (cprm , & elf , sizeof (elf ))) {
2080+ coredump_report_failure ("Error emitting the ELF headers" );
20692081 goto end_coredump ;
2082+ }
20702083
2071- if (!dump_emit (cprm , phdr4note , sizeof (* phdr4note )))
2084+ if (!dump_emit (cprm , phdr4note , sizeof (* phdr4note ))) {
2085+ coredump_report_failure ("Error emitting the program header for notes" );
20722086 goto end_coredump ;
2087+ }
20732088
20742089 /* Write program headers for segments dump */
20752090 for (i = 0 ; i < cprm -> vma_count ; i ++ ) {
@@ -2092,37 +2107,51 @@ static int elf_core_dump(struct coredump_params *cprm)
20922107 phdr .p_flags |= PF_X ;
20932108 phdr .p_align = ELF_EXEC_PAGESIZE ;
20942109
2095- if (!dump_emit (cprm , & phdr , sizeof (phdr )))
2110+ if (!dump_emit (cprm , & phdr , sizeof (phdr ))) {
2111+ coredump_report_failure ("Error emitting program headers" );
20962112 goto end_coredump ;
2113+ }
20972114 }
20982115
2099- if (!elf_core_write_extra_phdrs (cprm , offset ))
2116+ if (!elf_core_write_extra_phdrs (cprm , offset )) {
2117+ coredump_report_failure ("Error writing out extra program headers" );
21002118 goto end_coredump ;
2119+ }
21012120
21022121 /* write out the notes section */
2103- if (!write_note_info (& info , cprm ))
2122+ if (!write_note_info (& info , cprm )) {
2123+ coredump_report_failure ("Error writing out notes" );
21042124 goto end_coredump ;
2125+ }
21052126
21062127 /* For cell spufs and x86 xstate */
2107- if (elf_coredump_extra_notes_write (cprm ))
2128+ if (elf_coredump_extra_notes_write (cprm )) {
2129+ coredump_report_failure ("Error writing out extra notes" );
21082130 goto end_coredump ;
2131+ }
21092132
21102133 /* Align to page */
21112134 dump_skip_to (cprm , dataoff );
21122135
21132136 for (i = 0 ; i < cprm -> vma_count ; i ++ ) {
21142137 struct core_vma_metadata * meta = cprm -> vma_meta + i ;
21152138
2116- if (!dump_user_range (cprm , meta -> start , meta -> dump_size ))
2139+ if (!dump_user_range (cprm , meta -> start , meta -> dump_size )) {
2140+ coredump_report_failure ("Error writing out the process memory" );
21172141 goto end_coredump ;
2142+ }
21182143 }
21192144
2120- if (!elf_core_write_extra_data (cprm ))
2145+ if (!elf_core_write_extra_data (cprm )) {
2146+ coredump_report_failure ("Error writing out extra data" );
21212147 goto end_coredump ;
2148+ }
21222149
21232150 if (e_phnum == PN_XNUM ) {
2124- if (!dump_emit (cprm , shdr4extnum , sizeof (* shdr4extnum )))
2151+ if (!dump_emit (cprm , shdr4extnum , sizeof (* shdr4extnum ))) {
2152+ coredump_report_failure ("Error emitting extra program headers" );
21252153 goto end_coredump ;
2154+ }
21262155 }
21272156
21282157end_coredump :
0 commit comments