Commit 1176e83a authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Greg Kroah-Hartman

Staging: android: task_get_unused_fd_flags: fix the wrong usage of tsk->signal

Compile tested.

task_struct->signal is not protected by RCU, the code is bogus.
Change the code to take ->siglock to pin ->signal.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Brian Swetland <swetland@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 191805ac
...@@ -319,6 +319,7 @@ int task_get_unused_fd_flags(struct task_struct *tsk, int flags) ...@@ -319,6 +319,7 @@ int task_get_unused_fd_flags(struct task_struct *tsk, int flags)
int fd, error; int fd, error;
struct fdtable *fdt; struct fdtable *fdt;
unsigned long rlim_cur; unsigned long rlim_cur;
unsigned long irqs;
if (files == NULL) if (files == NULL)
return -ESRCH; return -ESRCH;
...@@ -335,12 +336,11 @@ repeat: ...@@ -335,12 +336,11 @@ repeat:
* N.B. For clone tasks sharing a files structure, this test * N.B. For clone tasks sharing a files structure, this test
* will limit the total number of files that can be opened. * will limit the total number of files that can be opened.
*/ */
rcu_read_lock(); rlim_cur = 0;
if (tsk->signal) if (lock_task_sighand(tsk, &irqs)) {
rlim_cur = tsk->signal->rlim[RLIMIT_NOFILE].rlim_cur; rlim_cur = tsk->signal->rlim[RLIMIT_NOFILE].rlim_cur;
else unlock_task_sighand(tsk, &irqs);
rlim_cur = 0; }
rcu_read_unlock();
if (fd >= rlim_cur) if (fd >= rlim_cur)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment