Skip to content

Commit 7cc60af

Browse files
asomerstonyhutter
authored andcommitted
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 openzfs#17136
1 parent b0f2bcd commit 7cc60af

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

module/zfs/metaslab.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5406,12 +5406,13 @@ metaslab_free_concrete(vdev_t *vd, uint64_t offset, uint64_t asize,
54065406
{
54075407
metaslab_t *msp;
54085408
spa_t *spa = vd->vdev_spa;
5409+
int m = offset >> vd->vdev_ms_shift;
54095410

54105411
ASSERT(vdev_is_concrete(vd));
54115412
ASSERT3U(spa_config_held(spa, SCL_ALL, RW_READER), !=, 0);
5412-
ASSERT3U(offset >> vd->vdev_ms_shift, <, vd->vdev_ms_count);
5413+
VERIFY3U(m, <, vd->vdev_ms_count);
54135414

5414-
msp = vd->vdev_ms[offset >> vd->vdev_ms_shift];
5415+
msp = vd->vdev_ms[m];
54155416

54165417
VERIFY(!msp->ms_condensing);
54175418
VERIFY3U(offset, >=, msp->ms_start);

0 commit comments

Comments
 (0)