diff options
author | Jonathan Corbet <corbet@lwn.net> | 2009-02-06 17:25:24 -0500 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2009-03-16 10:32:27 -0400 |
commit | db1dd4d376134eba0e08af523b61cc566a4ea1cd (patch) | |
tree | 8882c673abbaa5713511b7046493fa862b9140d1 /drivers/char/tty_io.c | |
parent | 684999149002dd046269666a390458e0acb38280 (diff) |
Use f_lock to protect f_flags
Traditionally, changes to struct file->f_flags have been done under BKL
protection, or with no protection at all. This patch causes all f_flags
changes after file open/creation time to be done under protection of
f_lock. This allows the removal of some BKL usage and fixes a number of
longstanding (if microscopic) races.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r-- | drivers/char/tty_io.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index bc84e125c6bc..224f271d8cbe 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2162,13 +2162,12 @@ static int fionbio(struct file *file, int __user *p) | |||
2162 | if (get_user(nonblock, p)) | 2162 | if (get_user(nonblock, p)) |
2163 | return -EFAULT; | 2163 | return -EFAULT; |
2164 | 2164 | ||
2165 | /* file->f_flags is still BKL protected in the fs layer - vomit */ | 2165 | spin_lock(&file->f_lock); |
2166 | lock_kernel(); | ||
2167 | if (nonblock) | 2166 | if (nonblock) |
2168 | file->f_flags |= O_NONBLOCK; | 2167 | file->f_flags |= O_NONBLOCK; |
2169 | else | 2168 | else |
2170 | file->f_flags &= ~O_NONBLOCK; | 2169 | file->f_flags &= ~O_NONBLOCK; |
2171 | unlock_kernel(); | 2170 | spin_unlock(&file->f_lock); |
2172 | return 0; | 2171 | return 0; |
2173 | } | 2172 | } |
2174 | 2173 | ||