diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2017-11-28 00:40:19 -0500 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2017-11-30 11:43:52 -0500 |
commit | 3b42d385753c22b29d259ccb9d4c3f419e583b30 (patch) | |
tree | 53e0c6b8ae3e364dc1e4f91a151f20998bbb927c /fs/xfs | |
parent | 2d5f4b5bebccfe983715ebc9255151e611234643 (diff) |
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: 80e4e1268 ("xfs: scrub inodes")
Fixes-coverity-id: 1423992
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/scrub/inode.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c index 637b7a892313..f120fb20452f 100644 --- a/fs/xfs/scrub/inode.c +++ b/fs/xfs/scrub/inode.c | |||
@@ -318,8 +318,20 @@ xfs_scrub_dinode( | |||
318 | 318 | ||
319 | /* di_mode */ | 319 | /* di_mode */ |
320 | mode = be16_to_cpu(dip->di_mode); | 320 | 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: | ||
322 | xfs_scrub_ino_set_corrupt(sc, ino, bp); | 332 | xfs_scrub_ino_set_corrupt(sc, ino, bp); |
333 | break; | ||
334 | } | ||
323 | 335 | ||
324 | /* v1/v2 fields */ | 336 | /* v1/v2 fields */ |
325 | switch (dip->di_version) { | 337 | switch (dip->di_version) { |