nfs: opening a file with O_WRONLY|O_CREAT flags can result in permission denied error
Tian Lan <[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
Hello,
We recently noticed there is a behavior change w.r.t opening a file
with the O_WRONLY|O_CREAT flags over the NFSv3 protocol after upgrading
the kernel from 6.1 LTS to 6.12 LTS. From the packets capturing, it seems
like the kernel would now issue an additional CREATE rpc call to the
remote NFS server regardless if the target file pre-exists or not.
The CREATE rpc request could return an EACCES error if the client only has
the write permission to the pre-existing file but no write permission on
the directory containing the pre-existing file. This causes the openat
syscall to fail with permission denied error which is not expected.
After doing some code tracing, it seems like the new behavior was
introduced as part of 7c6c5249f061 ("NFS: add atomic_open for NFSv3 to
handle O_TRUNC correctly."). We would like to confirm if the current
behavior that we are observing with the 6.12 kernel is expected given
that the new behavior breaks existing user's application code. We
currently have a workaround by explicitly remove the O_CREAT flag when
opening a pre-existing file for write, but would still prefer not have
to apply this workaround when upgrading to the newer kernel.
Best,
Tian