public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ftp.linux.org.uk>
To: Roland Dreier <rdreier@cisco.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [RESEND] file operations: release can race with read/write?
Date: Wed, 17 Oct 2007 20:33:21 +0100	[thread overview]
Message-ID: <20071017193320.GK8181@ftp.linux.org.uk> (raw)
In-Reply-To: <adaodexh9uz.fsf@cisco.com>

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.

  parent reply	other threads:[~2007-10-17 19:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-16 18:53 file operations: release can race with read/write? Roland Dreier
2007-10-17 18:30 ` [RESEND] " Roland Dreier
2007-10-17 19:16   ` Andrew Morton
2007-10-17 22:06     ` Roland Dreier
2007-10-17 19:27   ` Al Viro
2007-10-17 19:33   ` Al Viro [this message]
2007-10-17 22:10     ` Roland Dreier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071017193320.GK8181@ftp.linux.org.uk \
    --to=viro@ftp.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdreier@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox