]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: fix maxicount division by zero error
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 27 Aug 2019 00:06:01 +0000 (17:06 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 28 Aug 2019 15:31:01 +0000 (08:31 -0700)
commit6a5fd6d08b982782f4fe41e31bc3e4322cb467c9
tree676294a5dc3f20960df163bac47005ddf91d0c31
parentc953164460beab5f86248785d310a5b0fbcee9f1
xfs: fix maxicount division by zero error

In xfs_ialloc_setup_geometry, it's possible for a malicious/corrupt fs
image to set an unreasonably large value for sb_inopblog which will
cause ialloc_blks to be zero.  If sb_imax_pct is also set, this results
in a division by zero error in the second do_div call.  Therefore, force
maxicount to zero if ialloc_blks is zero.

Note that the kernel metadata verifiers will catch the garbage inopblog
value and abort the fs mount long before it tries to set up the inode
geometry; this is needed to avoid a crash in xfs_db while setting up the
xfs_mount structure.

Found by fuzzing sb_inopblog to 122 in xfs/350.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
fs/xfs/libxfs/xfs_ialloc.c