• D
    xfs: fix rmap key and record comparison functions · ae5ea479
    Darrick J. Wong 提交于
    stable inclusion
    from linux-4.19.158
    commit b7fec5a9a726e9e2a095d53b6de4e62bf179b481
    
    --------------------------------
    
    [ Upstream commit 6ff646b2 ]
    
    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: 4b8ed677 ("xfs: add rmap btree operations")
    Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: NChristoph Hellwig <hch@lst.de>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
    ae5ea479
xfs_rmap_btree.c 14.7 KB