Skip to contentSkip to conversation

binfmt: Fix error return code in load_elf_fdpic_binary()

PATCH Applied Wang Yufen 2 participants 3 messages Dec 2, 2022

Subsystems (3)
lore
Share & tools
lore

Wang Yufen

author
#0 lore raw

PATCH 1/1 binfmt: Fix error return code in load_elf_fdpic_binary()

Fix to return a negative error code from create_elf_fdpic_tables() instead of 0.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 fs/binfmt_elf_fdpic.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/binfmt_elf_fdpic.c +3 -2
index 08d0c87..9ce5e1f 100644
@@ -434,8 +434,9 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
 	current->mm->start_stack = current->mm->start_brk + stack_size;
 #endif
 
-	if (create_elf_fdpic_tables(bprm, current->mm,
-				    &exec_params, &interp_params) < 0)
+	retval = create_elf_fdpic_tables(bprm, current->mm, &exec_params,
+					 &interp_params);
+	if (retval < 0)
 		goto error;
 
 	kdebug("- start_code  %lx", current->mm->start_code);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 5 lines · Wang Yufen

Fix to return a negative error code from create_elf_fdpic_tables() instead of 0.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

Thanks for the catch! Yeah, it looks like this has been wrong for a long time. :)

-Kees

Quoted 23 lines
---
 fs/binfmt_elf_fdpic.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/binfmt_elf_fdpic.c +3 -2
index 08d0c87..9ce5e1f 100644
@@ -434,8 +434,9 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
 	current->mm->start_stack = current->mm->start_brk + stack_size;
 #endif
 
-	if (create_elf_fdpic_tables(bprm, current->mm,
-				    &exec_params, &interp_params) < 0)
+	retval = create_elf_fdpic_tables(bprm, current->mm, &exec_params,
+					 &interp_params);
+	if (retval < 0)
 		goto error;
 
 	kdebug("- start_code  %lx", current->mm->start_code);
Signature · 1 line
1.8.3.1
Signature · 1 line
Kees Cook