From: David Howells Date: Thu, 28 Apr 2011 15:26:38 +0000 (+0100) Subject: CRED: Fix load_flat_shared_library() to initialise bprm correctly X-Git-Tag: android-x86-4.4-r1~5988^2~1^2~2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=3a852d3bd53e718206a18b015909c4b575952692;p=android-x86%2Fkernel.git CRED: Fix load_flat_shared_library() to initialise bprm correctly Fix binfmt_flag's load_flat_shared_library() to initialise bprm correctly. Currently, prepare_binprm() is called with only .filename .file and .cred fields set in bprm, but the .cred_prepared and .per_clear fields at least need initialising. Reported-by: Tetsuo Handa Signed-off-by: David Howells Signed-off-by: James Morris --- diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 397d3057d336..1bffbe0ed778 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -820,6 +820,8 @@ static int load_flat_shared_library(int id, struct lib_info *libs) int res; char buf[16]; + memset(&bprm, 0, sizeof(bprm)); + /* Create the file name */ sprintf(buf, "/lib/lib%d.so", id); @@ -835,6 +837,12 @@ static int load_flat_shared_library(int id, struct lib_info *libs) if (!bprm.cred) goto out; + /* We don't really care about recalculating credentials at this point + * as we're past the point of no return and are dealing with shared + * libraries. + */ + bprm.cred_prepared = 1; + res = prepare_binprm(&bprm); if (!IS_ERR_VALUE(res))