xfs: validate untrusted inode numbers during lookup
commit2d797c070ed30c14cd2512f169a521f27282a313
authorDave Chinner <dchinner@redhat.com>
Mon, 10 Jan 2011 22:28:37 +0000 (10 15:28 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 2 Mar 2011 14:46:47 +0000 (2 09:46 -0500)
tree11e7c25984685e71260068387c7a310ffaca2e93
parent42ea054affa914cec030564d6fe567a271816fb0
xfs: validate untrusted inode numbers during lookup

Upstream commit: 7124fe0a5b619d65b739477b3b55a20bf805b06d

When we decode a handle or do a bulkstat lookup, we are using an
inode number we cannot trust to be valid. If we are deleting inode
chunks from disk (default noikeep mode), then we cannot trust the on
disk inode buffer for any given inode number to correctly reflect
whether the inode has been unlinked as the di_mode nor the
generation number may have been updated on disk.

This is due to the fact that when we delete an inode chunk, we do
not write the clusters back to disk when they are removed - instead
we mark them stale to avoid them being written back potentially over
the top of something that has been subsequently allocated at that
location. The result is that we can have locations of disk that look
like they contain valid inodes but in reality do not. Hence we
cannot simply convert the inode number to a block number and read
the location from disk to determine if the inode is valid or not.

As a result, and XFS_IGET_BULKSTAT lookup needs to actually look the
inode up in the inode allocation btree to determine if the inode
number is valid or not.

It should be noted even on ikeep filesystems, there is the
possibility that blocks on disk may look like valid inode clusters.
e.g. if there are filesystem images hosted on the filesystem. Hence
even for ikeep filesystems we really need to validate that the inode
number is valid before issuing the inode buffer read.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[dannf: backported to 2.6.32.y]
Cc: dann frazier <dannf@debian.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/xfs/xfs_ialloc.c