lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <f714d963-9855-546d-74b8-8c9a883ae65e@huawei.com>
Date:   Tue, 15 Mar 2022 17:35:19 +0800
From:   zhanchengbin <zhanchengbin1@...wei.com>
To:     Theodore Ts'o <tytso@....edu>
CC:     <linux-ext4@...r.kernel.org>, linfeilong <linfeilong@...wei.com>,
        <liuzhiqiang26@...wei.com>
Subject: [PATCH] e2fsck: do not skip deeper checkers when s_last_orphan list
 has truncated inodes

If the system crashes when a file is being truncated, we will get a 
problematic inode,
and it will be added into fs->super->s_last_orphan.
When we run `e2fsck -a img`, the s_last_orphan list will be traversed 
and deleted.
During this period, orphan inodes in the s_last_orphan list with 
i_links_count==0 can
be deleted, and orphan inodes with  i_links_count !=0 (ex. the truncated 
inode)
cannot be deleted. However, when there are some orphan inodes with 
i_links_count !=0,
the EXT2_VALID_FS is still assigned to fs->super->s_state, the deeper 
checkers are skipped
with some inconsistency problems.
Here, we will clean EXT2_VALID_FS flag when there is orphan inodes with 
i_links_count !=0
for deeper checkers.

Problems with truncated files.
     [root@...alhost ~]# e2fsck -a img
     img: recovering journal
     img: Truncating orphaned inode 188 (uid=0, gid=0, mode=0100666, size=0)
     img: Truncating orphaned inode 174 (uid=0, gid=0, mode=0100666, size=0)
     img: clean, 484/128016 files, 118274/512000 blocks
     [root@...alhost ~]# e2fsck -fn img
     e2fsck 1.46.5 (30-Dec-2021)
     Pass 1: Checking inodes, blocks, and sizes
     Inode 174, i_blocks is 2, should be 0.  Fix? no

     Inode 188, i_blocks is 2, should be 0.  Fix? no

     Pass 2: Checking directory structure
     Pass 3: Checking directory connectivity
     Pass 4: Checking reference counts
     Pass 5: Checking group summary information

     img: ********** WARNING: Filesystem still has errors **********

     img: 484/128016 files (24.6% non-contiguous), 118274/512000 blocks
     [root@...alhost ~]# e2fsck -a img
     img: clean, 484/128016 files, 118274/512000 blocks

But, if run `e2fsck -f img`, EXT2_VALID_FS flag will be clean, so do 
`e2fsck -a img` again,
can fix this problem.

     [root@...alhost ~]# e2fsck -f img
     e2fsck 1.46.5 (30-Dec-2021)
     Pass 1: Checking inodes, blocks, and sizes
     Inode 174, i_blocks is 2, should be 0.  Fix<y>? no
     Inode 188, i_blocks is 2, should be 0.  Fix<y>? no
     Pass 2: Checking directory structure
     Pass 3: Checking directory connectivity
     Pass 4: Checking reference counts
     Pass 5: Checking group summary information

     img: ********** WARNING: Filesystem still has errors **********

     img: 484/128016 files (24.6% non-contiguous), 118274/512000 blocks
     [root@...alhost ~]# e2fsck -a img
     img was not cleanly unmounted, check forced.
     img: Inode 174, i_blocks is 2, should be 0.  FIXED.
     img: Inode 188, i_blocks is 2, should be 0.  FIXED.
     img: 484/128016 files (24.6% non-contiguous), 118274/512000 blocks

Signed-off-by: zhanchengbin <zhanchengbin1@...wei.com>
---
  e2fsck/super.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/e2fsck/super.c b/e2fsck/super.c
index 9495e029..f4a414b7 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -351,6 +351,7 @@ static int release_orphan_inode(e2fsck_t ctx, 
ext2_ino_t *ino, char *block_buf)
          inode.i_dtime = ctx->now;
      } else {
          inode.i_dtime = 0;
+        fs->super->s_state &= ~EXT2_VALID_FS;
      }
      e2fsck_write_inode_full(ctx, *ino, EXT2_INODE(&inode),
                  sizeof(inode), "delete_file");




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ