-
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
chown erases file permissions for v2-v4 filesystems #1264
Comments
I'm unable to reproduce this under RHEL6.2 with 0.6.0-rc14. Try reproducing this strange behavior in an ext4 file system, it may not be due to ZFS.
|
@behlendorf He mentioned on zfs-discuss that it doesn't happen on ext4. Also he's running FC18 kernel-3.7.5-201.fc18.x86_64 so you may want to try it in your vm. |
I regularly use chown on Gentoo Linux. I have yet to see this happen. @db48x Would you try installing Gentoo Prefix on your system and using its chown? |
@behlendorf Did you try with Here's the strace info he posted to the list.
|
I notice from the ls output in his mailing list post that the file has an SELinux ACL.
Perhaps that is a relevant detail. @db48x what does |
Certainly:
Looks ok to me though. Selinux is actually in permissive mode, because it stopped working (not sure why I upgraded to FC18, honestly). This temp directory is in my home directory, so it ought to be labelled home_dir_t or some-such, but restorecon thinks that it is fine the way it is. I've spent several hours over the past couple of weekends trying to figure out how selinux really works, to no avail. If that turns out to be the cause then I won't mind having been the canary in the coal mine. Let me look into this Gentoo Prefix thing next. |
Gento Prefix failed to build GCC; some compile error. An interesting idea though. |
I can't reproduce it either on FC18 with selinux enabled (permissive or enforcing). Just as a sanity check, what does |
@db48x Would you make a Gentoo chroot and see if you can reproduce this with Gentoo's chmod? You should be able to make one by doing something like the following:
Now try to reproduce your issue. After you are finished, you can exit the chroot and destroy it by doing:
|
Using the gentoo binaries works fine:
I don't have an strace in here though, so I can't peek in and see what's different. |
I notice there's no SELinux ACL indicated in your ls output for this test. Did you try it with an SELinux ACL? I'd still like to see What other permutations of your reproducer have you tried? Does it depend on directory, file name, or user? Can you reproduce it in a newly created filesystem? |
The file does have an selinux ACL, but the gentoo ls doesn't see it.
oh, and
Ahh, the question about new filesystems is good; I hadn't tried that. If I do this in my newly-created gentoo filesystem using the normal tools, it doesn't happen:
Let me try again when I don't have to be root:
So that must mean that something is wrong with my current filesystem. Hard to say whether that's a result of the ACL, of xattrs in general (which I enabled long ago; I couldn't use most of the filesystems in this pool for a while because until a few versions ago zfs would lock up while reading them), or of something else. Can you suggest a way to compare the new and the old filesystems to see how they differ on disk? |
My first suspicion would be that it's related to having |
Yes, I've created the file anew for each test. |
Also, the tank/temp filesystem I just created has xattr=sa, since it inherited it from tank... Oh, but it doesn't. I turned xattrs off entirely for a test just before I went to sleep last night, so tank/temp doesn't have xattrs. Let me do some more testing. |
So it doesn't happen on new filesystems with or without xattrs, but it does happen on my old filesystem, with or without xattrs enabled. |
Ah, the file system version seems to be the key. I can reproduce the issue if I create a pool with pool version 23, file system version 4, or lower. Did you upgrade your pool version at some point? That would explain why your tank filesystem, which has version=4, has the issue but new filesystems with version=5 don't. |
Yes, I upgraded to my current pool and filesystem versions some time ago, long before I noticed this bug. |
Alas, if only that were the case. I tried it last night, but it didn't fix the problem. |
Ahh. I had a brainwave, and did a zfs upgrade this time instead of a zpool upgrade. That does indeed fix it; this only happens on filesystem version 4. Thanks Ned, for your help tracking this down :) |
Thanks for the update. There's clearly an issue here so I want to leave the bug open. But since it only impacts zfs v4 file systems (which are fairly rare these days) and the fix is to upgrade them to v5 we're going to treat this one as a low priority. |
FYI this also affects zfs v3 file systems. Problem is gone after zfs upgrade to v5. Couple of search terms to make others find this bug: npm install fail -EPERM zfs homedir. |
This still happens to me on git HEAD with the pool upgraded to latest version. :-( |
Since this seems to only occur with filesystem four, not five, should we close this as not-applicable, or rename it to something that indicate that it only happens when fs=4? |
I've updated the description to reflect that this only impacts version 4 filesystems. But there is a real bug here which should be fixed even if very few people run version 4 filesystems there days. |
I saw this also on zfs v3, see my comment above. |
@clefru Thanks for keeping me honest, I've updated the description again. |
I just ran into this problem with zfs v2, zpool v28, after upgrading from 30b92c1 to whatever the "0.6.3-1~wheezy" Debian packages are based on. |
I've updated the title accordingly. The same fix should apply, upgrade the zfs filesystem version if you can. |
@behlendorf Yeah, @DeHackEd remembered this bug when I was panicking on IRC and suggested upgrading right away. Everything is at v5 now, and haven't experienced it again so far. Will report back if I notice any different. |
In zfs_acl_chown_setattr(), the zfs_mode_comput() function is used to create a traditional mode value based on an ACL. If no ACL exists, this processing shouldn't be done. Problems caused by this were most evident on version 4 filesystems which not only don't have system attributes, but also don't typically have ACLs. On such filesystems, performing a chown() operation could have the effect of dirtying the mode bits in memory but not on the file system as follows: # create a file with typical mode of 664 echo test > test chown anyuser test ls -l test and the mode will show up as all zeroes. Unmounting/mounting and/or exporting/importing the filesystem will reveal the proper mode again. Fixes openzfs#1264
In zfs_acl_chown_setattr(), the zfs_mode_comput() function is used to create a traditional mode value based on an ACL. If no ACL exists, this processing shouldn't be done. Problems caused by this were most evident on version 4 filesystems which not only don't have system attributes, and also frequently have empty ACLs. On such filesystems, performing a chown() operation could have the effect of dirtying the mode bits in memory but not on the file system as follows: # create a file with typical mode of 664 echo test > test chown anyuser test ls -l test and the mode will show up as all zeroes. Unmounting/mounting and/or exporting/importing the filesystem will reveal the proper mode again. Fixes openzfs#1264
In zfs_acl_chown_setattr(), the zfs_mode_comput() function is used to create a traditional mode value based on an ACL. If no ACL exists, this processing shouldn't be done. Problems caused by this were most evident on version 4 filesystems which not only don't have system attributes, and also frequently have empty ACLs. On such filesystems, performing a chown() operation could have the effect of dirtying the mode bits in memory but not on the file system as follows: # create a file with typical mode of 664 echo test > test chown anyuser test ls -l test and the mode will show up as all zeroes. Unmounting/mounting and/or exporting/importing the filesystem will reveal the proper mode again. Fixes openzfs#1264
In zfs_acl_chown_setattr(), the zfs_mode_comput() function is used to create a traditional mode value based on an ACL. If no ACL exists, this processing shouldn't be done. Problems caused by this were most evident on version 4 filesystems which not only don't have system attributes, and also frequently have empty ACLs. On such filesystems, performing a chown() operation could have the effect of dirtying the mode bits in memory but not on the file system as follows: # create a file with typical mode of 664 echo test > test chown anyuser test ls -l test and the mode will show up as all zeroes. Unmounting/mounting and/or exporting/importing the filesystem will reveal the proper mode again. Signed-off-by: Tim Chase <tim@chase2k.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#1264
In zfs_acl_chown_setattr(), the zfs_mode_comput() function is used to create a traditional mode value based on an ACL. If no ACL exists, this processing shouldn't be done. Problems caused by this were most evident on version 4 filesystems which not only don't have system attributes, and also frequently have empty ACLs. On such filesystems, performing a chown() operation could have the effect of dirtying the mode bits in memory but not on the file system as follows: # create a file with typical mode of 664 echo test > test chown anyuser test ls -l test and the mode will show up as all zeroes. Unmounting/mounting and/or exporting/importing the filesystem will reveal the proper mode again. Signed-off-by: Tim Chase <tim@chase2k.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1264
Basically, chown breaks it, but only if the file is world-readable.
Edit: This happens with zfs filesystem version 4, not version 5.
[db48x@celebdil temp]$ ll
total 512
-rw-rw-r--. 1 db48x db48x 0 Feb 5 01:13 foo
[db48x@celebdil temp]$ chown db48x foo
[db48x@celebdil temp]$ ll
total 512
----------. 1 db48x db48x 0 Feb 5 01:13 foo
[db48x@celebdil temp]$ ll
total 512
-rw-rw----. 1 db48x db48x 0 Feb 5 01:13 foo
[db48x@celebdil temp]$ chown db48x foo
[db48x@celebdil temp]$ ll
total 512
-rw-rw----. 1 db48x db48x 0 Feb 5 01:13 foo
The text was updated successfully, but these errors were encountered: