Skip to contentSkip to conversation

fs/binfmt_elf.c: fix GPF when dereferencing invalid interpreter

PATCH In review Nikitas Angelinas 2 participants 2 messages Mar 30, 2019

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

PATCH 1/1 fs/binfmt_elf.c: fix GPF when dereferencing invalid interpreter

Syzkaller found an issue where an invalid interpreter pointer is dereferenced in load_elf_binary()->allow_write_access(). Fix this by jumping to a different label in the cleanup path.

This patch applies against the latest linux-next tree. I have not tested that the patch addresses the issue, but it should, imho.

Reported-by [email protected]
Fixes 44e63c4a0263 ("fs/binfmt_elf.c: free PT_INTERP filename ASAP")
---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf.c +1 -1
index 51bc894..09e76b2 100644
@@ -777,7 +777,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
 			kfree(elf_interpreter);
 			retval = PTR_ERR(interpreter);
 			if (IS_ERR(interpreter))
-				goto out_free_dentry;
+				goto out_free_ph;
 
 			/*
 			 * If the binary is not readable then enforce
Signature · 1 line
2.10.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Nikitas Angelinas

Syzkaller found an issue where an invalid interpreter pointer is dereferenced in load_elf_binary()->allow_write_access()

please mention here on failure path inside  allow_write_access

as there are two path it gets called.

Quoted 5 lines

. Fix this by
jumping to a different label in the cleanup path.

This patch applies against the latest linux-next tree. I have not tested that the patch addresses the issue, but it should, imho.

This should not be written in commit text body.
please fix.

Quoted 5 lines
Reported-by [email protected]
Fixes 44e63c4a0263 ("fs/binfmt_elf.c: free PT_INTERP filename ASAP")

---

Patch looks valid to me as interpreter may be NULL and it later get tried to dereferencing inside allow_write_access

under label out_free_dentry.

Cheers,
-Mukesh

Quoted 16 lines
  fs/binfmt_elf.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf.c +1 -1
index 51bc894..09e76b2 100644
@@ -777,7 +777,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
  			kfree(elf_interpreter);
  			retval = PTR_ERR(interpreter);
  			if (IS_ERR(interpreter))
-				goto out_free_dentry;
+				goto out_free_ph;
 
  			/*
  			 * If the binary is not readable then enforce