Always perform bounds-checking in metaslab_free_concrete

The vd->vdev_ms access can overflow due to on-disk corruption, not just
due to programming bugs.  So it makes sense to check its boundaries even
in production builds.

Sponsored by:	ConnectWise
Reviewed by: Alek Pinchuk <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by:	Alan Somers <[email protected]>
Closes #17136
This commit is contained in:
Alan Somers authored and GitHub committed 2025-03-19 11:24:43 -04:00
1 parent 3cd9934a48
commit d033f26765
1 file changed
+3 -2
+3 -2
View File
@@ -5406,12 +5406,13 @@ metaslab_free_concrete(vdev_t *vd, uint64_t offset, uint64_t asize,
{
metaslab_t *msp;
spa_t *spa = vd->vdev_spa;
int m = offset >> vd->vdev_ms_shift;
ASSERT(vdev_is_concrete(vd));
ASSERT3U(spa_config_held(spa, SCL_ALL, RW_READER), !=, 0);
ASSERT3U(offset >> vd->vdev_ms_shift, <, vd->vdev_ms_count);
VERIFY3U(m, <, vd->vdev_ms_count);
msp = vd->vdev_ms[offset >> vd->vdev_ms_shift];
msp = vd->vdev_ms[m];
VERIFY(!msp->ms_condensing);
VERIFY3U(offset, >=, msp->ms_start);