-
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
fix #3963: allow snapdir=disabled
to prevent automounts
#15891
fix #3963: allow snapdir=disabled
to prevent automounts
#15891
Conversation
I've had this on my wishlist for years, thank you. |
de5564c
to
1d8663e
Compare
fixed an error in the test property values list, should clear up the send test failure |
1d8663e
to
1838c4a
Compare
minimized the changes now that the inode for |
in some environments, just making the .zfs control dir hidden from sight might not be enough. in particular, the following scenarios might warrant not allowing access at all: - old snapshots with wrong permissions/ownership - old snapshots with exploitable setuid/setgid binaries - old snapshots with sensitive contents introducing a new 'disabled' value that not only hides the control dir, but prevents access to its contents by returning ENOENT solves all of the above. the new property value takes advantage of 'iuv' semantics ("ignore unknown value") to automatically fall back to the old default value when a pool is accessed by an older version of ZFS that doesn't yet know about 'disabled' semantics. I think that technically the zfs_dirlook change is enough to prevent access, but preventing lookups and dir entries in an already opened .zfs handle might also be a good idea to prevent races when modifying the property at runtime. Fixes: openzfs#3963 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> .zfs: don't return .zfs inode if disabled Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
there might be room for improvement w.r.t. runtime changes of the snapdir value after something obtained a handle/descriptor, but this at least implements the basic support. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
to control wheter automatically mounted snapshots have the setuid mount option set or not. this could be considered a partial fix for one of the scenarios mentioned in desired. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
6007a8c
to
b5ba501
Compare
basic freebsd support for snapdir=disabled now added (as standalone commit). AFAICT, freebsd already disables suid for the automounts unconditionally, so that part is not needed on freebsd at all. I hope this is ready for review now :) |
snapdir=disabled
to prevent automountssnapdir=disabled
to prevent automounts
I think we should break the nosuid part out into its own PR, and it will need an implementation for FreeBSD as well (I am someone else from FreeBSD can help with that) |
it is its own commit already, so splitting it out should be easily done. AFAIU, the BSD code already doesn't mount snapshots with setuid enabled no matter what? see https://github.com/openzfs/zfs/blob/master/module/os/freebsd/spl/spl_vfs.c#L187 (which is called by the ctl dir code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fabian-Gruenbichler thanks for putting this together. Looks good to me, if we can rebase this I think we can move forward with merging it.
Replaced by #16587. @Fabian-Gruenbichler I hope you don't mind but I've rebased this and squashed your commits. If you could take a look that would be great. |
thanks and sorry for the radio silence, I've been out of action for the past ~2 weeks cause of an injury! the rebased version LGTM, FWIW. |
Motivation and Context
there is currently a gap as described in #3963 that allows potentially problematic access to snapshots via the
.zfs
control dir.Description
this PR fixes the issue via two avenues:
snapdir
that allows disabling access altogether, instead of just hidingnosuid
on Linux, to at least close the "exploit vulnerable setuid binaries" gap while still allowing snapshot access in generalHow Has This Been Tested?
tested that the new property value works as expected, including fallback on old ZFS versions. in case of a version mismatch (new kernel module, old userspace)
-
is displayed as value of the property.tested that the module parameter works as expected. existing mounts are not modified.
Types of changes
Checklist:
Signed-off-by
.