fs core fixes
[pandora-kernel.git] / fs / compat.c
index a76455b..a53216d 100644 (file)
@@ -1353,12 +1353,17 @@ int compat_do_execve(char * filename,
 {
        struct linux_binprm *bprm;
        struct file *file;
+       struct files_struct *displaced;
        int retval;
 
+       retval = unshare_files(&displaced);
+       if (retval)
+               goto out_ret;
+
        retval = -ENOMEM;
        bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
        if (!bprm)
-               goto out_ret;
+               goto out_files;
 
        file = open_exec(filename);
        retval = PTR_ERR(file);
@@ -1410,6 +1415,8 @@ int compat_do_execve(char * filename,
                security_bprm_free(bprm);
                acct_update_integrals(current);
                free_bprm(bprm);
+               if (displaced)
+                       put_files_struct(displaced);
                return retval;
        }
 
@@ -1430,6 +1437,9 @@ out_file:
 out_kfree:
        free_bprm(bprm);
 
+out_files:
+       if (displaced)
+               reset_files_struct(displaced);
 out_ret:
        return retval;
 }