All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET 0/3] xfs: fix various bugs in fsmap
@ 2021-08-12  0:58 Darrick J. Wong
  2021-08-12  0:58 ` [PATCH 1/3] xfs: make xfs_rtalloc_query_range input parameters const Darrick J. Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Darrick J. Wong @ 2021-08-12  0:58 UTC (permalink / raw)
  To: djwong; +Cc: linux-xfs

Hi all,

While performing some code audits of the fsmap code, I noticed some off
by one errors in the realtime bitmap query code that provides the rt
fsmap implementation.

The first problem I found is that while the rtbitmap range query
function will constrain the starting and ending rtextent parameters to
match the actual rt volume, it does so by changing the struct passed in
by the caller.  This is a no-no, since query functions themselves are
not supposed to change the global state.

The second problem is an off-by-one error in the rtbitmap fsmap function
itself.  The fsmap record emitter function has the neat property that it
can detect gaps between the fsmap record we're about to emit and the
last one it emitted.  When this happens, it first emits an fsmap record
to fill the gap and then emits the one it was called about.

When the last block of the queried range is in use, we synthesize a
fsmap record just outside the query range, which has the effect of
emitting an "unknown owner" fsmap record for the inuse space.
Unfortunately, we don't range check the last block value, with the
result that the "unknown owner" fsmap can claim to extend beyond the end
of the rt volume!  So range check that.

The third problem is similar to the first: each fsmap backend is passed
the keys of the range to query and some scratch space.  The backend can
change anything it wants in the scratch space, but it's not supposed to
change the keys.  Unfortunately, range checking in the backend functions
/did/ change the keys, which causes subsequent backends to be called
with incorrect keys.  Fix this.

If you're going to start using this mess, you probably ought to just
pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything.  Enjoy!
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=fsmap-fixes-5.15
---
 fs/xfs/libxfs/xfs_rtbitmap.c |   14 ++++++-----
 fs/xfs/xfs_fsmap.c           |   52 ++++++++++++++++++++++++------------------
 fs/xfs/xfs_rtalloc.h         |    7 ++----
 3 files changed, 40 insertions(+), 33 deletions(-)


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-08-13 16:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12  0:58 [PATCHSET 0/3] xfs: fix various bugs in fsmap Darrick J. Wong
2021-08-12  0:58 ` [PATCH 1/3] xfs: make xfs_rtalloc_query_range input parameters const Darrick J. Wong
2021-08-12  8:30   ` Christoph Hellwig
2021-08-12 15:07     ` Darrick J. Wong
2021-08-13  9:56   ` Chandan Babu R
2021-08-12  0:58 ` [PATCH 2/3] xfs: fix off-by-one error when the last rt extent is in use Darrick J. Wong
2021-08-12  8:36   ` Christoph Hellwig
2021-08-12 16:24     ` Darrick J. Wong
2021-08-13 10:50   ` Chandan Babu R
2021-08-13 16:16     ` Darrick J. Wong
2021-08-12  0:58 ` [PATCH 3/3] xfs: make fsmap backend function key parameters const Darrick J. Wong
2021-08-12  8:40   ` Christoph Hellwig
2021-08-13 11:03   ` Chandan Babu R

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.