Skip to content

Commit 3a852d3

Browse files
dhowellsJames Morris
authored and
James Morris
committed
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 <[email protected]> Signed-off-by: David Howells <[email protected]> Signed-off-by: James Morris <[email protected]>
1 parent db5ca35 commit 3a852d3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/binfmt_flat.c

+8
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,8 @@ static int load_flat_shared_library(int id, struct lib_info *libs)
820820
int res;
821821
char buf[16];
822822

823+
memset(&bprm, 0, sizeof(bprm));
824+
823825
/* Create the file name */
824826
sprintf(buf, "/lib/lib%d.so", id);
825827

@@ -835,6 +837,12 @@ static int load_flat_shared_library(int id, struct lib_info *libs)
835837
if (!bprm.cred)
836838
goto out;
837839

840+
/* We don't really care about recalculating credentials at this point
841+
* as we're past the point of no return and are dealing with shared
842+
* libraries.
843+
*/
844+
bprm.cred_prepared = 1;
845+
838846
res = prepare_binprm(&bprm);
839847

840848
if (!IS_ERR_VALUE(res))

0 commit comments

Comments
 (0)