提交 6a96c565 编写于 作者: D Darrick J. Wong

xfs: don't accept inode buffers with suspicious unlinked chains

When we're verifying inode buffers, sanity-check the unlinked pointer.
We don't want to run the risk of trying to purge something that's
obviously broken.
Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: NBrian Foster <bfoster@redhat.com>
上级 8bb82bc1
...@@ -93,20 +93,26 @@ xfs_inode_buf_verify( ...@@ -93,20 +93,26 @@ xfs_inode_buf_verify(
bool readahead) bool readahead)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_agnumber_t agno;
int i; int i;
int ni; int ni;
/* /*
* Validate the magic number and version of every inode in the buffer * Validate the magic number and version of every inode in the buffer
*/ */
agno = xfs_daddr_to_agno(mp, XFS_BUF_ADDR(bp));
ni = XFS_BB_TO_FSB(mp, bp->b_length) * mp->m_sb.sb_inopblock; ni = XFS_BB_TO_FSB(mp, bp->b_length) * mp->m_sb.sb_inopblock;
for (i = 0; i < ni; i++) { for (i = 0; i < ni; i++) {
int di_ok; int di_ok;
xfs_dinode_t *dip; xfs_dinode_t *dip;
xfs_agino_t unlinked_ino;
dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog)); dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog));
unlinked_ino = be32_to_cpu(dip->di_next_unlinked);
di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) && di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) &&
xfs_dinode_good_version(mp, dip->di_version); xfs_dinode_good_version(mp, dip->di_version) &&
(unlinked_ino == NULLAGINO ||
xfs_verify_agino(mp, agno, unlinked_ino));
if (unlikely(XFS_TEST_ERROR(!di_ok, mp, if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
XFS_ERRTAG_ITOBP_INOTOBP))) { XFS_ERRTAG_ITOBP_INOTOBP))) {
if (readahead) { if (readahead) {
...@@ -124,9 +130,9 @@ xfs_inode_buf_verify( ...@@ -124,9 +130,9 @@ xfs_inode_buf_verify(
xfs_buf_verifier_error(bp, -EFSCORRUPTED, xfs_buf_verifier_error(bp, -EFSCORRUPTED,
__func__, dip, sizeof(*dip), __func__, dip, sizeof(*dip),
NULL); NULL);
return;
} }
} }
xfs_inobp_check(mp, bp);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册