1. 19 7月, 2023 8 次提交
  2. 18 7月, 2023 11 次提交
  3. 17 7月, 2023 4 次提交
  4. 14 7月, 2023 5 次提交
  5. 13 7月, 2023 5 次提交
  6. 12 7月, 2023 7 次提交
    • Z
      jbd2: Check 'jh->b_transaction' before remove it from checkpoint · f4dbcd2d
      Zhihao Cheng 提交于
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I70WHL
      CVE: NA
      
      --------------------------------
      
      Following process will corrupt ext4 image:
      Step 1:
      jbd2_journal_commit_transaction
       __jbd2_journal_insert_checkpoint(jh, commit_transaction)
       // Put jh into trans1->t_checkpoint_list
       journal->j_checkpoint_transactions = commit_transaction
       // Put trans1 into journal->j_checkpoint_transactions
      
      Step 2:
      do_get_write_access
       test_clear_buffer_dirty(bh) // clear buffer dirty,set jbd dirty
       __jbd2_journal_file_buffer(jh, transaction) // jh belongs to trans2
      
      Step 3:
      drop_cache
       journal_shrink_one_cp_list
        jbd2_journal_try_remove_checkpoint
         if (!trylock_buffer(bh))  // lock bh, true
         if (buffer_dirty(bh))     // buffer is not dirty
         __jbd2_journal_remove_checkpoint(jh)
         // remove jh from trans1->t_checkpoint_list
      
      Step 4:
      jbd2_log_do_checkpoint
       trans1 = journal->j_checkpoint_transactions
       // jh is not in trans1->t_checkpoint_list
       jbd2_cleanup_journal_tail(journal)  // trans1 is done
      
      Step 5: Power cut, trans2 is not committed, jh is lost in next mounting.
      
      Fix it by checking 'jh->b_transaction' before remove it from checkpoint.
      
      Fixes: 80079353 ("jbd2: fix a race when checking checkpoint ...")
      Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
      (cherry picked from commit 7723e91d)
      f4dbcd2d
    • B
      quota: simplify drop_dquot_ref() · 86afeac9
      Baokun Li 提交于
      maillist inclusion
      category: bugfix
      bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR
      
      Reference: https://www.spinics.net/lists/kernel/msg4844759.html
      
      ----------------------------------------
      
      As Honza said, remove_inode_dquot_ref() currently does not release the
      last dquot reference but instead adds the dquot to tofree_head list. This
      is because dqput() can sleep while dropping of the last dquot reference
      (writing back the dquot and calling ->release_dquot()) and that must not
      happen under dq_list_lock. Now that dqput() queues the final dquot cleanup
      into a workqueue, remove_inode_dquot_ref() can call dqput() unconditionally
      and we can significantly simplify it.
      
      Here we open code the simplified code of remove_inode_dquot_ref() into
      remove_dquot_ref() and remove the function put_dquot_list() which is no
      longer used.
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      (cherry picked from commit a13fcef3)
      86afeac9
    • B
      quota: fix dqput() to follow the guarantees dquot_srcu should provide · 056c248c
      Baokun Li 提交于
      maillist inclusion
      category: bugfix
      bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR
      
      Reference: https://www.spinics.net/lists/kernel/msg4844759.html
      
      ----------------------------------------
      
      The dquot_mark_dquot_dirty() using dquot references from the inode
      should be protected by dquot_srcu. quota_off code takes care to call
      synchronize_srcu(&dquot_srcu) to not drop dquot references while they
      are used by other users. But dquot_transfer() breaks this assumption.
      We call dquot_transfer() to drop the last reference of dquot and add
      it to free_dquots, but there may still be other users using the dquot
      at this time, as shown in the function graph below:
      
             cpu1              cpu2
      _________________|_________________
      wb_do_writeback         CHOWN(1)
       ...
        ext4_da_update_reserve_space
         dquot_claim_block
          ...
           dquot_mark_dquot_dirty // try to dirty old quota
            test_bit(DQ_ACTIVE_B, &dquot->dq_flags) // still ACTIVE
            if (test_bit(DQ_MOD_B, &dquot->dq_flags))
            // test no dirty, wait dq_list_lock
                          ...
                           dquot_transfer
                            __dquot_transfer
                            dqput_all(transfer_from) // rls old dquot
                             dqput // last dqput
                              dquot_release
                               clear_bit(DQ_ACTIVE_B, &dquot->dq_flags)
                              atomic_dec(&dquot->dq_count)
                              put_dquot_last(dquot)
                               list_add_tail(&dquot->dq_free, &free_dquots)
                               // add the dquot to free_dquots
            if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags))
              add dqi_dirty_list // add released dquot to dirty_list
      
      This can cause various issues, such as dquot being destroyed by
      dqcache_shrink_scan() after being added to free_dquots, which can trigger
      a UAF in dquot_mark_dquot_dirty(); or after dquot is added to free_dquots
      and then to dirty_list, it is added to free_dquots again after
      dquot_writeback_dquots() is executed, which causes the free_dquots list to
      be corrupted and triggers a UAF when dqcache_shrink_scan() is called for
      freeing dquot twice.
      
      As Honza said, we need to fix dquot_transfer() to follow the guarantees
      dquot_srcu should provide. But calling synchronize_srcu() directly from
      dquot_transfer() is too expensive (and mostly unnecessary). So we add
      dquot whose last reference should be dropped to the new global dquot
      list releasing_dquots, and then queue work item which would call
      synchronize_srcu() and after that perform the final cleanup of all the
      dquots on releasing_dquots.
      
      Fixes: 4580b30e ("quota: Do not dirty bad dquots")
      Suggested-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      (cherry picked from commit d82ddaab)
      056c248c
    • B
      quota: add new helper dquot_active() · 4307a0d7
      Baokun Li 提交于
      maillist inclusion
      category: bugfix
      bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR
      
      Reference: https://www.spinics.net/lists/kernel/msg4844759.html
      
      ----------------------------------------
      
      Add new helper function dquot_active() to make the code more concise.
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      (cherry picked from commit 3fb7aa3a)
      4307a0d7
    • B
      quota: rename dquot_active() to inode_quota_active() · 73218f6c
      Baokun Li 提交于
      maillist inclusion
      category: bugfix
      bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR
      
      Reference: https://www.spinics.net/lists/kernel/msg4844759.html
      
      ----------------------------------------
      
      Now we have a helper function dquot_dirty() to determine if dquot has
      DQ_MOD_B bit. dquot_active() can easily be misunderstood as a helper
      function to determine if dquot has DQ_ACTIVE_B bit. So we avoid this by
      renaming it to inode_quota_active() and later on we will add the helper
      function dquot_active() to determine if dquot has DQ_ACTIVE_B bit.
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      (cherry picked from commit 329a1eb4)
      73218f6c
    • B
      quota: factor out dquot_write_dquot() · 347d528b
      Baokun Li 提交于
      maillist inclusion
      category: bugfix
      bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR
      
      Reference: https://www.spinics.net/lists/kernel/msg4844759.html
      
      ----------------------------------------
      
      Refactor out dquot_write_dquot() to reduce duplicate code.
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      (cherry picked from commit 0a3781ae)
      347d528b
    • O
      !1330 [sync] PR-1325: jbd2: fix several checkpoint · cedc20d7
      openeuler-ci-bot 提交于
      Merge Pull Request from: @openeuler-sync-bot 
       
      
      Origin pull request: 
      https://gitee.com/openeuler/kernel/pulls/1325 
       
      PR sync from: Zhihao Cheng <chengzhihao1@huawei.com>
      https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/QARA5X5OQUKRFUIORG2YVB6YE3V5CGQB/ 
      Zhang Yi (4):
        jbd2: remove journal_clean_one_cp_list()
        jbd2: fix a race when checking checkpoint buffer busy
        jbd2: remove __journal_try_to_free_buffer()
        jbd2: fix checkpoint cleanup performance regression
      
      Zhihao Cheng (1):
        jbd2: Fix wrongly judgement for buffer head removing while doing
          checkpoint
      
      
      -- 
      2.31.1
       
       
      Link:https://gitee.com/openeuler/kernel/pulls/1330 
      
      Reviewed-by: zhangyi (F) <yi.zhang@huawei.com> 
      Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
      cedc20d7