Skip to content

Commit 5751153

Browse files
committed
Merge tag 'binfmt_elf-v5.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull binfmt_elf fix from Kees Cook: "This addresses a regression[1] under ia64 where some ET_EXEC binaries were not loading" Link: https://linux-regtracking.leemhuis.info/regzbot/regression/[email protected]/ [1] - Fix ia64 ET_EXEC loading * tag 'binfmt_elf-v5.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: binfmt_elf: Avoid total_mapping_size for ET_EXEC
2 parents 719fce7 + 439a846 commit 5751153

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

fs/binfmt_elf.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,14 +1135,25 @@ static int load_elf_binary(struct linux_binprm *bprm)
11351135
* is then page aligned.
11361136
*/
11371137
load_bias = ELF_PAGESTART(load_bias - vaddr);
1138-
}
11391138

1140-
/*
1141-
* Calculate the entire size of the ELF mapping (total_size).
1142-
* (Note that load_addr_set is set to true later once the
1143-
* initial mapping is performed.)
1144-
*/
1145-
if (!load_addr_set) {
1139+
/*
1140+
* Calculate the entire size of the ELF mapping
1141+
* (total_size), used for the initial mapping,
1142+
* due to load_addr_set which is set to true later
1143+
* once the initial mapping is performed.
1144+
*
1145+
* Note that this is only sensible when the LOAD
1146+
* segments are contiguous (or overlapping). If
1147+
* used for LOADs that are far apart, this would
1148+
* cause the holes between LOADs to be mapped,
1149+
* running the risk of having the mapping fail,
1150+
* as it would be larger than the ELF file itself.
1151+
*
1152+
* As a result, only ET_DYN does this, since
1153+
* some ET_EXEC (e.g. ia64) may have large virtual
1154+
* memory holes between LOADs.
1155+
*
1156+
*/
11461157
total_size = total_mapping_size(elf_phdata,
11471158
elf_ex->e_phnum);
11481159
if (!total_size) {

0 commit comments

Comments
 (0)