]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
xfs: fix rmap key and record comparison functions
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 9 Nov 2020 00:32:44 +0000 (16:32 -0800)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 10 Dec 2020 11:06:30 +0000 (12:06 +0100)
commit4e1e0da86342019e99c1ddec513970a8b2bfbdb8
treef9580bdc604f8cab07962d98a414c0206e17ffdc
parent7301a7bdd95e60eb52679e613a3e26e207c1a70d
xfs: fix rmap key and record comparison functions

BugLink: https://bugs.launchpad.net/bugs/1905618
[ Upstream commit 6ff646b2ceb0eec916101877f38da0b73e3a5b7f ]

Keys for extent interval records in the reverse mapping btree are
supposed to be computed as follows:

(physical block, owner, fork, is_btree, is_unwritten, offset)

This provides users the ability to look up a reverse mapping from a bmbt
record -- start with the physical block; then if there are multiple
records for the same block, move on to the owner; then the inode fork
type; and so on to the file offset.

However, the key comparison functions incorrectly remove the
fork/btree/unwritten information that's encoded in the on-disk offset.
This means that lookup comparisons are only done with:

(physical block, owner, offset)

This means that queries can return incorrect results.  On consistent
filesystems this hasn't been an issue because blocks are never shared
between forks or with bmbt blocks; and are never unwritten.  However,
this bug means that online repair cannot always detect corruption in the
key information in internal rmapbt nodes.

Found by fuzzing keys[1].attrfork = ones on xfs/371.

Fixes: 4b8ed67794fe ("xfs: add rmap btree operations")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
fs/xfs/libxfs/xfs_rmap_btree.c