This is a note to let you know that I've just added the patch titled xfs: don't allow overly small or large realtime volumes to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-don-t-allow-overly-small-or-large-realtime-volumes.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From stable+bounces-32419-greg=kroah.com@xxxxxxxxxxxxxxx Wed Mar 27 01:13:24 2024 From: Catherine Hoang <catherine.hoang@xxxxxxxxxx> Date: Tue, 26 Mar 2024 17:12:19 -0700 Subject: xfs: don't allow overly small or large realtime volumes To: stable@xxxxxxxxxxxxxxx Cc: linux-xfs@xxxxxxxxxxxxxxx Message-ID: <20240327001233.51675-11-catherine.hoang@xxxxxxxxxx> From: "Darrick J. Wong" <djwong@xxxxxxxxxx> commit e14293803f4e84eb23a417b462b56251033b5a66 upstream. [backport: resolve merge conflicts due to refactoring rtbitmap/summary macros and accessors] Don't allow realtime volumes that are less than one rt extent long. This has been broken across 4 LTS kernels with nobody noticing, so let's just disable it. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Signed-off-by: Catherine Hoang <catherine.hoang@xxxxxxxxxx> Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/xfs/libxfs/xfs_rtbitmap.h | 13 +++++++++++++ fs/xfs/libxfs/xfs_sb.c | 3 ++- fs/xfs/xfs_rtalloc.c | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) --- a/fs/xfs/libxfs/xfs_rtbitmap.h +++ b/fs/xfs/libxfs/xfs_rtbitmap.h @@ -73,6 +73,18 @@ int xfs_rtfree_blocks(struct xfs_trans * uint8_t xfs_compute_rextslog(xfs_rtbxlen_t rtextents); +/* Do we support an rt volume having this number of rtextents? */ +static inline bool +xfs_validate_rtextents( + xfs_rtbxlen_t rtextents) +{ + /* No runt rt volumes */ + if (rtextents == 0) + return false; + + return true; +} + #else /* CONFIG_XFS_RT */ # define xfs_rtfree_extent(t,b,l) (-ENOSYS) # define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS) @@ -81,6 +93,7 @@ uint8_t xfs_compute_rextslog(xfs_rtbxlen # define xfs_rtbuf_get(m,t,b,i,p) (-ENOSYS) # define xfs_rtalloc_extent_is_free(m,t,s,l,i) (-ENOSYS) # define xfs_compute_rextslog(rtx) (0) +# define xfs_validate_rtextents(rtx) (false) #endif /* CONFIG_XFS_RT */ #endif /* __XFS_RTBITMAP_H__ */ --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -509,7 +509,8 @@ xfs_validate_sb_common( rbmblocks = howmany_64(sbp->sb_rextents, NBBY * sbp->sb_blocksize); - if (sbp->sb_rextents != rexts || + if (!xfs_validate_rtextents(rexts) || + sbp->sb_rextents != rexts || sbp->sb_rextslog != xfs_compute_rextslog(rexts) || sbp->sb_rbmblocks != rbmblocks) { xfs_notice(mp, --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -998,6 +998,8 @@ xfs_growfs_rt( */ nrextents = nrblocks; do_div(nrextents, in->extsize); + if (!xfs_validate_rtextents(nrextents)) + return -EINVAL; nrbmblocks = howmany_64(nrextents, NBBY * sbp->sb_blocksize); nrextslog = xfs_compute_rextslog(nrextents); nrsumlevels = nrextslog + 1; Patches currently in stable-queue which might be from kroah.com@xxxxxxxxxxxxxxx are queue-6.6/xfs-fix-32-bit-truncation-in-xfs_compute_rextslog.patch queue-6.6/xfs-transfer-recovered-intent-item-ownership-in-iop_recover.patch queue-6.6/xfs-initialise-di_crc-in-xfs_log_dinode.patch queue-6.6/xfs-add-missing-nrext64-inode-flag-check-to-scrub.patch queue-6.6/xfs-consider-minlen-sized-extents-in-xfs_rtallocate_extent_block.patch queue-6.6/xfs-don-t-leak-recovered-attri-intent-items.patch queue-6.6/xfs-remove-unused-fields-from-struct-xbtree_ifakeroot.patch queue-6.6/xfs-ensure-logflagsp-is-initialized-in-xfs_bmap_del_extent_real.patch queue-6.6/xfs-convert-rt-bitmap-extent-lengths-to-xfs_rtbxlen_t.patch queue-6.6/xfs-fix-perag-leak-when-growfs-fails.patch queue-6.6/xfs-pass-the-xfs_defer_pending-object-to-iop_recover.patch queue-6.6/xfs-update-dir3-leaf-block-metadata-after-swap.patch queue-6.6/xfs-make-rextslog-computation-consistent-with-mkfs.patch queue-6.6/xfs-move-the-xfs_rtbitmap.c-declarations-to-xfs_rtbitmap.h.patch queue-6.6/xfs-recompute-growfsrtfree-transaction-reservation-while-growing-rt-volume.patch queue-6.6/xfs-force-all-buffers-to-be-written-during-btree-bulk-load.patch queue-6.6/xfs-make-xchk_iget-safer-in-the-presence-of-corrupt-inode-btrees.patch queue-6.6/xfs-reset-xfs_attr_incomplete-filter-on-node-removal.patch queue-6.6/xfs-fix-an-off-by-one-error-in-xreap_agextent_binval.patch queue-6.6/xfs-short-circuit-xfs_growfs_data_private-if-delta-is-zero.patch queue-6.6/xfs-add-lock-protection-when-remove-perag-from-radix-tree.patch queue-6.6/xfs-use-xfs_defer_pending-objects-to-recover-intent-items.patch queue-6.6/xfs-don-t-allow-overly-small-or-large-realtime-volumes.patch queue-6.6/xfs-remove-conditional-building-of-rt-geometry-validator-functions.patch