@@ -1314,6 +1314,11 @@ static int load_elf_binary(struct linux_binprm *bprm)
1314
1314
emulate the SVr4 behavior. Sigh. */
1315
1315
error = vm_mmap (NULL , 0 , PAGE_SIZE , PROT_READ | PROT_EXEC ,
1316
1316
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 );
1317
1322
}
1318
1323
1319
1324
regs = current_pt_regs ();
@@ -2027,8 +2032,10 @@ static int elf_core_dump(struct coredump_params *cprm)
2027
2032
* Collect all the non-memory information about the process for the
2028
2033
* notes. This also sets up the file header.
2029
2034
*/
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" );
2031
2037
goto end_coredump ;
2038
+ }
2032
2039
2033
2040
has_dumped = 1 ;
2034
2041
@@ -2043,8 +2050,10 @@ static int elf_core_dump(struct coredump_params *cprm)
2043
2050
sz += elf_coredump_extra_notes_size ();
2044
2051
2045
2052
phdr4note = kmalloc (sizeof (* phdr4note ), GFP_KERNEL );
2046
- if (!phdr4note )
2053
+ if (!phdr4note ) {
2054
+ coredump_report_failure ("Error allocating program headers note entry" );
2047
2055
goto end_coredump ;
2056
+ }
2048
2057
2049
2058
fill_elf_note_phdr (phdr4note , sz , offset );
2050
2059
offset += sz ;
@@ -2058,18 +2067,24 @@ static int elf_core_dump(struct coredump_params *cprm)
2058
2067
2059
2068
if (e_phnum == PN_XNUM ) {
2060
2069
shdr4extnum = kmalloc (sizeof (* shdr4extnum ), GFP_KERNEL );
2061
- if (!shdr4extnum )
2070
+ if (!shdr4extnum ) {
2071
+ coredump_report_failure ("Error allocating extra program headers" );
2062
2072
goto end_coredump ;
2073
+ }
2063
2074
fill_extnum_info (& elf , shdr4extnum , e_shoff , segs );
2064
2075
}
2065
2076
2066
2077
offset = dataoff ;
2067
2078
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" );
2069
2081
goto end_coredump ;
2082
+ }
2070
2083
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" );
2072
2086
goto end_coredump ;
2087
+ }
2073
2088
2074
2089
/* Write program headers for segments dump */
2075
2090
for (i = 0 ; i < cprm -> vma_count ; i ++ ) {
@@ -2092,37 +2107,51 @@ static int elf_core_dump(struct coredump_params *cprm)
2092
2107
phdr .p_flags |= PF_X ;
2093
2108
phdr .p_align = ELF_EXEC_PAGESIZE ;
2094
2109
2095
- if (!dump_emit (cprm , & phdr , sizeof (phdr )))
2110
+ if (!dump_emit (cprm , & phdr , sizeof (phdr ))) {
2111
+ coredump_report_failure ("Error emitting program headers" );
2096
2112
goto end_coredump ;
2113
+ }
2097
2114
}
2098
2115
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" );
2100
2118
goto end_coredump ;
2119
+ }
2101
2120
2102
2121
/* 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" );
2104
2124
goto end_coredump ;
2125
+ }
2105
2126
2106
2127
/* 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" );
2108
2130
goto end_coredump ;
2131
+ }
2109
2132
2110
2133
/* Align to page */
2111
2134
dump_skip_to (cprm , dataoff );
2112
2135
2113
2136
for (i = 0 ; i < cprm -> vma_count ; i ++ ) {
2114
2137
struct core_vma_metadata * meta = cprm -> vma_meta + i ;
2115
2138
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" );
2117
2141
goto end_coredump ;
2142
+ }
2118
2143
}
2119
2144
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" );
2121
2147
goto end_coredump ;
2148
+ }
2122
2149
2123
2150
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" );
2125
2153
goto end_coredump ;
2154
+ }
2126
2155
}
2127
2156
2128
2157
end_coredump :
0 commit comments