Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 907d712

Browse files
committedJan 26, 2025·
require rollback permission when force receive
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 forced receive. Fixes #16943 Signed-off-by: Gionatan Danti <[email protected]>
1 parent 3420571 commit 907d712

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎man/man8/zfs-allow.8

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ load-key subcommand Allows loading and unloading of encryption key (see \fBzfs l
207207
change-key subcommand Allows changing an encryption key via \fBzfs change-key\fR.
208208
mount subcommand Allows mounting/umounting ZFS datasets
209209
promote subcommand Must also have the \fBmount\fR and \fBpromote\fR ability in the origin file system
210-
receive subcommand Must also have the \fBmount\fR and \fBcreate\fR ability
210+
receive subcommand Must also have the \fBmount\fR and \fBcreate\fR ability; must also have the \fBrollback\fR ability if \fBzfs receive -F\fR (force receive) is used.
211211
release subcommand Allows releasing a user hold which might destroy the snapshot
212212
rename subcommand Must also have the \fBmount\fR and \fBcreate\fR ability in the new parent
213213
rollback subcommand Must also have the \fBmount\fR ability

‎module/zfs/zfs_ioctl.c

+5
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,11 @@ zfs_secpolicy_recv(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
908908
ZFS_DELEG_PERM_MOUNT, cr)) != 0)
909909
return (error);
910910

911+
/* Forced receive can rollback or destroy snapshots */
912+
if (zc->zc_guid && (error = zfs_secpolicy_write_perms(zc->zc_name,
913+
ZFS_DELEG_PERM_ROLLBACK, cr)) != 0)
914+
return (error);
915+
911916
return (zfs_secpolicy_write_perms(zc->zc_name,
912917
ZFS_DELEG_PERM_CREATE, cr));
913918
}

0 commit comments

Comments
 (0)
Please sign in to comment.