-
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
require rollback permission when force receive #16991
base: master
Are you sure you want to change the base?
Conversation
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.
I am not very deep in this area, but it makes sense to me. I just worry that it changes existing behavior, that may upset many existing setups. And that permission is required even when no actual revert might be needed. Though I guess if the receiving side is mounted for writing with atime enabled, then simple traversal through it might change access times, requiring the rollback. And if user is forced to add -F
even for routine operations he may also get forced to add the permission, that may devalue the whole purpose, unless user in some way make receiving side read-only or not mounted.
Also for stream generated with send -R
aside of the rollback receive -F
might delete old snapshots and datasets, rename, may be something else. I guess those might already need additional permissions, that are just not documented now?
It is confusing to me that those functions are sharing the same -F
flag, and I actually discussed it with @ixhamza lately. I wonder if we could somehow better define the use cases to allow them in more restricted scenarios. For example, in case of backup server, I don't see a problem in receive able to rollback if only to the last snapshot, without any older snapshots deletion, that could be a part of an attack on backup server, while backup server does not care about local changes after the last snapshot. rollback
command actually has an -r
option to allow snapshots deletion. I wonder if that already requires destroy permission, or it is another bad design example.
True, I generally run backup server with
Again, true, but for such a potentially destructive operation
Unless I am missing something, checked permissions as defined by
I agree in principle, but the current situation is bad enough that should be corrected as soon a possible. As things are now, a malicious send can actually destroy snapshots on the receiving side without any specific rollback/destroy permission. Any more fine-grained behavior (ie: do not require rollback permission for rolling back last snapshot only) depends on the inspection of the receive stream itself - which, as far I know, happens after permission checking. So, while such detailed check would be ideal, I do not see any simple means to implement it. |
AFAIK user-space
We could add less aggressive forms of |
I just tried with
I don't feel that adding a less aggressive form of
It would be great, but I don't know if/how this fits in the current code, or how much time would be needed to add this kind of checks. |
Why prerequisite? It could be done same time or even unrelated. If you make
I am not trying to diminish the seriousness of the issue, but with all due respect I guess the issue must have existed for decades. Lets spend a week or two on thinking without extra rush. |
Sure. What I meant to say is that, in order for the (hypothetical)
If preserving compatibility with current behavior is required, how do you feel about a tunable to enable/disable the added check?
I agree, and thanks for you feedback. This PR is about a simple fix, but I am all for a better solution if possible. |
One of the problems here is that replication is often done through SSH, and the receive command is supplied by the sender. It means all the senders using |
@shodanshok - There is also a path that could delete a snapshot during an incremental receive even before performing the actual zfs receive operation if some destination snapshot does not match with the send stream. This requires destroy permissions, however. The following script now errors out due to missing rollback permission after your patch, but it still deletes
|
Thanks for pointing out that. If I understand it correctly, an explicit |
Yes, destroy permission is required. Though failing to receive the incremental stream but still able to destroy the snapshot sounds confusing. |
Do you think it would be better to check for rollback or destroy privileges, so that if destroy is allowed, then receive can continue? On the other hand, requiring explicit destroy/rollback permissions does not seems wrong to me. |
For a note, I brought this topic up on the yesterday's OpenZFS Leadership Meeting. The video should probably be on YouTube "soon". In general, consensus predictably was that breaking compatibility without warning is bad. It should likely be spread over at least couple releases, while alternatives in forms of new flags and permissions are provided to allow users to migrate before old functionality is blocked, if needed. I personally don't mind if some module parameter can force it sooner if user desire, but it should not be a primary solution. |
Force receive (zfs receive -F) can rollback or destroy snapshots and file systems that do not exist on the sending side (see zfs-receive man page). This means an user having the receive permission can effectively delete data on receiving side, even if such user does not have explicit rollback or destroy permissions. This patch add the rollback permission requirement for force receive. To avoid changing current default behavior, a new zfs_recv_perm tunable is introduced. When set to 0 (default) the new permission check is disabled. When set to 1 rollback permission requirement is enabled. Fixes openzfs#16943 Signed-off-by: Gionatan Danti <[email protected]>
907d712
to
c3a7dba
Compare
Thanks for discussing this issue. I added a new |
ZFS_MODULE_PARAM(zfs, zfs_, recv_perm, INT, ZMOD_RW, | ||
"Force receive (-F) requires rollback permission"); |
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.
The name seems not very descriptive.
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.
Any suggestion?
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.
I can't think if everything. ;) On a quick look I see we already have a vfs.zfs.recv.*
section (in FreeBSD terms). So may be something like vfs.zfs.recv.check_perm_on_force
?
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.
As linux seems to use zfs_recv_*
, and as some checks are already done by current code, what about zfs_recv_force_need_perm
? Otherwise, I happily use your suggestion above.
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.
OK. Just "need" or "needs"?
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.
"needs" seems better, I will use zfs_recv_force_needs_perm
If breaking existing setups is an issue, an alternative to the tunable might be to add a new permission named, e.g., |
@randomnetcat Yes, that is kind of what I meant with "while alternatives in forms of new flags and permissions are provided". I see it as splitting |
Ah, got it. Makes sense. |
I like something as an "append" permission. @amotin do you think that adding a specific |
I am not sure I like that the shortest and the most obvious permission name means more than necessary (includes rollback variants), but it would be the least invasive change for the existing users and sure better than any tunables. I'd be fine with it (it must be properly documented), but I would be glad to hear more opinions. But as I mentioned above there are two cases of rollback: to the last snapshot and deleting some snapshots. I think we should investigate that area too while we are at this to make sure things are consistent. |
Force receive (zfs receive -F) can rollback or destroy snapshots and file systems that do not exist on the sending side (see zfs-receive man page). This means an user having the receive permission can effectively delete data on receiving side, even if such user does not have explicit rollback or destroy permissions.
This patch add the rollback permission requirement for force receive. To avoid changing current default behavior, a new
zfs_recv_perm
tunable is introduced. When set to 0 (default) the new permission check is disabled. When set to 1 rollback permission requirement is enabled.Fixes #16943
Motivation and Context
Description
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.