Skip to contentSkip to conversation

fs/binfmt_elf: fix PT_LOAD p_align values for loaders

PATCH In review Mike Rapoport 2 participants 2 messages Feb 2, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/binfmt_elf: fix PT_LOAD p_align values for loaders

From: Mike Rapoport <[email protected]>

Rui Salvaterra reported that Aisleroit solitaire crashes with "Wrong __data_start/_end pair" assertion from libgc after update to v5.17-rc1.

Bisection pointed to commit 9630f0d60fec ("fs/binfmt_elf: use PT_LOAD p_align values for static PIE") that fixed handling of static PIEs, but made the condition that guards load_bias calculation to exclude loader binaries.

Restoring the check for presence of interpreter fixes the problem.

Fixes 9630f0d60fec ("fs/binfmt_elf: use PT_LOAD p_align values for static PIE")
---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf.c +1 -1
index 605017eb9349..9e11e6f13e83 100644
@@ -1117,7 +1117,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
 			 * without MAP_FIXED nor MAP_FIXED_NOREPLACE).
 			 */
 			alignment = maximum_alignment(elf_phdata, elf_ex->e_phnum);
-			if (alignment > ELF_MIN_ALIGN) {
+			if (interpreter || alignment > ELF_MIN_ALIGN) {
 				load_bias = ELF_ET_DYN_BASE;
 				if (current->flags & PF_RANDOMIZE)
 					load_bias += arch_mmap_rnd();
Signature · 1 line
2.34.1
Tested-by on v1 1/1
#1 lore raw

Hi, Mike,

Quoted 34 lines · Mike Rapoport

From: Mike Rapoport <[email protected]>

Rui Salvaterra reported that Aisleroit solitaire crashes with "Wrong __data_start/_end pair" assertion from libgc after update to v5.17-rc1.

Bisection pointed to commit 9630f0d60fec ("fs/binfmt_elf: use PT_LOAD p_align values for static PIE") that fixed handling of static PIEs, but made the condition that guards load_bias calculation to exclude loader binaries.

Restoring the check for presence of interpreter fixes the problem.

Fixes 9630f0d60fec ("fs/binfmt_elf: use PT_LOAD p_align values for static PIE")
---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf.c +1 -2
index 605017eb9349..9e11e6f13e83 100644
@@ -1117,7 +1117,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
                         * without MAP_FIXED nor MAP_FIXED_NOREPLACE).
                         */
                        alignment = maximum_alignment(elf_phdata, elf_ex->e_phnum);
-                       if (alignment > ELF_MIN_ALIGN) {
+                       if (interpreter || alignment > ELF_MIN_ALIGN) {
                                load_bias = ELF_ET_DYN_BASE;
                                if (current->flags & PF_RANDOMIZE)
                                        load_bias += arch_mmap_rnd();
--
Quoted 2 lines

2.34.1

The patch does fix the problem for me, and is thus

Thanks,
Rui