1. 18 7月, 2023 2 次提交
    • Z
      ring-buffer: Fix deadloop issue on reading trace_pipe · e4403a7d
      Zheng Yejian 提交于
      mainline inclusion
      from mainline-v6.5-rc2
      commit 7e42907f3a7b4ce3a2d1757f6d78336984daf8f5
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7KXY9
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7e42907f3a7b4ce3a2d1757f6d78336984daf8f5
      
      ---------------------------
      
      Soft lockup occurs when reading file 'trace_pipe':
      
        watchdog: BUG: soft lockup - CPU#6 stuck for 22s! [cat:4488]
        [...]
        RIP: 0010:ring_buffer_empty_cpu+0xed/0x170
        RSP: 0018:ffff88810dd6fc48 EFLAGS: 00000246
        RAX: 0000000000000000 RBX: 0000000000000246 RCX: ffffffff93d1aaeb
        RDX: ffff88810a280040 RSI: 0000000000000008 RDI: ffff88811164b218
        RBP: ffff88811164b218 R08: 0000000000000000 R09: ffff88815156600f
        R10: ffffed102a2acc01 R11: 0000000000000001 R12: 0000000051651901
        R13: 0000000000000000 R14: ffff888115e49500 R15: 0000000000000000
        [...]
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007f8d853c2000 CR3: 000000010dcd8000 CR4: 00000000000006e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         __find_next_entry+0x1a8/0x4b0
         ? peek_next_entry+0x250/0x250
         ? down_write+0xa5/0x120
         ? down_write_killable+0x130/0x130
         trace_find_next_entry_inc+0x3b/0x1d0
         tracing_read_pipe+0x423/0xae0
         ? tracing_splice_read_pipe+0xcb0/0xcb0
         vfs_read+0x16b/0x490
         ksys_read+0x105/0x210
         ? __ia32_sys_pwrite64+0x200/0x200
         ? switch_fpu_return+0x108/0x220
         do_syscall_64+0x33/0x40
         entry_SYSCALL_64_after_hwframe+0x61/0xc6
      
      Through the vmcore, I found it's because in tracing_read_pipe(),
      ring_buffer_empty_cpu() found some buffer is not empty but then it
      cannot read anything due to "rb_num_of_entries() == 0" always true,
      Then it infinitely loop the procedure due to user buffer not been
      filled, see following code path:
      
        tracing_read_pipe() {
          ... ...
          waitagain:
            tracing_wait_pipe() // 1. find non-empty buffer here
            trace_find_next_entry_inc()  // 2. loop here try to find an entry
              __find_next_entry()
                ring_buffer_empty_cpu();  // 3. find non-empty buffer
                peek_next_entry()  // 4. but peek always return NULL
                  ring_buffer_peek()
                    rb_buffer_peek()
                      rb_get_reader_page()
                        // 5. because rb_num_of_entries() == 0 always true here
                        //    then return NULL
            // 6. user buffer not been filled so goto 'waitgain'
            //    and eventually leads to an deadloop in kernel!!!
        }
      
      By some analyzing, I found that when resetting ringbuffer, the 'entries'
      of its pages are not all cleared (see rb_reset_cpu()). Then when reducing
      the ringbuffer, and if some reduced pages exist dirty 'entries' data, they
      will be added into 'cpu_buffer->overrun' (see rb_remove_pages()), which
      cause wrong 'overrun' count and eventually cause the deadloop issue.
      
      To fix it, we need to clear every pages in rb_reset_cpu().
      
      Link: https://lore.kernel.org/linux-trace-kernel/20230708225144.3785600-1-zhengyejian1@huawei.com
      
      Cc: stable@vger.kernel.org
      Fixes: a5fb8331 ("ring-buffer: Fix uninitialized read_stamp")
      Signed-off-by: NZheng Yejian <zhengyejian1@huawei.com>
      Signed-off-by: NSteven Rostedt (Google) <rostedt@goodmis.org>
      Reviewed-by: NXu Kuohai <xukuohai@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      e4403a7d
    • O
      !1435 fix CVE-2023-3117 · 5a1a48ed
      openeuler-ci-bot 提交于
      Merge Pull Request from: @LiuYongQiang0816 
       
      3 patches from Lu Wei 
       
      Link:https://gitee.com/openeuler/kernel/pulls/1435 
      
      Reviewed-by: Yue Haibing <yuehaibing@huawei.com> 
      Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
      5a1a48ed
  2. 17 7月, 2023 5 次提交
  3. 14 7月, 2023 2 次提交
    • Z
      ext4: Add debug message to notify user space is out of free · 963b3ef7
      Zhihao Cheng 提交于
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7CBCS
      CVE: NA
      
      --------------------------------
      
      Add debug message to notify user that ext4_writepages is stuck in loop
      caused by ENOSPC.
      Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
      963b3ef7
    • Z
      Revert "ext4: Stop trying writing pages if no free blocks generated" · 62405f69
      Zhihao Cheng 提交于
      This reverts commit 6b84e9d9.
      
      When ext4 runs out of space, there could be a potential data lost in
      ext4_writepages:
      If there are many preallocated blocks for some files, e4b bitmap is
      different from block bitmap, and there are more free blocks accounted
      by block bitmap.
      
          ext4_writepages                         P2
      ext4_mb_new_blocks                  ext4_map_blocks
       ext4_mb_regular_allocator // No free bits in e4b bitmap
       ext4_mb_discard_preallocations_should_retry
        ext4_mb_discard_preallocations
         ext4_mb_discard_group_preallocations
          ext4_mb_release_inode_pa // updates e4b bitmap by pa->pa_free
           mb_free_blocks
                                           ext4_mb_new_blocks
                                            ext4_mb_regular_allocator
                                            // Got e4b bitmap's free bits
       ext4_mb_regular_allocator  // After 3 times retrying, ret ENOSPC
      
      ext4_writepages
       mpage_map_and_submit_extent
        mpage_map_one_extent // ret ENOSPC
        if (err == -ENOSPC && EXT4_SB(sb)->s_mb_free_pending)
        // s_mb_free_pending is 0
        *give_up_on_write = true  // Abandon writeback, data lost!
      
      Fixes: 6b84e9d9 ("ext4: Stop trying writing pages if no free ...")
      Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
      62405f69
  4. 13 7月, 2023 3 次提交
  5. 12 7月, 2023 3 次提交
  6. 11 7月, 2023 3 次提交
    • Z
      jbd2: Check 'jh->b_transaction' before remove it from checkpoint · a49943e0
      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)
      a49943e0
    • L
      etmem: fix the div 0 problem in swapcache reclaim process · 248e7033
      liubo 提交于
      euleros inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7JI6K
      CVE: NA
      
      ------------------------------------------------------------
      
      In the swapcache recycling process, the number of pages
      to be reclaimed on each node is obtained as follows:
      
      nr_to_reclaim[nid_num] = (swapcache_to_reclaim /
      			  (swapcache_total_reclaimable / nr[nid_num]));
      
      However, nr[nid_num] is obtained by traversing the number
      of swapcache pages on each node.
      If there are multiple nodes in the environment and
      no swap process occurs on a node, no swapcache page exists.
      The value of nr[nid_num] may be 0.
      
      Therefore, division by zero errors may occur.
      Signed-off-by: Nliubo <liubo254@huawei.com>
      248e7033
    • O
      !1361 fix CVE-2023-1295 · cb31b5b2
      openeuler-ci-bot 提交于
      Merge Pull Request from: @LiuYongQiang0816 
       
      3 patches from Li Nan 
       
      Link:https://gitee.com/openeuler/kernel/pulls/1361 
      
      Reviewed-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
      Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
      cb31b5b2
  7. 10 7月, 2023 3 次提交
  8. 08 7月, 2023 4 次提交
  9. 07 7月, 2023 15 次提交