diff options
| -rw-r--r-- | fs/compat.c | 11 | ||||
| -rw-r--r-- | fs/exec.c | 19 |
2 files changed, 15 insertions, 15 deletions
diff --git a/fs/compat.c b/fs/compat.c index 379a399bf5c3..681ed81e6be0 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
| @@ -1476,6 +1476,7 @@ int compat_do_execve(char * filename, | |||
| 1476 | struct linux_binprm *bprm; | 1476 | struct linux_binprm *bprm; |
| 1477 | struct file *file; | 1477 | struct file *file; |
| 1478 | struct files_struct *displaced; | 1478 | struct files_struct *displaced; |
| 1479 | bool clear_in_exec; | ||
| 1479 | int retval; | 1480 | int retval; |
| 1480 | 1481 | ||
| 1481 | retval = unshare_files(&displaced); | 1482 | retval = unshare_files(&displaced); |
| @@ -1498,8 +1499,9 @@ int compat_do_execve(char * filename, | |||
| 1498 | goto out_unlock; | 1499 | goto out_unlock; |
| 1499 | 1500 | ||
| 1500 | retval = check_unsafe_exec(bprm); | 1501 | retval = check_unsafe_exec(bprm); |
| 1501 | if (retval) | 1502 | if (retval < 0) |
| 1502 | goto out_unlock; | 1503 | goto out_unlock; |
| 1504 | clear_in_exec = retval; | ||
| 1503 | 1505 | ||
| 1504 | file = open_exec(filename); | 1506 | file = open_exec(filename); |
| 1505 | retval = PTR_ERR(file); | 1507 | retval = PTR_ERR(file); |
| @@ -1546,9 +1548,7 @@ int compat_do_execve(char * filename, | |||
| 1546 | goto out; | 1548 | goto out; |
| 1547 | 1549 | ||
| 1548 | /* execve succeeded */ | 1550 | /* execve succeeded */ |
| 1549 | write_lock(¤t->fs->lock); | ||
| 1550 | current->fs->in_exec = 0; | 1551 | current->fs->in_exec = 0; |
| 1551 | write_unlock(¤t->fs->lock); | ||
| 1552 | current->in_execve = 0; | 1552 | current->in_execve = 0; |
| 1553 | mutex_unlock(¤t->cred_exec_mutex); | 1553 | mutex_unlock(¤t->cred_exec_mutex); |
| 1554 | acct_update_integrals(current); | 1554 | acct_update_integrals(current); |
| @@ -1568,9 +1568,8 @@ out_file: | |||
| 1568 | } | 1568 | } |
| 1569 | 1569 | ||
| 1570 | out_unmark: | 1570 | out_unmark: |
| 1571 | write_lock(¤t->fs->lock); | 1571 | if (clear_in_exec) |
| 1572 | current->fs->in_exec = 0; | 1572 | current->fs->in_exec = 0; |
| 1573 | write_unlock(¤t->fs->lock); | ||
| 1574 | 1573 | ||
| 1575 | out_unlock: | 1574 | out_unlock: |
| 1576 | current->in_execve = 0; | 1575 | current->in_execve = 0; |
| @@ -1077,9 +1077,11 @@ int check_unsafe_exec(struct linux_binprm *bprm) | |||
| 1077 | if (p->fs->users > n_fs) { | 1077 | if (p->fs->users > n_fs) { |
| 1078 | bprm->unsafe |= LSM_UNSAFE_SHARE; | 1078 | bprm->unsafe |= LSM_UNSAFE_SHARE; |
| 1079 | } else { | 1079 | } else { |
| 1080 | if (p->fs->in_exec) | 1080 | res = -EAGAIN; |
| 1081 | res = -EAGAIN; | 1081 | if (!p->fs->in_exec) { |
| 1082 | p->fs->in_exec = 1; | 1082 | p->fs->in_exec = 1; |
| 1083 | res = 1; | ||
| 1084 | } | ||
| 1083 | } | 1085 | } |
| 1084 | 1086 | ||
| 1085 | unlock_task_sighand(p, &flags); | 1087 | unlock_task_sighand(p, &flags); |
| @@ -1284,6 +1286,7 @@ int do_execve(char * filename, | |||
| 1284 | struct linux_binprm *bprm; | 1286 | struct linux_binprm *bprm; |
| 1285 | struct file *file; | 1287 | struct file *file; |
| 1286 | struct files_struct *displaced; | 1288 | struct files_struct *displaced; |
| 1289 | bool clear_in_exec; | ||
| 1287 | int retval; | 1290 | int retval; |
| 1288 | 1291 | ||
| 1289 | retval = unshare_files(&displaced); | 1292 | retval = unshare_files(&displaced); |
| @@ -1306,8 +1309,9 @@ int do_execve(char * filename, | |||
| 1306 | goto out_unlock; | 1309 | goto out_unlock; |
| 1307 | 1310 | ||
| 1308 | retval = check_unsafe_exec(bprm); | 1311 | retval = check_unsafe_exec(bprm); |
| 1309 | if (retval) | 1312 | if (retval < 0) |
| 1310 | goto out_unlock; | 1313 | goto out_unlock; |
| 1314 | clear_in_exec = retval; | ||
| 1311 | 1315 | ||
| 1312 | file = open_exec(filename); | 1316 | file = open_exec(filename); |
| 1313 | retval = PTR_ERR(file); | 1317 | retval = PTR_ERR(file); |
| @@ -1355,9 +1359,7 @@ int do_execve(char * filename, | |||
| 1355 | goto out; | 1359 | goto out; |
| 1356 | 1360 | ||
| 1357 | /* execve succeeded */ | 1361 | /* execve succeeded */ |
| 1358 | write_lock(¤t->fs->lock); | ||
| 1359 | current->fs->in_exec = 0; | 1362 | current->fs->in_exec = 0; |
| 1360 | write_unlock(¤t->fs->lock); | ||
| 1361 | current->in_execve = 0; | 1363 | current->in_execve = 0; |
| 1362 | mutex_unlock(¤t->cred_exec_mutex); | 1364 | mutex_unlock(¤t->cred_exec_mutex); |
| 1363 | acct_update_integrals(current); | 1365 | acct_update_integrals(current); |
| @@ -1377,9 +1379,8 @@ out_file: | |||
| 1377 | } | 1379 | } |
| 1378 | 1380 | ||
| 1379 | out_unmark: | 1381 | out_unmark: |
| 1380 | write_lock(¤t->fs->lock); | 1382 | if (clear_in_exec) |
| 1381 | current->fs->in_exec = 0; | 1383 | current->fs->in_exec = 0; |
| 1382 | write_unlock(¤t->fs->lock); | ||
| 1383 | 1384 | ||
| 1384 | out_unlock: | 1385 | out_unlock: |
| 1385 | current->in_execve = 0; | 1386 | current->in_execve = 0; |
