kcmp: In get_file_raw_ptr use task_lookup_fd_rcu

ANBZ: #9824

commit ed77e80e14 upstream.

Modify get_file_raw_ptr to use task_lookup_fd_rcu.  The helper
task_lookup_fd_rcu does the work of taking the task lock and verifying
that task->files != NULL and then calls files_lookup_fd_rcu.  So let
use the helper to make a simpler implementation of get_file_raw_ptr.

Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Link: https://lkml.kernel.org/r/20201120231441.29911-13-ebiederm@xmission.com
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ferry Meng <mengferry@linux.alibaba.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3779
This commit is contained in:
Eric W. Biederman 2020-11-20 17:14:30 -06:00 committed by 小龙
parent e62795e67b
commit 15ae23a65e
1 changed files with 2 additions and 7 deletions

View File

@ -61,16 +61,11 @@ static int kcmp_ptr(void *v1, void *v2, enum kcmp_type type)
static struct file *
get_file_raw_ptr(struct task_struct *task, unsigned int idx)
{
struct file *file = NULL;
struct file *file;
task_lock(task);
rcu_read_lock();
if (task->files)
file = files_lookup_fd_rcu(task->files, idx);
file = task_lookup_fd_rcu(task, idx);
rcu_read_unlock();
task_unlock(task);
return file;
}