Skip to content

Commit 3b42d38

Browse files
committed
xfs: scrub inode mode properly
Since we've used up all the bits in i_mode, the existing mode check doesn't actually do anything useful. However, we've not used all the bit values in the format portion of i_mode, so we /do/ need to test that for bad values. Fixes: 80e4e12 ("xfs: scrub inodes") Fixes-coverity-id: 1423992 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
1 parent 2d5f4b5 commit 3b42d38

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

fs/xfs/scrub/inode.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,20 @@ xfs_scrub_dinode(
318318

319319
/* di_mode */
320320
mode = be16_to_cpu(dip->di_mode);
321-
if (mode & ~(S_IALLUGO | S_IFMT))
321+
switch (mode & S_IFMT) {
322+
case S_IFLNK:
323+
case S_IFREG:
324+
case S_IFDIR:
325+
case S_IFCHR:
326+
case S_IFBLK:
327+
case S_IFIFO:
328+
case S_IFSOCK:
329+
/* mode is recognized */
330+
break;
331+
default:
322332
xfs_scrub_ino_set_corrupt(sc, ino, bp);
333+
break;
334+
}
323335

324336
/* v1/v2 fields */
325337
switch (dip->di_version) {

0 commit comments

Comments
 (0)