updating current->files requires task_lock
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
goto out;
}
- /*
- * Note: we may be using current for both targets (See exec.c)
- * This works because we cache current->files (old) as oldf. Don't
- * break this.
- */
- tsk->files = NULL;
newf = dup_fd(oldf, &error);
if (!newf)
goto out;
int unshare_files(void)
{
struct files_struct *files = current->files;
- int rc;
+ struct files_struct *newf;
+ int error = 0;
BUG_ON(!files);
atomic_inc(&files->count);
return 0;
}
- rc = copy_files(0, current);
- if(rc)
- current->files = files;
- return rc;
+ newf = dup_fd(files, &error);
+ if (newf) {
+ task_lock(current);
+ current->files = newf;
+ task_unlock(current);
+ }
+ return error;
}
EXPORT_SYMBOL(unshare_files);