[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20071017193320.GK8181@ftp.linux.org.uk>
Date: Wed, 17 Oct 2007 20:33:21 +0100
From: Al Viro <viro@....linux.org.uk>
To: Roland Dreier <rdreier@...co.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org
Subject: Re: [RESEND] file operations: release can race with read/write?
On Wed, Oct 17, 2007 at 11:30:44AM -0700, Roland Dreier wrote:
> static unsigned long flag;
>
> static int cw_open(struct inode *inode, struct file *filp)
> {
> return 0;
> }
>
> static int cw_close(struct inode *inode, struct file *filp)
> {
> clear_bit(1, &flag);
>
> msleep(1);
>
> if (test_and_set_bit(1, &flag))
> printk(KERN_ERR "Write raced with close?\n");
Of _course_ you can trigger that - just open two files and have write
on one of them while another gets closed.
That is certainly possible, but it has nothing whatsoever with the
race you've described - you have two different objects and method
call on one of them might happen when destructor is called on another.
You have protection against ->release() for a struct file called
while you are in ->write() for _same_ struct file.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists