Skip to content

Commit

Permalink
xfs: validate allocated inode number
Browse files Browse the repository at this point in the history
When we have corrupted free inode btrees, we can attempt to
allocate inodes that we know are already allocated. Catch allocation
of these inodes and report corruption as early as possible to
prevent corruption propagation or deadlocks.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
  • Loading branch information
Dave Chinner authored and Darrick J. Wong committed May 9, 2018
1 parent afca6c5 commit 8b26984
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fs/xfs/xfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,18 @@ xfs_ialloc(
}
ASSERT(*ialloc_context == NULL);

/*
* Protect against obviously corrupt allocation btree records. Later
* xfs_iget checks will catch re-allocation of other active in-memory
* and on-disk inodes. If we don't catch reallocating the parent inode
* here we will deadlock in xfs_iget() so we have to do these checks
* first.
*/
if ((pip && ino == pip->i_ino) || !xfs_verify_dir_ino(mp, ino)) {
xfs_alert(mp, "Allocated a known in-use inode 0x%llx!", ino);
return -EFSCORRUPTED;
}

/*
* Get the in-core inode with the lock held exclusively.
* This is because we're setting fields here we need
Expand Down

0 comments on commit 8b26984

Please sign in to comment.