Skip to content

Commit

Permalink
CRED: Fix load_flat_shared_library() to initialise bprm correctly
Browse files Browse the repository at this point in the history
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 <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
dhowells authored and James Morris committed May 3, 2011
1 parent db5ca35 commit 3a852d3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/binfmt_flat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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))
Expand Down

0 comments on commit 3a852d3

Please sign in to comment.