Skip to content

Commit

Permalink
flat: fix uninitialized ptr with shared libs
Browse files Browse the repository at this point in the history
The new credentials code broke load_flat_shared_library() as it now uses
an uninitialized cred pointer.

Reported-by: Bernd Schmidt <bernds_cb1@t-online.de>
Tested-by: Bernd Schmidt <bernds_cb1@t-online.de>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: David Howells <dhowells@redhat.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Linus Torvalds committed Aug 7, 2009
1 parent 9e5cf0c commit 3440625
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions fs/binfmt_flat.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,15 +828,22 @@ static int load_flat_shared_library(int id, struct lib_info *libs)
if (IS_ERR(bprm.file))
return res;

bprm.cred = prepare_exec_creds();
res = -ENOMEM;
if (!bprm.cred)
goto out;

res = prepare_binprm(&bprm);

if (res <= (unsigned long)-4096)
res = load_flat_file(&bprm, libs, id, NULL);
if (bprm.file) {
allow_write_access(bprm.file);
fput(bprm.file);
bprm.file = NULL;
}

abort_creds(bprm.cred);

out:
allow_write_access(bprm.file);
fput(bprm.file);

return(res);
}

Expand Down

0 comments on commit 3440625

Please sign in to comment.