Skip to content

zfs allow send:encrypted #17543

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

allanjude
Copy link
Contributor

Motivation and Context

Allow delegation of permission to ONLY send raw encrypted replication.
This allows automated replication processes to only have permission to the raw replication stream, without the ability to send the decrypted version of the stream.

Description

A new zfs allow permission: send:encrypted, similar to the existing send permission, but only allows send with the --raw flag. Any attempt to send without --raw will be denied.
The existing send permission is unchanged, so retains the ability to send either way.

How Has This Been Tested?

Manually, and with new ZTS additions

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@snajpa
Copy link
Contributor

snajpa commented Jul 17, 2025

Why can't it be send:raw, when it is in fact about just that? Raw by far doesn't imply encrypted.

@amotin
Copy link
Member

amotin commented Jul 17, 2025

Why can't it be send:raw, when it is in fact about just that? Raw by far doesn't imply encrypted.

Outside of encryption it makes no sense to restrict it. But I agree that raw sounds consistent with the zfs send terminology.

@allanjude
Copy link
Contributor Author

Why can't it be send:raw, when it is in fact about just that? Raw by far doesn't imply encrypted.

The permission was originally called sendraw and we changed it to have the : etc and match what other had done with receive: append etc.

If there is a preference to call it send:raw that is fine with us, we'll do the search/replace with the next push to solve the other issues.

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Jul 18, 2025
allanjude and others added 2 commits July 21, 2025 15:17
A new `zfs allow` permissions that ONLY allows sending replication
streams in raw (encrypted) mode, so encrypted data will not be
decrypted as part of the replication process.

Sponsored-by: Klara, Inc.
Sponsored-by: Karakun AG
Co-authored-by: JT Pennington <[email protected]>
Signed-off-by: Allan Jude <[email protected]>
Create tests for the new send:encrypted permission

Sponsored-by: Klara, Inc.
Sponsored-by: Karakun AG
Signed-off-by: JT Pennington <[email protected]>
@allanjude
Copy link
Contributor Author

Fixed a missing line continuation that failed to install some of the tests

Comment on lines +707 to +714
if (rawok == B_TRUE) {
error = zfs_secpolicy_write_perms_ds(zc->zc_name, ds,
ZFS_DELEG_PERM_SENDRAW, cr);
}
if (rawok == B_FALSE || error != 0) {
error = zfs_secpolicy_write_perms_ds(zc->zc_name, ds,
ZFS_DELEG_PERM_SEND, cr);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be subjective, but I'd first verified ZFS_DELEG_PERM_SEND and then, if needed, more specific ZFS_DELEG_PERM_SENDRAW.

Comment on lines +25 to +26
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what part here is from Sun? ;)


# Create staff group and add two user to it
log_must add_group $STAFF_GROUP
if ! id $STAFF1 > /dev/null 2>&1; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need to check this. At least add_user_freebsd already checks it inside. Wonder is Linux' useradd does it.

log_note "Create a user called 'testerbot'."
if ! id testerbot > /dev/null 2>&1; then
user_added="TRUE"
log_must add_user $STAFF_GROUP testerbot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use some $STAFF1 created in setup?

# 4. Write random data to the encrypted dataset
# 5. Snapshot the dataset
# 6. As root: attempt a send and raw send (both should succeed)
# 7. As user: attempt a send and raw send (both should fail, no permission)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any log_mustnot in this file. Is the description not accurate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants