Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/driver/linux_onload/ossock_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ oo_fd_replace_file(struct file* old_filp, struct file* new_filp,
{
struct file* tmp_filp = NULL;

rcu_read_lock();
task_lock(current);
if( atomic_read(&current->files->count) != 1 ) {
/* This is a multithreaded application, and someone can be already
Expand All @@ -96,7 +97,6 @@ oo_fd_replace_file(struct file* old_filp, struct file* new_filp,
unsigned flags;

task_unlock(current);
rcu_read_lock(); /* for files_fdtable() */
flags = efrm_close_on_exec(old_fd, current->files) ? O_CLOEXEC : 0;
rcu_read_unlock();
new_fd = get_unused_fd_flags(flags);
Expand All @@ -117,6 +117,7 @@ oo_fd_replace_file(struct file* old_filp, struct file* new_filp,
if( tmp_filp )
fput(tmp_filp);
task_unlock(current);
rcu_read_unlock();
return -EINVAL;
}

Expand All @@ -125,6 +126,7 @@ oo_fd_replace_file(struct file* old_filp, struct file* new_filp,
get_file(new_filp);
rcu_assign_pointer(files_fdtable(current->files)->fd[old_fd], new_filp);
task_unlock(current);
rcu_read_unlock();

/* No synchronize_rcu() is needed here. See do_dup2() for an example,
* and file_free() for the reason. */
Expand Down