lkml.org 
[lkml]   [2005]   [Sep]   [24]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] open: O_DIRECTORY and O_CREAT together should fail
FromMiklos Szeredi <>
DateSat, 24 Sep 2005 07:52:06 +0200
> > Current behavior is inconsistent with documentation: 
> > open(..., O_DIRECTORY|O_CREAT) succeeds if file didn't exist, and
> > returned descriptor does not refer to a directory.
> > 
> > No other error value quite fits this case: 
> > 
> >   ENOTDIR - the file doesn't exist, so this is slightly misleading
> >   ENOENT - yes, but we asked for an O_CREAT so why wasn't it created
> > 
> > But EINVAL - invalid combination of flags, is quite good IMO.
> > 
> 
> We could be a bit screwed here.  If there are any apps out there which are
> using this combination, we just broke them.  Essentially the patch is
> assuming that nobody is currently using O_CREAT|O_DIRECTORY, but one day in
> the future someone will do that.

Well yes.  But I don't think anybody is using it, and if so they are
clearly breaking the rules in man open(2):

       O_DIRECTORY
              If pathname is not a directory, cause the open  to  fail.   This
              flag is Linux‐specific, and was added in kernel version 2.1.126,
              to avoid denial‐of‐service problems if opendir(3) is called on a
              FIFO  or  tape  device,  but  should  not be used outside of the
              implementation of opendir.

So if someone uses this outside of opendir() and uses it to create a
non-directory, I think they deserve to be screwed.

Miklos
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-09-24 07:58    [from the cache]
©2003-2008