Re: [PATCH v2 6/6] xfs: assert the reservation covers each da fork growth
"Darrick J. Wong" <[email protected]>
| Newsgroups | org.kernel.vger.linux-xfs,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260810180703.GR3556460@frogsfrogsfrogs> |
On Mon, Aug 10, 2026 at 10:43:19AM -0600, Javier Tia wrote: > xfs_da_grow_inode_int() subtracts the blocks it just allocated from > args->total, the caller's remaining block reservation. The subtraction > is unsigned, so a caller that reaches it with too small a total wraps > the field instead of failing, and every allocation afterwards runs with > a bogus reservation. Assert the remaining reservation still covers the > step, so an under-reserved or uninitialised total trips in debug builds > instead of silently wrapping. > > Suggested-by: Darrick J. Wong <[email protected]> > Signed-off-by: Javier Tia <[email protected]> Looks good, Reviewed-by: "Darrick J. Wong" <[email protected]> --D > --- > fs/xfs/libxfs/xfs_da_btree.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c > index ad801b7bd2dd..9be407affc6e 100644 > --- a/fs/xfs/libxfs/xfs_da_btree.c > +++ b/fs/xfs/libxfs/xfs_da_btree.c > @@ -2385,6 +2385,7 @@ xfs_da_grow_inode_int( > } > > /* account for newly allocated blocks in reserved blocks total */ > + ASSERT(args->total >= dp->i_nblocks - nblks); > args->total -= dp->i_nblocks - nblks; > > out_free_map: > -- > Javier Tia > >