Skip to content

Conversation

@tidjean
Copy link

@tidjean tidjean commented Oct 24, 2025

Add defensive validation to prevent kernel panics when corrupted space map data is encountered during pool import. Instead of panicking, the system now logs corruption and continues in read-only mode.

Changes:

  • space_map.c: Add bounds checking in space_map_load_callback to skip zero-sized and out-of-bounds entries
  • range_tree.c: Add defensive check in zfs_range_tree_remove_impl to detect corrupted segment bounds and recover gracefully

Motivation and Context

Description

How Has This Been Tested?

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:

Add defensive validation to prevent kernel panics when corrupted
space map data is encountered during pool import. Instead of
panicking, the system now logs corruption and continues in
read-only mode.

Changes:
- space_map.c: Add bounds checking in space_map_load_callback to
  skip zero-sized and out-of-bounds entries
- range_tree.c: Add defensive check in zfs_range_tree_remove_impl
  to detect corrupted segment bounds and recover gracefully

Signed-off-by: Tidjean <tidjean@gmail.com>
@amotin
Copy link
Member

amotin commented Oct 24, 2025

On a quick look this looks like a pretty narrow solution. Please see this discussion: #17094 (comment).

alek-p added a commit to alek-p/openzfs that referenced this pull request Jan 12, 2026
…p corruption

- Add configuration check for simple_fillattr which replaces generic_fillattr in Linux 6.13.

- Update vfs_compat.h and zpl_ctldir.c to use simple_fillattr when available.

- Update zfs_vnops_os.c to support HAVE_SIMPLE_FILLATTR.

- Make zfs_range_tree_remove_impl and space_map_load_callback robust against corruption by using zfs_panic_recover instead of panic or assertions.

- This addresses issues openzfs#18094, openzfs#17870, openzfs#17812.
alek-p added a commit to alek-p/openzfs that referenced this pull request Jan 12, 2026
…p corruption

- Add configuration check for simple_fillattr which replaces generic_fillattr in Linux 6.13.

- Update vfs_compat.h and zpl_ctldir.c to use simple_fillattr when available.

- Update zfs_vnops_os.c to support HAVE_SIMPLE_FILLATTR.

- Make zfs_range_tree_remove_impl and space_map_load_callback robust against corruption by using zfs_panic_recover instead of panic or assertions.

- This addresses issues openzfs#18094, openzfs#17870, openzfs#17812.

closes #14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants