Commit 1920779e authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: rename XFS_IGET_BULKSTAT to XFS_IGET_UNTRUSTED

Inode numbers may come from somewhere external to the filesystem
(e.g. file handles, bulkstat information) and so are inherently
untrusted. Rename the flag we use for these lookups to make it
obvious we are doing a lookup of an untrusted inode number and need
to verify it completely before trying to read it from disk.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 7124fe0a
...@@ -128,12 +128,11 @@ xfs_nfs_get_inode( ...@@ -128,12 +128,11 @@ xfs_nfs_get_inode(
return ERR_PTR(-ESTALE); return ERR_PTR(-ESTALE);
/* /*
* The XFS_IGET_BULKSTAT means that an invalid inode number is just * The XFS_IGET_UNTRUSTED means that an invalid inode number is just
* fine and not an indication of a corrupted filesystem. Because * fine and not an indication of a corrupted filesystem as clients can
* clients can send any kind of invalid file handle, e.g. after * send invalid file handles and we have to handle it gracefully..
* a restore on the server we have to deal with this case gracefully.
*/ */
error = xfs_iget(mp, NULL, ino, XFS_IGET_BULKSTAT, error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED,
XFS_ILOCK_SHARED, &ip, 0); XFS_ILOCK_SHARED, &ip, 0);
if (error) { if (error) {
/* /*
......
...@@ -1251,7 +1251,7 @@ xfs_imap_lookup( ...@@ -1251,7 +1251,7 @@ xfs_imap_lookup(
return error; return error;
/* for untrusted inodes check it is allocated first */ /* for untrusted inodes check it is allocated first */
if ((flags & XFS_IGET_BULKSTAT) && if ((flags & XFS_IGET_UNTRUSTED) &&
(rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino))) (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino)))
return EINVAL; return EINVAL;
...@@ -1292,8 +1292,11 @@ xfs_imap( ...@@ -1292,8 +1292,11 @@ xfs_imap(
if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks || if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks ||
ino != XFS_AGINO_TO_INO(mp, agno, agino)) { ino != XFS_AGINO_TO_INO(mp, agno, agino)) {
#ifdef DEBUG #ifdef DEBUG
/* no diagnostics for bulkstat, ino comes from userspace */ /*
if (flags & XFS_IGET_BULKSTAT) * Don't output diagnostic information for untrusted inodes
* as they can be invalid without implying corruption.
*/
if (flags & XFS_IGET_UNTRUSTED)
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
if (agno >= mp->m_sb.sb_agcount) { if (agno >= mp->m_sb.sb_agcount) {
xfs_fs_cmn_err(CE_ALERT, mp, xfs_fs_cmn_err(CE_ALERT, mp,
...@@ -1329,7 +1332,7 @@ xfs_imap( ...@@ -1329,7 +1332,7 @@ xfs_imap(
* inodes in stale state on disk. Hence we have to do a btree lookup * inodes in stale state on disk. Hence we have to do a btree lookup
* in all cases where an untrusted inode number is passed. * in all cases where an untrusted inode number is passed.
*/ */
if (flags & XFS_IGET_BULKSTAT) { if (flags & XFS_IGET_UNTRUSTED) {
error = xfs_imap_lookup(mp, tp, agno, agino, agbno, error = xfs_imap_lookup(mp, tp, agno, agino, agbno,
&chunk_agbno, &offset_agbno, flags); &chunk_agbno, &offset_agbno, flags);
if (error) if (error)
......
...@@ -177,7 +177,7 @@ xfs_imap_to_bp( ...@@ -177,7 +177,7 @@ xfs_imap_to_bp(
if (unlikely(XFS_TEST_ERROR(!di_ok, mp, if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
XFS_ERRTAG_ITOBP_INOTOBP, XFS_ERRTAG_ITOBP_INOTOBP,
XFS_RANDOM_ITOBP_INOTOBP))) { XFS_RANDOM_ITOBP_INOTOBP))) {
if (iget_flags & XFS_IGET_BULKSTAT) { if (iget_flags & XFS_IGET_UNTRUSTED) {
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
} }
......
...@@ -500,7 +500,7 @@ do { \ ...@@ -500,7 +500,7 @@ do { \
* Flags for xfs_iget() * Flags for xfs_iget()
*/ */
#define XFS_IGET_CREATE 0x1 #define XFS_IGET_CREATE 0x1
#define XFS_IGET_BULKSTAT 0x2 #define XFS_IGET_UNTRUSTED 0x2
int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, int xfs_inotobp(struct xfs_mount *, struct xfs_trans *,
xfs_ino_t, struct xfs_dinode **, xfs_ino_t, struct xfs_dinode **,
......
...@@ -80,7 +80,7 @@ xfs_bulkstat_one_int( ...@@ -80,7 +80,7 @@ xfs_bulkstat_one_int(
return XFS_ERROR(ENOMEM); return XFS_ERROR(ENOMEM);
error = xfs_iget(mp, NULL, ino, error = xfs_iget(mp, NULL, ino,
XFS_IGET_BULKSTAT, XFS_ILOCK_SHARED, &ip, bno); XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip, bno);
if (error) { if (error) {
*stat = BULKSTAT_RV_NOTHING; *stat = BULKSTAT_RV_NOTHING;
goto out_free; goto out_free;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment