Author: mckusick
Date: Sun Oct 25 21:04:07 2020
New Revision: 367045
URL: https://svnweb.freebsd.org/changeset/base/367045

Log:
  Use proper type (ino_t) for inode numbers to avoid improper sign extention
  in the Pass 5 checks. The manifestation was fsck_ffs exiting with this error:
  
    ** Phase 5 - Check Cyl groups
    fsck_ffs: inoinfo: inumber 18446744071562087424 out of range
  
  The error only manifests itself for filesystems bigger than about 100Tb.
  
  Reported by:  Nikita Grechikhin <ngrechikhin at yandex.ru>
  MFC after:    2 weeks
  Sponsored by: Netflix

Modified:
  head/sbin/fsck_ffs/pass5.c

Modified: head/sbin/fsck_ffs/pass5.c
==============================================================================
--- head/sbin/fsck_ffs/pass5.c  Sun Oct 25 19:34:02 2020        (r367044)
+++ head/sbin/fsck_ffs/pass5.c  Sun Oct 25 21:04:07 2020        (r367045)
@@ -63,6 +63,7 @@ pass5(void)
        struct fs *fs = &sblock;
        ufs2_daddr_t d, dbase, dmax, start;
        int rewritecg = 0;
+       ino_t inum;
        struct csum *cs;
        struct csum_total cstotal;
        struct inodesc idesc[3];
@@ -238,9 +239,9 @@ pass5(void)
                }
                memset(&newcg->cg_frsum[0], 0, sizeof newcg->cg_frsum);
                memset(cg_inosused(newcg), 0, (size_t)(mapsize));
-               j = fs->fs_ipg * c;
-               for (i = 0; i < inostathead[c].il_numalloced; j++, i++) {
-                       switch (inoinfo(j)->ino_state) {
+               inum = fs->fs_ipg * c;
+               for (i = 0; i < inostathead[c].il_numalloced; inum++, i++) {
+                       switch (inoinfo(inum)->ino_state) {
 
                        case USTATE:
                                break;
@@ -260,10 +261,10 @@ pass5(void)
                                break;
 
                        default:
-                               if (j < (int)UFS_ROOTINO)
+                               if (inum < UFS_ROOTINO)
                                        break;
-                               errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
-                                   inoinfo(j)->ino_state, j);
+                               errx(EEXIT, "BAD STATE %d FOR INODE I=%ju",
+                                   inoinfo(inum)->ino_state, (uintmax_t)inum);
                        }
                }
                if (c == 0)
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to