]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: fix exchmaps reservation limit check
authorYingjie Gao <gaoyingjie@uniontech.com>
Thu, 4 Jun 2026 12:03:17 +0000 (20:03 +0800)
committerCarlos Maiolino <cem@kernel.org>
Tue, 9 Jun 2026 07:14:41 +0000 (09:14 +0200)
xfs_exchmaps_estimate_overhead() adds the bmbt and rmapbt
overhead to a local resblks variable, but the final UINT_MAX
check still tests req->resblks.  That is the reservation value
from before the overhead was added.

The computed value is stored back in req->resblks and later passed
to xfs_trans_alloc(), whose block reservation argument is unsigned
int.  Check the computed reservation so the existing limit applies
to the value that will be used.

Fixes: 966ceafc7a43 ("xfs: create deferred log items for file mapping exchanges")
Cc: stable@vger.kernel.org # v6.10
Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/libxfs/xfs_exchmaps.c

index 5d28f4eac527b452dc8d28d5f3becb00e7199c18..541e33f33167216e2d43dd13d11f2bf7ad5033f4 100644 (file)
@@ -711,7 +711,7 @@ xfs_exchmaps_estimate_overhead(
                return -ENOSPC;
 
        /* Can't actually reserve more than UINT_MAX blocks. */
-       if (req->resblks > UINT_MAX)
+       if (resblks > UINT_MAX)
                return -ENOSPC;
 
        req->resblks = resblks;