Skip to content
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

RFC: Don't panic on unencrypted block in encrypted dataset. #15677

Merged
merged 1 commit into from Dec 21, 2023

Conversation

chrisperedun
Copy link
Contributor

@chrisperedun chrisperedun commented Dec 15, 2023

Motivation and Context

While #15465 closes the situation of block cloning creating unencrypted records in encrypted datasets, any existing data that was cloned prior to this still causes panic on read. Setting zfs_recover=1 bypasses the panic but is a bit of a blunt instrument as it avoids all panics.

Since the code paths here already call spa_log_error and return EIO for the read, the actual unencrypted data shouldn't ever be sent upstream, so this shouldn't introduce a vulnerable scenario where deliberately injected data would be returned. We can perhaps be louder about the alert, but this at least prevents users from having accidentally populated an encrypted dataset with files that could crash their system.

Description

Removed the call to zfs_panic_recover at dbuf.c#L1637 and dmu_send.c#L1127

How Has This Been Tested?

Copied a test file from unencrypted to encrypted dataset using cp, confirmed that reading with dd results in a crash, made change, repeated process and received no crash on read, with application receiving an I/O error.

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)
  • 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:

@chrisperedun chrisperedun marked this pull request as ready for review December 16, 2023 19:20
Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

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

While formally it is a pool corruption and should not happen, I agree that it makes no sense to crash the system on it. As these are reads, the errors there should be handled clean and unlike some space map corruptions, for example, should not cause more problems if system is not crashed. May be we could leave some ASSERT() there to ease the debugging of debug builds, but we should not panic production boxes on this.

Looking through the other zfs_panic_recover() use cases I see couple more questionable ones. I wonder if we should introduce some printf()-like variation of ASSERT() to report arbitrary panic messages on debug builds, or just use PANIC() wrapped in ZFS_DEBUG.

@amotin amotin added Status: Code Review Needed Ready for review and testing Status: Design Review Needed Architecture or design is under discussion labels Dec 18, 2023
@chrisperedun chrisperedun changed the title RFC: When encountering an unencrypted block in encrypted dataset, don't panic, as we're already returning an error. RFC: Don't panic on unencrypted block in encrypted dataset. Dec 18, 2023
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

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

Agreed we should gracefully handle these by default. Can you just address the two style warnings and force update the PR. You can run make checkstyle locally to make sure it's happy.

error: commit subject over 72 characters
error: missing "Signed-off-by"
error: commit message body contains line over 72 characters

@chrisperedun chrisperedun force-pushed the dontpanic branch 2 times, most recently from 3ba91d6 to 2839199 Compare December 20, 2023 22:42
While 763ca47 closes the situation of block cloning creating
unencrypted records in encrypted datasets, existing data still causes
panic on read. Setting zfs_recover bypasses this but at the cost of
potentially ignoring more serious issues.

Signed-off-by: Chris Peredun <chris.peredun@ixsystems.com>
@chrisperedun
Copy link
Contributor Author

Style warnings addressed, thank you.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing Status: Design Review Needed Architecture or design is under discussion labels Dec 21, 2023
@behlendorf behlendorf merged commit 5a49156 into openzfs:master Dec 21, 2023
22 of 25 checks passed
mmatuska pushed a commit to mmatuska/zfs that referenced this pull request Dec 26, 2023
While 763ca47 closes the situation of block cloning creating
unencrypted records in encrypted datasets, existing data still causes
panic on read. Setting zfs_recover bypasses this but at the cost of
potentially ignoring more serious issues.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Peredun <chris.peredun@ixsystems.com>
Closes openzfs#15677
mmatuska pushed a commit to mmatuska/zfs that referenced this pull request Dec 27, 2023
While 763ca47 closes the situation of block cloning creating
unencrypted records in encrypted datasets, existing data still causes
panic on read. Setting zfs_recover bypasses this but at the cost of
potentially ignoring more serious issues.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Peredun <chris.peredun@ixsystems.com>
Closes openzfs#15677
mmatuska pushed a commit to mmatuska/zfs that referenced this pull request Dec 27, 2023
While 763ca47 closes the situation of block cloning creating
unencrypted records in encrypted datasets, existing data still causes
panic on read. Setting zfs_recover bypasses this but at the cost of
potentially ignoring more serious issues.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Peredun <chris.peredun@ixsystems.com>
Closes openzfs#15677
mmatuska pushed a commit to mmatuska/zfs that referenced this pull request Dec 27, 2023
While 763ca47 closes the situation of block cloning creating
unencrypted records in encrypted datasets, existing data still causes
panic on read. Setting zfs_recover bypasses this but at the cost of
potentially ignoring more serious issues.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Peredun <chris.peredun@ixsystems.com>
Closes openzfs#15677
@chrisperedun chrisperedun deleted the dontpanic branch January 3, 2024 21:01
behlendorf pushed a commit that referenced this pull request Jan 9, 2024
While 763ca47 closes the situation of block cloning creating
unencrypted records in encrypted datasets, existing data still causes
panic on read. Setting zfs_recover bypasses this but at the cost of
potentially ignoring more serious issues.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Peredun <chris.peredun@ixsystems.com>
Closes #15677
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Mar 13, 2024
While 763ca47 closes the situation of block cloning creating
unencrypted records in encrypted datasets, existing data still causes
panic on read. Setting zfs_recover bypasses this but at the cost of
potentially ignoring more serious issues.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Peredun <chris.peredun@ixsystems.com>
Closes openzfs#15677
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Mar 13, 2024
While 763ca47 closes the situation of block cloning creating
unencrypted records in encrypted datasets, existing data still causes
panic on read. Setting zfs_recover bypasses this but at the cost of
potentially ignoring more serious issues.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Peredun <chris.peredun@ixsystems.com>
Closes openzfs#15677
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants