diff options
author | Dipankar Sarma <dipankar@in.ibm.com> | 2006-04-18 22:21:46 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-04-19 09:13:51 -0700 |
commit | ca99c1da080345e227cfb083c330a184d42e27f3 (patch) | |
tree | e417b4c456ae31dc1dde8027b6be44a1a9f19395 /drivers/char | |
parent | fb30d64568fd8f6a21afef987f11852a109723da (diff) | |
download | op-kernel-dev-ca99c1da080345e227cfb083c330a184d42e27f3.zip op-kernel-dev-ca99c1da080345e227cfb083c330a184d42e27f3.tar.gz |
[PATCH] Fix file lookup without ref
There are places in the kernel where we look up files in fd tables and
access the file structure without holding refereces to the file. So, we
need special care to avoid the race between looking up files in the fd
table and tearing down of the file in another CPU. Otherwise, one might
see a NULL f_dentry or such torn down version of the file. This patch
fixes those special places where such a race may happen.
Signed-off-by: Dipankar Sarma <dipankar@in.ibm.com>
Acked-by: "Paul E. McKenney" <paulmck@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tty_io.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 841f0bd..f07637a 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2723,7 +2723,11 @@ static void __do_SAK(void *arg) } task_lock(p); if (p->files) { - rcu_read_lock(); + /* + * We don't take a ref to the file, so we must + * hold ->file_lock instead. + */ + spin_lock(&p->files->file_lock); fdt = files_fdtable(p->files); for (i=0; i < fdt->max_fds; i++) { filp = fcheck_files(p->files, i); @@ -2738,7 +2742,7 @@ static void __do_SAK(void *arg) break; } } - rcu_read_unlock(); + spin_unlock(&p->files->file_lock); } task_unlock(p); } while_each_thread(g, p); |