Open with O_CREAT flag set fails to open existing files on non writable directories
commit526253456ad4e2b2136d470e651b1a400942a5db
authorSachin Prabhu <sprabhu@redhat.com>
Wed, 20 Apr 2011 12:09:35 +0000 (20 13:09 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 9 May 2011 23:04:45 +0000 (9 16:04 -0700)
tree5b5892aa7bcaf7bef66fd4e4b0b7adb618333e86
parent7377803f5859c2cda20baa95aa3f47102ed66a9a
Open with O_CREAT flag set fails to open existing files on non writable directories

commit 1574dff8996ab1ed92c09012f8038b5566fce313 upstream.

An open on a NFS4 share using the O_CREAT flag on an existing file for
which we have permissions to open but contained in a directory with no
write permissions will fail with EACCES.

A tcpdump shows that the client had set the open mode to UNCHECKED which
indicates that the file should be created if it doesn't exist and
encountering an existing flag is not an error. Since in this case the
file exists and can be opened by the user, the NFS server is wrong in
attempting to check create permissions on the parent directory.

The patch adds a conditional statement to check for create permissions
only if the file doesn't exist.

Signed-off-by: Sachin S. Prabhu <sprabhu@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/nfsd/vfs.c