aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2008-04-22 05:31:30 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2008-04-25 09:23:59 -0400
commit3b1253880b7a9e6db54b943b2d40bcf2202f58ab (patch)
tree5301be7b4d4310faa8db5a0d027b81421e36570e /fs/exec.c
parentfd8328be874f4190a811c58cd4778ec2c74d2c05 (diff)
[PATCH] sanitize unshare_files/reset_files_struct
* let unshare_files() give caller the displaced files_struct * don't bother with grabbing reference only to drop it in the caller if it hadn't been shared in the first place * in that form unshare_files() is trivially implemented via unshare_fd(), so we eliminate the duplicate logics in fork.c * reset_files_struct() is not just only called for current; it will break the system if somebody ever calls it for anything else (we can't modify ->files of somebody else). Lose the task_struct * argument. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 475543002f13..b152029f18f6 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1269,19 +1269,13 @@ int do_execve(char * filename,
1269 struct linux_binprm *bprm; 1269 struct linux_binprm *bprm;
1270 struct file *file; 1270 struct file *file;
1271 unsigned long env_p; 1271 unsigned long env_p;
1272 struct files_struct *files; 1272 struct files_struct *displaced;
1273 int retval; 1273 int retval;
1274 1274
1275 files = current->files; 1275 retval = unshare_files(&displaced);
1276 retval = unshare_files();
1277 if (retval) 1276 if (retval)
1278 goto out_ret; 1277 goto out_ret;
1279 1278
1280 if (files == current->files) {
1281 put_files_struct(files);
1282 files = NULL;
1283 }
1284
1285 retval = -ENOMEM; 1279 retval = -ENOMEM;
1286 bprm = kzalloc(sizeof(*bprm), GFP_KERNEL); 1280 bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
1287 if (!bprm) 1281 if (!bprm)
@@ -1340,8 +1334,8 @@ int do_execve(char * filename,
1340 security_bprm_free(bprm); 1334 security_bprm_free(bprm);
1341 acct_update_integrals(current); 1335 acct_update_integrals(current);
1342 kfree(bprm); 1336 kfree(bprm);
1343 if (files) 1337 if (displaced)
1344 put_files_struct(files); 1338 put_files_struct(displaced);
1345 return retval; 1339 return retval;
1346 } 1340 }
1347 1341
@@ -1363,8 +1357,8 @@ out_kfree:
1363 kfree(bprm); 1357 kfree(bprm);
1364 1358
1365out_files: 1359out_files:
1366 if (files) 1360 if (displaced)
1367 reset_files_struct(current, files); 1361 reset_files_struct(displaced);
1368out_ret: 1362out_ret:
1369 return retval; 1363 return retval;
1370} 1364}