public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Race in open(O_CREAT|O_EXCL) and network filesystem
@ 2002-07-28 16:52 Jan Hudec
  2002-07-29 11:45 ` Trond Myklebust
  2002-07-29 11:50 ` Neil Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Hudec @ 2002-07-28 16:52 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel

Hi all,

maybe I'm blind, but I think there is a race featuring
open(O_CREAT|O_EXCL) and nfs or any other network fs.

What may happen is:

client A: open_namei looks up the inode
	driver queries server and gets ENOENT
client B: open_namei looks up the inode
	driver queries server and gets ENOENT
client A: open_namei calls create method
	driver requests file to be created and is successful
client B: open_namei calls create method
	dirver requests file to be created and since it does not know,
	cant specify exclusion, thus is succesful
client A: open_namei does no more checks and thus open succeeds
client B: open succeeds too here - and it shouldn't

Since many applications rely on this working correctly (especialy
mailboxes are locked using exclusive creates and mounting them over NFS
is quite common).

So, can someone please answer:

1) Is there some reason this can't happen that I overlooked?
2) If it is a problem (comment in NFS suggest so), I can see two ways of
handling this. Either pass the flags to the create method, or restart
the open when create returns EEXISTS. Which one would be prefered?
3) How to fix NFS to add exclude flag to the NFSv3 request?

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-07-29 23:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-28 16:52 Race in open(O_CREAT|O_EXCL) and network filesystem Jan Hudec
2002-07-29 11:45 ` Trond Myklebust
2002-07-29 11:50 ` Neil Brown
2002-07-29 15:02   ` Andreas Dilger
2002-07-29 23:04     ` Neil Brown
2002-07-29 23:44       ` Andreas Dilger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox