1. 29 3月, 2023 2 次提交
  2. 15 3月, 2023 1 次提交
  3. 08 2月, 2023 1 次提交
  4. 07 12月, 2022 1 次提交
  5. 02 11月, 2022 1 次提交
  6. 18 10月, 2022 1 次提交
  7. 27 9月, 2022 3 次提交
  8. 26 7月, 2022 2 次提交
  9. 13 7月, 2022 1 次提交
  10. 23 5月, 2022 1 次提交
  11. 12 5月, 2022 1 次提交
    • Y
      ext4: fix bug_on in start_this_handle during umount filesystem · fc4bac49
      Ye Bin 提交于
      mainline inclusion
      from mainline-v5.18-rc4
      commit b98535d0
      category: bugfix
      bugzilla: 186675, https://gitee.com/openeuler/kernel/issues/I55TUC
      CVE: NA
      
      -------------------------------------------------
      
      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: NYe Bin <yebin10@huawei.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Reviewed-by: NRitesh Harjani <riteshh@linux.ibm.com>
      Link: https://lore.kernel.org/r/20220322012419.725457-1-yebin10@huawei.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      
      conflicts:
      	fs/ext4/super.c
      Signed-off-by: NChenXiaoSong <chenxiaosong2@huawei.com>
      Reviewed-by: Nyebin <yebin10@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      fc4bac49
  12. 27 4月, 2022 3 次提交
  13. 02 3月, 2022 1 次提交
  14. 23 2月, 2022 1 次提交
  15. 26 1月, 2022 1 次提交
  16. 22 1月, 2022 1 次提交
    • Y
      ext4: Fix BUG_ON in ext4_bread when write quota data · a6610eed
      Ye Bin 提交于
      mainline inclusion
      from mainline-v5.17-rc1
      commit 380a0091
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I4RP94?from=project-issue
      CVE: NA
      
      --------------------------------
      
      We got issue as follows when run syzkaller:
      [  167.936972] EXT4-fs error (device loop0): __ext4_remount:6314: comm rep: Abort forced by user
      [  167.938306] EXT4-fs (loop0): Remounting filesystem read-only
      [  167.981637] Assertion failure in ext4_getblk() at fs/ext4/inode.c:847: '(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY) || handle != NULL || create == 0'
      [  167.983601] ------------[ cut here ]------------
      [  167.984245] kernel BUG at fs/ext4/inode.c:847!
      [  167.984882] invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI
      [  167.985624] CPU: 7 PID: 2290 Comm: rep Tainted: G    B             5.16.0-rc5-next-20211217+ #123
      [  167.986823] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014
      [  167.988590] RIP: 0010:ext4_getblk+0x17e/0x504
      [  167.989189] Code: c6 01 74 28 49 c7 c0 a0 a3 5c 9b b9 4f 03 00 00 48 c7 c2 80 9c 5c 9b 48 c7 c6 40 b6 5c 9b 48 c7 c7 20 a4 5c 9b e8 77 e3 fd ff <0f> 0b 8b 04 244
      [  167.991679] RSP: 0018:ffff8881736f7398 EFLAGS: 00010282
      [  167.992385] RAX: 0000000000000094 RBX: 1ffff1102e6dee75 RCX: 0000000000000000
      [  167.993337] RDX: 0000000000000001 RSI: ffffffff9b6e29e0 RDI: ffffed102e6dee66
      [  167.994292] RBP: ffff88816a076210 R08: 0000000000000094 R09: ffffed107363fa09
      [  167.995252] R10: ffff88839b1fd047 R11: ffffed107363fa08 R12: ffff88816a0761e8
      [  167.996205] R13: 0000000000000000 R14: 0000000000000021 R15: 0000000000000001
      [  167.997158] FS:  00007f6a1428c740(0000) GS:ffff88839b000000(0000) knlGS:0000000000000000
      [  167.998238] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  167.999025] CR2: 00007f6a140716c8 CR3: 0000000133216000 CR4: 00000000000006e0
      [  167.999987] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  168.000944] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  168.001899] Call Trace:
      [  168.002235]  <TASK>
      [  168.007167]  ext4_bread+0xd/0x53
      [  168.007612]  ext4_quota_write+0x20c/0x5c0
      [  168.010457]  write_blk+0x100/0x220
      [  168.010944]  remove_free_dqentry+0x1c6/0x440
      [  168.011525]  free_dqentry.isra.0+0x565/0x830
      [  168.012133]  remove_tree+0x318/0x6d0
      [  168.014744]  remove_tree+0x1eb/0x6d0
      [  168.017346]  remove_tree+0x1eb/0x6d0
      [  168.019969]  remove_tree+0x1eb/0x6d0
      [  168.022128]  qtree_release_dquot+0x291/0x340
      [  168.023297]  v2_release_dquot+0xce/0x120
      [  168.023847]  dquot_release+0x197/0x3e0
      [  168.024358]  ext4_release_dquot+0x22a/0x2d0
      [  168.024932]  dqput.part.0+0x1c9/0x900
      [  168.025430]  __dquot_drop+0x120/0x190
      [  168.025942]  ext4_clear_inode+0x86/0x220
      [  168.026472]  ext4_evict_inode+0x9e8/0xa22
      [  168.028200]  evict+0x29e/0x4f0
      [  168.028625]  dispose_list+0x102/0x1f0
      [  168.029148]  evict_inodes+0x2c1/0x3e0
      [  168.030188]  generic_shutdown_super+0xa4/0x3b0
      [  168.030817]  kill_block_super+0x95/0xd0
      [  168.031360]  deactivate_locked_super+0x85/0xd0
      [  168.031977]  cleanup_mnt+0x2bc/0x480
      [  168.033062]  task_work_run+0xd1/0x170
      [  168.033565]  do_exit+0xa4f/0x2b50
      [  168.037155]  do_group_exit+0xef/0x2d0
      [  168.037666]  __x64_sys_exit_group+0x3a/0x50
      [  168.038237]  do_syscall_64+0x3b/0x90
      [  168.038751]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      In order to reproduce this problem, the following conditions need to be met:
      1. Ext4 filesystem with no journal;
      2. Filesystem image with incorrect quota data;
      3. Abort filesystem forced by user;
      4. umount filesystem;
      
      As in ext4_quota_write:
      ...
               if (EXT4_SB(sb)->s_journal && !handle) {
                       ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)"
                               " cancelled because transaction is not started",
                               (unsigned long long)off, (unsigned long long)len);
                       return -EIO;
               }
      ...
      We only check handle if NULL when filesystem has journal. There is need
      check handle if NULL even when filesystem has no journal.
      Signed-off-by: NYe Bin <yebin10@huawei.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20211223015506.297766-1-yebin10@huawei.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: NYe Bin <yebin10@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      a6610eed
  17. 14 1月, 2022 1 次提交
  18. 06 12月, 2021 1 次提交
  19. 30 11月, 2021 1 次提交
  20. 15 11月, 2021 2 次提交
  21. 21 10月, 2021 1 次提交
    • Y
      ext4: flush s_error_work before journal destroy in ext4_fill_super · bb39867f
      yangerkun 提交于
      mainline inclusion
      from mainline-v5.15-rc4
      commit bb9464e0
      category: bugfix
      bugzilla: 176737 https://gitee.com/openeuler/kernel/issues/I4DDEL
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bb9464e08309f6befe80866f5be51778ca355ee9
      
      ---------------------------
      
      The error path in ext4_fill_super forget to flush s_error_work before
      journal destroy, and it may trigger the follow bug since
      flush_stashed_error_work can run concurrently with journal destroy
      without any protection for sbi->s_journal.
      
      [32031.740193] EXT4-fs (loop66): get root inode failed
      [32031.740484] EXT4-fs (loop66): mount failed
      [32031.759805] ------------[ cut here ]------------
      [32031.759807] kernel BUG at fs/jbd2/transaction.c:373!
      [32031.760075] invalid opcode: 0000 [#1] SMP PTI
      [32031.760336] CPU: 5 PID: 1029268 Comm: kworker/5:1 Kdump: loaded
      4.18.0
      [32031.765112] Call Trace:
      [32031.765375]  ? __switch_to_asm+0x35/0x70
      [32031.765635]  ? __switch_to_asm+0x41/0x70
      [32031.765893]  ? __switch_to_asm+0x35/0x70
      [32031.766148]  ? __switch_to_asm+0x41/0x70
      [32031.766405]  ? _cond_resched+0x15/0x40
      [32031.766665]  jbd2__journal_start+0xf1/0x1f0 [jbd2]
      [32031.766934]  jbd2_journal_start+0x19/0x20 [jbd2]
      [32031.767218]  flush_stashed_error_work+0x30/0x90 [ext4]
      [32031.767487]  process_one_work+0x195/0x390
      [32031.767747]  worker_thread+0x30/0x390
      [32031.768007]  ? process_one_work+0x390/0x390
      [32031.768265]  kthread+0x10d/0x130
      [32031.768521]  ? kthread_flush_work_fn+0x10/0x10
      [32031.768778]  ret_from_fork+0x35/0x40
      
      static int start_this_handle(...)
          BUG_ON(journal->j_flags & JBD2_UNMOUNT); <---- Trigger this
      
      Besides, after we enable fast commit, ext4_fc_replay can add work to
      s_error_work but return success, so the latter journal destroy in
      ext4_load_journal can trigger this problem too.
      
      Fix this problem with two steps:
      1. Call ext4_commit_super directly in ext4_handle_error for the case
         that called from ext4_fc_replay
      2. Since it's hard to pair the init and flush for s_error_work, we'd
         better add a extras flush_work before journal destroy in
         ext4_fill_super
      
      Besides, this patch will call ext4_commit_super in ext4_handle_error for
      any nojournal case too. But it seems safe since the reason we call
      schedule_work was that we should save error info to sb through journal
      if available. Conversely, for the nojournal case, it seems useless delay
      commit superblock to s_error_work.
      
      Fixes: c92dc856 ("ext4: defer saving error info from atomic context")
      Fixes: 2d01ddc8 ("ext4: save error info to sb through journal if available")
      Cc: stable@kernel.org
      Signed-off-by: Nyangerkun <yangerkun@huawei.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20210924093917.1953239-1-yangerkun@huawei.comReviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      bb39867f
  22. 15 10月, 2021 3 次提交
  23. 13 10月, 2021 1 次提交
  24. 12 10月, 2021 3 次提交
  25. 06 7月, 2021 1 次提交
  26. 15 6月, 2021 1 次提交
    • A
      ext4: fix memory leak in ext4_fill_super · 071edc48
      Alexey Makhalov 提交于
      stable inclusion
      from stable-5.10.43
      commit 01d349a481f0591230300a9171330136f9159bcd
      bugzilla: 109284
      CVE: NA
      
      --------------------------------
      
      commit afd09b61 upstream.
      
      Buffer head references must be released before calling kill_bdev();
      otherwise the buffer head (and its page referenced by b_data) will not
      be freed by kill_bdev, and subsequently that bh will be leaked.
      
      If blocksizes differ, sb_set_blocksize() will kill current buffers and
      page cache by using kill_bdev(). And then super block will be reread
      again but using correct blocksize this time. sb_set_blocksize() didn't
      fully free superblock page and buffer head, and being busy, they were
      not freed and instead leaked.
      
      This can easily be reproduced by calling an infinite loop of:
      
        systemctl start <ext4_on_lvm>.mount, and
        systemctl stop <ext4_on_lvm>.mount
      
      ... since systemd creates a cgroup for each slice which it mounts, and
      the bh leak get amplified by a dying memory cgroup that also never
      gets freed, and memory consumption is much more easily noticed.
      
      Fixes: ce40733c ("ext4: Check for return value from sb_set_blocksize")
      Fixes: ac27a0ec ("ext4: initial copy of files from ext3")
      Link: https://lore.kernel.org/r/20210521075533.95732-1-amakhalov@vmware.comSigned-off-by: NAlexey Makhalov <amakhalov@vmware.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      071edc48
  27. 03 6月, 2021 2 次提交
  28. 22 4月, 2021 1 次提交
    • E
      ext4: shrink race window in ext4_should_retry_alloc() · 560f326e
      Eric Whitney 提交于
      stable inclusion
      from stable-5.10.28
      commit 4b3139576a20e27fccb9a103ca5503b02e1ac655
      bugzilla: 51779
      
      --------------------------------
      
      [ Upstream commit efc61345 ]
      
      When generic/371 is run on kvm-xfstests using 5.10 and 5.11 kernels, it
      fails at significant rates on the two test scenarios that disable
      delayed allocation (ext3conv and data_journal) and force actual block
      allocation for the fallocate and pwrite functions in the test.  The
      failure rate on 5.10 for both ext3conv and data_journal on one test
      system typically runs about 85%.  On 5.11, the failure rate on ext3conv
      sometimes drops to as low as 1% while the rate on data_journal
      increases to nearly 100%.
      
      The observed failures are largely due to ext4_should_retry_alloc()
      cutting off block allocation retries when s_mb_free_pending (used to
      indicate that a transaction in progress will free blocks) is 0.
      However, free space is usually available when this occurs during runs
      of generic/371.  It appears that a thread attempting to allocate
      blocks is just missing transaction commits in other threads that
      increase the free cluster count and reset s_mb_free_pending while
      the allocating thread isn't running.  Explicitly testing for free space
      availability avoids this race.
      
      The current code uses a post-increment operator in the conditional
      expression that determines whether the retry limit has been exceeded.
      This means that the conditional expression uses the value of the
      retry counter before it's increased, resulting in an extra retry cycle.
      The current code actually retries twice before hitting its retry limit
      rather than once.
      
      Increasing the retry limit to 3 from the current actual maximum retry
      count of 2 in combination with the change described above reduces the
      observed failure rate to less that 0.1% on both ext3conv and
      data_journal with what should be limited impact on users sensitive to
      the overhead caused by retries.
      
      A per filesystem percpu counter exported via sysfs is added to allow
      users or developers to track the number of times the retry limit is
      exceeded without resorting to debugging methods.  This should provide
      some insight into worst case retry behavior.
      Signed-off-by: NEric Whitney <enwlinux@gmail.com>
      Link: https://lore.kernel.org/r/20210218151132.19678-1-enwlinux@gmail.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: N  Weilong Chen <chenweilong@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      560f326e