From oleg@redhat.com Wed Jan 21 07:43:26 2009 From: Oleg Nesterov Date: Sun, 18 Jan 2009 18:17:20 +0100 Subject: Staging: android: task_get_unused_fd_flags: fix the wrong usage of tsk->signal To: arve@android.com, gregkh@suse.de, jrm8005@gmail.com, rlove@google.com, swetland@google.com Cc: linux-kernel@vger.kernel.org Message-ID: <20090118171720.GA18374@redhat.com> Content-Disposition: inline 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: Oleg Nesterov Cc: Arve Hjønnevåg Cc: Brian Swetland Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -319,6 +319,7 @@ int task_get_unused_fd_flags(struct task int fd, error; struct fdtable *fdt; unsigned long rlim_cur; + unsigned long irqs; if (files == NULL) return -ESRCH; @@ -335,12 +336,11 @@ repeat: * N.B. For clone tasks sharing a files structure, this test * will limit the total number of files that can be opened. */ - rcu_read_lock(); - if (tsk->signal) + rlim_cur = 0; + if (lock_task_sighand(tsk, &irqs)) { rlim_cur = tsk->signal->rlim[RLIMIT_NOFILE].rlim_cur; - else - rlim_cur = 0; - rcu_read_unlock(); + unlock_task_sighand(tsk, &irqs); + } if (fd >= rlim_cur) goto out;