validation of mode argument in open?

Bill Hawes (
Fri, 12 Dec 1997 17:48:54 -0500

While reviewing the handling of mkdir calls I noticed that the
open_namei() routine doesn't do any verification of the mode argument
before calling the fs create() operation. Unless I've missed it, the
calling path from the syscall down to open_namei() doesn't test the mode
either. In contrast, mknod() does validate the argument, and mkdir masks
away all but the permissions (though I think it should OR in S_IFDIR).

It was my understanding that the fs create() operation was intended only
for plain files, and that directory and device node creation (if
supported) should always go to the mkdir and mknod ops. If this is the
case, there should be a test somewhere in the open() code to make sure
the mode is valid (i.e. S_IFREG plus permissions).