From: Linus Torvalds Date: Thu, 6 Aug 2009 22:09:34 +0000 (-0700) Subject: flat: fix uninitialized ptr with shared libs X-Git-Tag: v2.6.27.30~10 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=58d92bedd89043cf0ade84a902130078dc9094b8;p=karo-tx-linux.git flat: fix uninitialized ptr with shared libs commit 3440625d78711bee41a84cf29c3d8c579b522666 upstream. The new credentials code broke load_flat_shared_library() as it now uses an uninitialized cred pointer. Reported-by: Bernd Schmidt Tested-by: Bernd Schmidt Cc: Mike Frysinger Cc: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index dfc0197905ca..25200e661443 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -824,15 +824,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); }