diff mbox series

[36/58] xfs: check owner of dir3 free blocks

Message ID 20200507121851.304002-37-hch@lst.de (mailing list archive)
State Accepted
Headers show
Series [01/58] xfs: add agf freeblocks verify in xfs_agf_verify | expand

Commit Message

Christoph Hellwig May 7, 2020, 12:18 p.m. UTC
From: "Darrick J. Wong" <darrick.wong@oracle.com>

Source kernel commit: 6fb5aac73310d030be13eb3481fdb7c7cc7c0f00

Check the owner field of dir3 free block headers and reject the metadata
if there's something wrong with it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 libxfs/xfs_dir2_node.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c
index 48c06da2..b2026da5 100644
--- a/libxfs/xfs_dir2_node.c
+++ b/libxfs/xfs_dir2_node.c
@@ -191,6 +191,8 @@  xfs_dir3_free_header_check(
 			return __this_address;
 		if (be32_to_cpu(hdr3->nvalid) < be32_to_cpu(hdr3->nused))
 			return __this_address;
+		if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino)
+			return __this_address;
 	} else {
 		struct xfs_dir2_free_hdr *hdr = bp->b_addr;