Skip to content

Commit 1920779

Browse files
dgchinnerdchinner
authored andcommitted
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: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 7124fe0 commit 1920779

5 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎fs/xfs/linux-2.6/xfs_export.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,11 @@ xfs_nfs_get_inode(
128128
return ERR_PTR(-ESTALE);
129129

130130
/*
131-
* The XFS_IGET_BULKSTAT means that an invalid inode number is just
132-
* fine and not an indication of a corrupted filesystem. Because
133-
* clients can send any kind of invalid file handle, e.g. after
134-
* a restore on the server we have to deal with this case gracefully.
131+
* The XFS_IGET_UNTRUSTED means that an invalid inode number is just
132+
* fine and not an indication of a corrupted filesystem as clients can
133+
* send invalid file handles and we have to handle it gracefully..
135134
*/
136-
error = xfs_iget(mp, NULL, ino, XFS_IGET_BULKSTAT,
135+
error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED,
137136
XFS_ILOCK_SHARED, &ip, 0);
138137
if (error) {
139138
/*

‎fs/xfs/xfs_ialloc.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ xfs_imap_lookup(
12511251
return error;
12521252

12531253
/* for untrusted inodes check it is allocated first */
1254-
if ((flags & XFS_IGET_BULKSTAT) &&
1254+
if ((flags & XFS_IGET_UNTRUSTED) &&
12551255
(rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino)))
12561256
return EINVAL;
12571257

@@ -1292,8 +1292,11 @@ xfs_imap(
12921292
if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks ||
12931293
ino != XFS_AGINO_TO_INO(mp, agno, agino)) {
12941294
#ifdef DEBUG
1295-
/* no diagnostics for bulkstat, ino comes from userspace */
1296-
if (flags & XFS_IGET_BULKSTAT)
1295+
/*
1296+
* Don't output diagnostic information for untrusted inodes
1297+
* as they can be invalid without implying corruption.
1298+
*/
1299+
if (flags & XFS_IGET_UNTRUSTED)
12971300
return XFS_ERROR(EINVAL);
12981301
if (agno >= mp->m_sb.sb_agcount) {
12991302
xfs_fs_cmn_err(CE_ALERT, mp,
@@ -1329,7 +1332,7 @@ xfs_imap(
13291332
* inodes in stale state on disk. Hence we have to do a btree lookup
13301333
* in all cases where an untrusted inode number is passed.
13311334
*/
1332-
if (flags & XFS_IGET_BULKSTAT) {
1335+
if (flags & XFS_IGET_UNTRUSTED) {
13331336
error = xfs_imap_lookup(mp, tp, agno, agino, agbno,
13341337
&chunk_agbno, &offset_agbno, flags);
13351338
if (error)

‎fs/xfs/xfs_inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ xfs_imap_to_bp(
177177
if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
178178
XFS_ERRTAG_ITOBP_INOTOBP,
179179
XFS_RANDOM_ITOBP_INOTOBP))) {
180-
if (iget_flags & XFS_IGET_BULKSTAT) {
180+
if (iget_flags & XFS_IGET_UNTRUSTED) {
181181
xfs_trans_brelse(tp, bp);
182182
return XFS_ERROR(EINVAL);
183183
}

‎fs/xfs/xfs_inode.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ do { \
500500
* Flags for xfs_iget()
501501
*/
502502
#define XFS_IGET_CREATE 0x1
503-
#define XFS_IGET_BULKSTAT 0x2
503+
#define XFS_IGET_UNTRUSTED 0x2
504504

505505
int xfs_inotobp(struct xfs_mount *, struct xfs_trans *,
506506
xfs_ino_t, struct xfs_dinode **,

‎fs/xfs/xfs_itable.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ xfs_bulkstat_one_int(
8080
return XFS_ERROR(ENOMEM);
8181

8282
error = xfs_iget(mp, NULL, ino,
83-
XFS_IGET_BULKSTAT, XFS_ILOCK_SHARED, &ip, bno);
83+
XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip, bno);
8484
if (error) {
8585
*stat = BULKSTAT_RV_NOTHING;
8686
goto out_free;

0 commit comments

Comments
 (0)