-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sticky bit causes operation not permitted when exported over NFS #6889
Comments
As of two releases ago, I've also been experiencing similar issues with sticky bits. For me it's not over nfs though - I'm getting operation not permitted errors with .NET core applications that implement the File.OpenRead method. Only affects files with sticky bit and does not occur if the underlying filesystem is xfs - only started happening 2 releases ago, the files are unchanged and nothing else has changed on my end configuration-wise. I'm on CentOS 7.4. |
I can confirm this happening with the jonathonf zfsonlinux packages on ubuntu-xenial with a stock kernel (4.4) as well, when trying to access an nfs share backed by zfs. |
Should have mentioned - I'm on the stock kernel also. |
Playing some more on my testing system shows the following (/srv/startmail is a mounted share, backed by zfs on the server):
So if either the directory or the thing to be removed is owned by root, removal is allowed. |
Also affecting the setgid bit on directories. |
Possibly the same issue as #6800 ? |
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the desired behavior. As described in the block comment, permission should be granted when the entry is a regular file and you have write access. S_ISREG should have been used here instead of S_ISDIR. Signed-off-by: Brian Behlendorf <[email protected]> Issue openzfs#6889
I've open PR #6910 with a proposed fix for this issue. Independent verification that the patch resolves the issue as intended would be great. |
Thanks for this patch, I'll try it out tomorrow or the day after! (It's about midnight in my timezone) |
PR #6910 fixes the issue for me. Thanks! |
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the desired behavior. As described in the block comment, permission should be granted when the entry is a regular file and you have write access. S_ISREG should have been used here instead of S_ISDIR. Signed-off-by: Brian Behlendorf <[email protected]> Issue openzfs#6889
This fix appears to be wrong - it does fix this specific case, but there's a regression:
(client is a vm which has nfs-mounted a share on a server running zfs with this patch) Note that running rmdir with this user on the server side works as expected - that is, it removes the dir. |
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the intended behavior. As described in the block comment, the intended behavior is that permission should be granted when the entry is a regular file and you have write access. That is, S_ISREG should have been used instead of S_ISDIR. Restricting permission to regular files made good sense for older systems where setting the bit on executable files would instruct the system to save the program's text segment on the swap device. On modern systems this behavior has been replaced by the sticky bit acting as a restricted deletion flag and the plain file restriction has been relaxed. Signed-off-by: Brian Behlendorf <[email protected]> Issue openzfs#6889
@jap thanks for verifying the updated patch. I've refreshed it again to relax the file type restriction which is no longer correct when it's used in the modern context as a restricted deletion flag. |
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the intended behavior. As described in the block comment, the intended behavior is that permission should be granted when the entry is a regular file and you have write access. That is, S_ISREG should have been used instead of S_ISDIR. Restricting permission to regular files made good sense for older systems where setting the bit on executable files would instruct the system to save the program's text segment on the swap device. On modern systems this behavior has been replaced by the sticky bit acting as a restricted deletion flag and the plain file restriction has been relaxed. Signed-off-by: Brian Behlendorf <[email protected]> Issue openzfs#6889
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the intended behavior. As described in the block comment, the intended behavior is that permission should be granted when the entry is a regular file and you have write access. That is, S_ISREG should have been used instead of S_ISDIR. Restricting permission to regular files made good sense for older systems where setting the bit on executable files would instruct the system to save the program's text segment on the swap device. On modern systems this behavior has been replaced by the sticky bit acting as a restricted deletion flag and the plain file restriction has been relaxed. Signed-off-by: Brian Behlendorf <[email protected]> Issue openzfs#6889
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the intended behavior. As described in the block comment, the intended behavior is that permission should be granted when the entry is a regular file and you have write access. That is, S_ISREG should have been used instead of S_ISDIR. Restricting permission to regular files made good sense for older systems where setting the bit on executable files would instruct the system to save the program's text segment on the swap device. On modern systems this behavior has been replaced by the sticky bit acting as a restricted deletion flag and the plain file restriction has been relaxed. Signed-off-by: Brian Behlendorf <[email protected]> Issue openzfs#6889
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the intended behavior. As described in the block comment, the intended behavior is that permission should be granted when the entry is a regular file and you have write access. That is, S_ISREG should have been used instead of S_ISDIR. Restricting permission to regular files made good sense for older systems where setting the bit on executable files would instruct the system to save the program's text segment on the swap device. On modern systems this behavior has been replaced by the sticky bit acting as a restricted deletion flag and the plain file restriction has been relaxed. Reviewed-by: George Melikov <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #6889 Closes #6910
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the intended behavior. As described in the block comment, the intended behavior is that permission should be granted when the entry is a regular file and you have write access. That is, S_ISREG should have been used instead of S_ISDIR. Restricting permission to regular files made good sense for older systems where setting the bit on executable files would instruct the system to save the program's text segment on the swap device. On modern systems this behavior has been replaced by the sticky bit acting as a restricted deletion flag and the plain file restriction has been relaxed. Reviewed-by: George Melikov <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes openzfs#6889 Closes openzfs#6910
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the intended behavior. As described in the block comment, the intended behavior is that permission should be granted when the entry is a regular file and you have write access. That is, S_ISREG should have been used instead of S_ISDIR. Restricting permission to regular files made good sense for older systems where setting the bit on executable files would instruct the system to save the program's text segment on the swap device. On modern systems this behavior has been replaced by the sticky bit acting as a restricted deletion flag and the plain file restriction has been relaxed. Reviewed-by: George Melikov <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes openzfs#6889 Closes openzfs#6910
When zfs_sticky_remove_access() was originally adapted for Linux a typo was made which altered the intended behavior. As described in the block comment, the intended behavior is that permission should be granted when the entry is a regular file and you have write access. That is, S_ISREG should have been used instead of S_ISDIR. Restricting permission to regular files made good sense for older systems where setting the bit on executable files would instruct the system to save the program's text segment on the swap device. On modern systems this behavior has been replaced by the sticky bit acting as a restricted deletion flag and the plain file restriction has been relaxed. Reviewed-by: George Melikov <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes openzfs#6889 Closes openzfs#6910
System information
Describe the problem you're observing
When exporting zfs over nfs, setting the sticky bit on a directory gives access denied incorrectly when trying to remove files. On the same system I tested exporting an xfs file system and it did not have the same issue.
Supposedly this changed sometime in the last few months, but we didn't notice this until today. We rebuilt the zpool a few weeks ago, if that's relevant.
Selinux is already permissive.
Describe how to reproduce the problem
Have an nfs server setup and running and change directory to a zfs filesystem, then run the following as root.
The
rm testmount/sticky/foo
fails withbut trying to rm directly at testexport succeeds.
If you run these same commands on a different underlying file system (I've only tested xfs) gives no error.
Include any warning/errors/backtraces from the system logs
I'm happy to include any logs you think are relevant, but there was nothing in selinux logs (selinux is permissive), messages, secure, or dmesg.
Thanks in advance.
The text was updated successfully, but these errors were encountered: