public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] android: task_get_unused_fd_flags: fix the wrong usage of tsk->signal
@ 2009-01-18 17:17 Oleg Nesterov
  2009-01-18 18:22 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2009-01-18 17:17 UTC (permalink / raw)
  To: arve, gregkh, jrm8005, rlove, swetland; +Cc: linux-kernel

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 <oleg@redhat.com>

--- CUR/drivers/staging/android/binder.c~ANDROID	2009-01-12 23:07:43.000000000 +0100
+++ CUR/drivers/staging/android/binder.c	2009-01-18 18:06:12.000000000 +0100
@@ -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;
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-18 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-18 17:17 [PATCH] android: task_get_unused_fd_flags: fix the wrong usage of tsk->signal Oleg Nesterov
2009-01-18 18:22 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox