diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2020-11-21 00:14:19 +0100 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2020-12-10 19:39:32 +0100 |
commit | 1f702603e7125a390b5cdf5ce00539781cfcc86a (patch) | |
tree | ed62c7824115f6c452bf18f24b2f401b6206e020 /kernel/fork.c | |
parent | exec: Move unshare_files to fix posix file locking during exec (diff) | |
download | linux-1f702603e7125a390b5cdf5ce00539781cfcc86a.tar.xz linux-1f702603e7125a390b5cdf5ce00539781cfcc86a.zip |
exec: Simplify unshare_files
Now that exec no longer needs to return the unshared files to their
previous value there is no reason to return displaced.
Instead when unshare_fd creates a copy of the file table, call
put_files_struct before returning from unshare_files.
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
v1: https://lkml.kernel.org/r/20200817220425.9389-2-ebiederm@xmission.com
Link: https://lkml.kernel.org/r/20201120231441.29911-2-ebiederm@xmission.com
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 32083db7a2a2..837b546528c8 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -3023,21 +3023,21 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags) * the exec layer of the kernel. */ -int unshare_files(struct files_struct **displaced) +int unshare_files(void) { struct task_struct *task = current; - struct files_struct *copy = NULL; + struct files_struct *old, *copy = NULL; int error; error = unshare_fd(CLONE_FILES, NR_OPEN_MAX, ©); - if (error || !copy) { - *displaced = NULL; + if (error || !copy) return error; - } - *displaced = task->files; + + old = task->files; task_lock(task); task->files = copy; task_unlock(task); + put_files_struct(old); return 0; } |