lkml.org 
[lkml]   [2009]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/4] Use f_lock to protect f_flags
On Sat, Feb 07, 2009 at 01:06:55PM -0700, Jonathan Corbet wrote:
> 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.

Looks good to me.


Reviewed-by: Christoph Hellwig <hch@lst.de>

One comments only tangentially related to the patch:


> diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
> index bc84e12..224f271 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)
> if (get_user(nonblock, p))
> return -EFAULT;
>
> - /* file->f_flags is still BKL protected in the fs layer - vomit */
> - lock_kernel();
> + spin_lock(&file->f_lock);
> if (nonblock)
> file->f_flags |= O_NONBLOCK;
> else
> file->f_flags &= ~O_NONBLOCK;
> - unlock_kernel();
> + spin_unlock(&file->f_lock);
> return 0;
> }

Why is this code there at all? It's a duplicate of
fs/ioctl.c:ioctl_fionbio minus the sparc special case, and from looking
at the flow in fs/ioctl.c I'm pretty sure FIONBIO never gets handed to
the chardev ioctl methods..



\
 
 \ /
  Last update: 2009-02-08 10:05    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog