1. 13 Apr, 2022 3 commits
    • Ye Bin's avatar
      ext4: fix bug_on in start_this_handle during umount filesystem · b98535d0
      Ye Bin authored
      We got issue as follows:
      ------------[ cut here ]------------
      kernel BUG at fs/jbd2/transaction.c:389!
      invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI
      CPU: 9 PID: 131 Comm: kworker/9:1 Not tainted 5.17.0-862.14.0.6.x86_64-00001-g23f87daf7d74-dirty #197
      Workqueue: events flush_stashed_error_work
      RIP: 0010:start_this_handle+0x41c/0x1160
      RSP: 0018:ffff888106b47c20 EFLAGS: 00010202
      RAX: ffffed10251b8400 RBX: ffff888128dc204c RCX: ffffffffb52972ac
      RDX: 0000000000000200 RSI: 0000000000000004 RDI: ffff888128dc2050
      RBP: 0000000000000039 R08: 0000000000000001 R09: ffffed10251b840a
      R10: ffff888128dc204f R11: ffffed10251b8409 R12: ffff888116d78000
      R13: 0000000000000000 R14: dffffc0000000000 R15: ffff888128dc2000
      FS:  0000000000000000(0000) GS:ffff88839d680000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000001620068 CR3: 0000000376c0e000 CR4: 00000000000006e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       jbd2__journal_start+0x38a/0x790
       jbd2_journal_start+0x19/0x20
       flush_stashed_error_work+0x110/0x2b3
       process_one_work+0x688/0x1080
       worker_thread+0x8b/0xc50
       kthread+0x26f/0x310
       ret_from_fork+0x22/0x30
       </TASK>
      Modules linked in:
      ---[ end trace 0000000000000000 ]---
      
      Above issue may happen as follows:
            umount            read procfs            error_work
      ext4_put_super
        flush_work(&sbi->s_error_work);
      
                            ext4_mb_seq_groups_show
      	                ext4_mb_load_buddy_gfp
      			  ext4_mb_init_group
      			    ext4_mb_init_cache
      	                      ext4_read_block_bitmap_nowait
      			        ext4_validate_block_bitmap
      				  ext4_error
      			            ext4_handle_error
      			              schedule_work(&EXT4_SB(sb)->s_error_work);
      
        ext4_unregister_sysfs(sb);
        jbd2_journal_destroy(sbi->s_journal);
          journal_kill_thread
            journal->j_flags |= JBD2_UNMOUNT;
      
                                                flush_stashed_error_work
      				            jbd2_journal_start
      					      start_this_handle
      					        BUG_ON(journal->j_flags & JBD2_UNMOUNT);
      
      To solve this issue, we call 'ext4_unregister_sysfs() before flushing
      s_error_work in ext4_put_super().
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarRitesh Harjani <riteshh@linux.ibm.com>
      Link: https://lore.kernel.org/r/20220322012419.725457-1-yebin10@huawei.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      b98535d0
    • Ye Bin's avatar
      ext4: fix symlink file size not match to file content · a2b0b205
      Ye Bin authored
      We got issue as follows:
      [home]# fsck.ext4  -fn  ram0yb
      e2fsck 1.45.6 (20-Mar-2020)
      Pass 1: Checking inodes, blocks, and sizes
      Pass 2: Checking directory structure
      Symlink /p3/d14/d1a/l3d (inode #3494) is invalid.
      Clear? no
      Entry 'l3d' in /p3/d14/d1a (3383) has an incorrect filetype (was 7, should be 0).
      Fix? no
      
      As the symlink file size does not match the file content. If the writeback
      of the symlink data block failed, ext4_finish_bio() handles the end of IO.
      However this function fails to mark the buffer with BH_write_io_error and
      so when unmount does journal checkpoint it cannot detect the writeback
      error and will cleanup the journal. Thus we've lost the correct data in the
      journal area. To solve this issue, mark the buffer as BH_write_io_error in
      ext4_finish_bio().
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20220321144438.201685-1-yebin10@huawei.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      a2b0b205
    • Darrick J. Wong's avatar
      ext4: fix fallocate to use file_modified to update permissions consistently · ad5cd4f4
      Darrick J. Wong authored
      Since the initial introduction of (posix) fallocate back at the turn of
      the century, it has been possible to use this syscall to change the
      user-visible contents of files.  This can happen by extending the file
      size during a preallocation, or through any of the newer modes (punch,
      zero, collapse, insert range).  Because the call can be used to change
      file contents, we should treat it like we do any other modification to a
      file -- update the mtime, and drop set[ug]id privileges/capabilities.
      
      The VFS function file_modified() does all this for us if pass it a
      locked inode, so let's make fallocate drop permissions correctly.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Link: https://lore.kernel.org/r/20220308185043.GA117678@magnoliaSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      ad5cd4f4
  2. 15 Mar, 2022 7 commits
  3. 13 Mar, 2022 8 commits
  4. 03 Mar, 2022 7 commits
  5. 26 Feb, 2022 13 commits
  6. 20 Feb, 2022 2 commits