1. 18 1月, 2023 8 次提交
  2. 11 1月, 2023 3 次提交
    • J
      io_uring: kill goto error handling in io_sqpoll_wait_sq() · f0d47ca5
      Jens Axboe 提交于
      stable inclusion
      from stable-v5.10.155
      commit 0f544353fec8e717d37724d95b92538e1de79e86
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I69NMA
      CVE: CVE-2022-47946
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0f544353fec8e717d37724d95b92538e1de79e86
      
      --------------------------------
      
      Hunk extracted from commit 70aacfe6
      upstream.
      
      If the sqpoll thread has died, the out condition doesn't remove the
      waiting task from the waitqueue. The goto and check are not needed, just
      make it a break condition after setting the error value. That ensures
      that we always remove ourselves from sqo_sq_wait waitqueue.
      Reported-by: NXingyuan Mo <hdthky0@gmail.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      f0d47ca5
    • B
      ext4: fix bad checksum after online resize · 44942478
      Baokun Li 提交于
      mainline inclusion
      from mainline-v6.2-rc1
      commit a408f33e
      category: bugfix
      bugzilla: 187935,https://gitee.com/src-openeuler/kernel/issues/I5ZR8Z
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a408f33e895e455f16cf964cb5cd4979b658db7b
      
      --------------------------------
      
      When online resizing is performed twice consecutively, the error message
      "Superblock checksum does not match superblock" is displayed for the
      second time. Here's the reproducer:
      
      	mkfs.ext4 -F /dev/sdb 100M
      	mount /dev/sdb /tmp/test
      	resize2fs /dev/sdb 5G
      	resize2fs /dev/sdb 6G
      
      To solve this issue, we moved the update of the checksum after the
      es->s_overhead_clusters is updated.
      
      Fixes: 026d0d27 ("ext4: reduce computation of overhead during resize")
      Fixes: de394a86 ("ext4: update s_overhead_clusters in the superblock during an on-line resize")
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Cc: stable@kernel.org
      Link: https://lore.kernel.org/r/20221117040341.1380702-2-libaokun1@huawei.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      
      Conflict:
      	fs/ext4/resize.c
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      44942478
    • D
      xfs: fix use-after-free in xattr node block inactivation · 63307509
      Darrick J. Wong 提交于
      mainline inclusion
      from mainline-v5.19-rc5
      commit 95ff0363
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=95ff0363f3f6ae70c21a0f2b0603e54438e5988b
      
      --------------------------------
      
      The kernel build robot reported a UAF error while running xfs/433
      (edited somewhat for brevity):
      
       BUG: KASAN: use-after-free in xfs_attr3_node_inactive (fs/xfs/xfs_attr_inactive.c:214) xfs
       Read of size 4 at addr ffff88820ac2bd44 by task kworker/0:2/139
      
       CPU: 0 PID: 139 Comm: kworker/0:2 Tainted: G S                5.19.0-rc2-00004-g7cf2b0f9 #1
       Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013
       Workqueue: xfs-inodegc/sdb4 xfs_inodegc_worker [xfs]
       Call Trace:
        <TASK>
       dump_stack_lvl (lib/dump_stack.c:107 (discriminator 1))
       print_address_description+0x1f/0x200
       print_report.cold (mm/kasan/report.c:430)
       kasan_report (mm/kasan/report.c:162 mm/kasan/report.c:493)
       xfs_attr3_node_inactive (fs/xfs/xfs_attr_inactive.c:214) xfs
       xfs_attr3_root_inactive (fs/xfs/xfs_attr_inactive.c:296) xfs
       xfs_attr_inactive (fs/xfs/xfs_attr_inactive.c:371) xfs
       xfs_inactive (fs/xfs/xfs_inode.c:1781) xfs
       xfs_inodegc_worker (fs/xfs/xfs_icache.c:1837 fs/xfs/xfs_icache.c:1860) xfs
       process_one_work
       worker_thread
       kthread
       ret_from_fork
        </TASK>
      
       Allocated by task 139:
       kasan_save_stack (mm/kasan/common.c:39)
       __kasan_slab_alloc (mm/kasan/common.c:45 mm/kasan/common.c:436 mm/kasan/common.c:469)
       kmem_cache_alloc (mm/slab.h:750 mm/slub.c:3214 mm/slub.c:3222 mm/slub.c:3229 mm/slub.c:3239)
       _xfs_buf_alloc (include/linux/instrumented.h:86 include/linux/atomic/atomic-instrumented.h:41 fs/xfs/xfs_buf.c:232) xfs
       xfs_buf_get_map (fs/xfs/xfs_buf.c:660) xfs
       xfs_buf_read_map (fs/xfs/xfs_buf.c:777) xfs
       xfs_trans_read_buf_map (fs/xfs/xfs_trans_buf.c:289) xfs
       xfs_da_read_buf (fs/xfs/libxfs/xfs_da_btree.c:2652) xfs
       xfs_da3_node_read (fs/xfs/libxfs/xfs_da_btree.c:392) xfs
       xfs_attr3_root_inactive (fs/xfs/xfs_attr_inactive.c:272) xfs
       xfs_attr_inactive (fs/xfs/xfs_attr_inactive.c:371) xfs
       xfs_inactive (fs/xfs/xfs_inode.c:1781) xfs
       xfs_inodegc_worker (fs/xfs/xfs_icache.c:1837 fs/xfs/xfs_icache.c:1860) xfs
       process_one_work
       worker_thread
       kthread
       ret_from_fork
      
       Freed by task 139:
       kasan_save_stack (mm/kasan/common.c:39)
       kasan_set_track (mm/kasan/common.c:45)
       kasan_set_free_info (mm/kasan/generic.c:372)
       __kasan_slab_free (mm/kasan/common.c:368 mm/kasan/common.c:328 mm/kasan/common.c:374)
       kmem_cache_free (mm/slub.c:1753 mm/slub.c:3507 mm/slub.c:3524)
       xfs_buf_rele (fs/xfs/xfs_buf.c:1040) xfs
       xfs_attr3_node_inactive (fs/xfs/xfs_attr_inactive.c:210) xfs
       xfs_attr3_root_inactive (fs/xfs/xfs_attr_inactive.c:296) xfs
       xfs_attr_inactive (fs/xfs/xfs_attr_inactive.c:371) xfs
       xfs_inactive (fs/xfs/xfs_inode.c:1781) xfs
       xfs_inodegc_worker (fs/xfs/xfs_icache.c:1837 fs/xfs/xfs_icache.c:1860) xfs
       process_one_work
       worker_thread
       kthread
       ret_from_fork
      
      I reproduced this for my own satisfaction, and got the same report,
      along with an extra morsel:
      
       The buggy address belongs to the object at ffff88802103a800
        which belongs to the cache xfs_buf of size 432
       The buggy address is located 396 bytes inside of
        432-byte region [ffff88802103a800, ffff88802103a9b0)
      
      I tracked this code down to:
      
      	error = xfs_trans_get_buf(*trans, mp->m_ddev_targp,
      			child_blkno,
      			XFS_FSB_TO_BB(mp, mp->m_attr_geo->fsbcount), 0,
      			&child_bp);
      	if (error)
      		return error;
      	error = bp->b_error;
      
      That doesn't look right -- I think this should be dereferencing
      child_bp, not bp.  Looking through the codebase history, I think this
      was added by commit 2911edb6 ("xfs: remove the mappedbno argument to
      xfs_da_get_buf"), which replaced a call to xfs_da_get_buf with the
      current call to xfs_trans_get_buf.  Not sure why we trans_brelse'd @bp
      earlier in the function, but I'm guessing it's to avoid pinning too many
      buffers in memory while we inactivate the bottom of the attr tree.
      Hence we now have to get the buffer back.
      
      I /think/ this was supposed to check child_bp->b_error and fail the rest
      of the invalidation if child_bp had experienced any kind of IO or
      corruption error.  I bet the xfs_da3_node_read earlier in the loop will
      catch most cases of incoming on-disk corruption which makes this check
      mostly moot unless someone corrupts the buffer and the AIL pushes it out
      to disk while the buffer's unlocked.
      
      In the first case we'll never get to the bad check, and in the second
      case the AIL will shut down the log, at which point there's no reason to
      check b_error.  Remove the check, and null out @bp to avoid this problem
      in the future.
      
      Cc: hch@lst.de
      Reported-by: Nkernel test robot <oliver.sang@intel.com>
      Fixes: 2911edb6 ("xfs: remove the mappedbno argument to xfs_da_get_buf")
      Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NLong Li <leo.lilong@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      63307509
  3. 06 1月, 2023 6 次提交
    • N
      ksmbd: fix heap-based overflow in set_ntacl_dacl() · 0e862a6c
      Namjae Jeon 提交于
      mainline inclusion
      from mainline-v5.19-rc7
      commit 8f054118
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I67AML
      CVE: CVE-2022-47942
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8f0541186e9ad1b62accc9519cc2b7a7240272a7
      
      --------------------------------
      
      The testcase use SMB2_SET_INFO_HE command to set a malformed file attribute
      under the label `security.NTACL`. SMB2_QUERY_INFO_HE command in testcase
      trigger the following overflow.
      
      [ 4712.003781] ==================================================================
      [ 4712.003790] BUG: KASAN: slab-out-of-bounds in build_sec_desc+0x842/0x1dd0 [ksmbd]
      [ 4712.003807] Write of size 1060 at addr ffff88801e34c068 by task kworker/0:0/4190
      
      [ 4712.003813] CPU: 0 PID: 4190 Comm: kworker/0:0 Not tainted 5.19.0-rc5 #1
      [ 4712.003850] Workqueue: ksmbd-io handle_ksmbd_work [ksmbd]
      [ 4712.003867] Call Trace:
      [ 4712.003870]  <TASK>
      [ 4712.003873]  dump_stack_lvl+0x49/0x5f
      [ 4712.003935]  print_report.cold+0x5e/0x5cf
      [ 4712.003972]  ? ksmbd_vfs_get_sd_xattr+0x16d/0x500 [ksmbd]
      [ 4712.003984]  ? cmp_map_id+0x200/0x200
      [ 4712.003988]  ? build_sec_desc+0x842/0x1dd0 [ksmbd]
      [ 4712.004000]  kasan_report+0xaa/0x120
      [ 4712.004045]  ? build_sec_desc+0x842/0x1dd0 [ksmbd]
      [ 4712.004056]  kasan_check_range+0x100/0x1e0
      [ 4712.004060]  memcpy+0x3c/0x60
      [ 4712.004064]  build_sec_desc+0x842/0x1dd0 [ksmbd]
      [ 4712.004076]  ? parse_sec_desc+0x580/0x580 [ksmbd]
      [ 4712.004088]  ? ksmbd_acls_fattr+0x281/0x410 [ksmbd]
      [ 4712.004099]  smb2_query_info+0xa8f/0x6110 [ksmbd]
      [ 4712.004111]  ? psi_group_change+0x856/0xd70
      [ 4712.004148]  ? update_load_avg+0x1c3/0x1af0
      [ 4712.004152]  ? asym_cpu_capacity_scan+0x5d0/0x5d0
      [ 4712.004157]  ? xas_load+0x23/0x300
      [ 4712.004162]  ? smb2_query_dir+0x1530/0x1530 [ksmbd]
      [ 4712.004173]  ? _raw_spin_lock_bh+0xe0/0xe0
      [ 4712.004179]  handle_ksmbd_work+0x30e/0x1020 [ksmbd]
      [ 4712.004192]  process_one_work+0x778/0x11c0
      [ 4712.004227]  ? _raw_spin_lock_irq+0x8e/0xe0
      [ 4712.004231]  worker_thread+0x544/0x1180
      [ 4712.004234]  ? __cpuidle_text_end+0x4/0x4
      [ 4712.004239]  kthread+0x282/0x320
      [ 4712.004243]  ? process_one_work+0x11c0/0x11c0
      [ 4712.004246]  ? kthread_complete_and_exit+0x30/0x30
      [ 4712.004282]  ret_from_fork+0x1f/0x30
      
      This patch add the buffer validation for security descriptor that is
      stored by malformed SMB2_SET_INFO_HE command. and allocate large
      response buffer about SMB2_O_INFO_SECURITY file info class.
      
      Fixes: e2f34481 ("cifsd: add server-side procedures for SMB3")
      Cc: stable@vger.kernel.org
      Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-17771
      Reviewed-by: NHyunchul Lee <hyc.lee@gmail.com>
      Signed-off-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      
      conflicts:
      	fs/ksmbd/smb2pdu.c
      	fs/ksmbd/smbacl.c
      	fs/ksmbd/smbacl.h
      	fs/ksmbd/vfs.c
      Signed-off-by: NLong Li <leo.lilong@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      (cherry picked from commit 9bb7487f)
      0e862a6c
    • H
      ksmbd: prevent out of bound read for SMB2_WRITE · ec3d0f21
      Hyunchul Lee 提交于
      mainline inclusion
      from mainline-v5.19-rc7
      commit ac60778b
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I67AMX
      CVE: CVE-2022-47943
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ac60778b87e45576d7bfdbd6f53df902654e6f09
      
      --------------------------------
      
      OOB read memory can be written to a file,
      if DataOffset is 0 and Length is too large
      in SMB2_WRITE request of compound request.
      
      To prevent this, when checking the length of
      the data area of SMB2_WRITE in smb2_get_data_area_len(),
      let the minimum of DataOffset be the size of
      SMB2 header + the size of SMB2_WRITE header.
      
      This bug can lead an oops looking something like:
      
      [  798.008715] BUG: KASAN: slab-out-of-bounds in copy_page_from_iter_atomic+0xd3d/0x14b0
      [  798.008724] Read of size 252 at addr ffff88800f863e90 by task kworker/0:2/2859
      ...
      [  798.008754] Call Trace:
      [  798.008756]  <TASK>
      [  798.008759]  dump_stack_lvl+0x49/0x5f
      [  798.008764]  print_report.cold+0x5e/0x5cf
      [  798.008768]  ? __filemap_get_folio+0x285/0x6d0
      [  798.008774]  ? copy_page_from_iter_atomic+0xd3d/0x14b0
      [  798.008777]  kasan_report+0xaa/0x120
      [  798.008781]  ? copy_page_from_iter_atomic+0xd3d/0x14b0
      [  798.008784]  kasan_check_range+0x100/0x1e0
      [  798.008788]  memcpy+0x24/0x60
      [  798.008792]  copy_page_from_iter_atomic+0xd3d/0x14b0
      [  798.008795]  ? pagecache_get_page+0x53/0x160
      [  798.008799]  ? iov_iter_get_pages_alloc+0x1590/0x1590
      [  798.008803]  ? ext4_write_begin+0xfc0/0xfc0
      [  798.008807]  ? current_time+0x72/0x210
      [  798.008811]  generic_perform_write+0x2c8/0x530
      [  798.008816]  ? filemap_fdatawrite_wbc+0x180/0x180
      [  798.008820]  ? down_write+0xb4/0x120
      [  798.008824]  ? down_write_killable+0x130/0x130
      [  798.008829]  ext4_buffered_write_iter+0x137/0x2c0
      [  798.008833]  ext4_file_write_iter+0x40b/0x1490
      [  798.008837]  ? __fsnotify_parent+0x275/0xb20
      [  798.008842]  ? __fsnotify_update_child_dentry_flags+0x2c0/0x2c0
      [  798.008846]  ? ext4_buffered_write_iter+0x2c0/0x2c0
      [  798.008851]  __kernel_write+0x3a1/0xa70
      [  798.008855]  ? __x64_sys_preadv2+0x160/0x160
      [  798.008860]  ? security_file_permission+0x4a/0xa0
      [  798.008865]  kernel_write+0xbb/0x360
      [  798.008869]  ksmbd_vfs_write+0x27e/0xb90 [ksmbd]
      [  798.008881]  ? ksmbd_vfs_read+0x830/0x830 [ksmbd]
      [  798.008892]  ? _raw_read_unlock+0x2a/0x50
      [  798.008896]  smb2_write+0xb45/0x14e0 [ksmbd]
      [  798.008909]  ? __kasan_check_write+0x14/0x20
      [  798.008912]  ? _raw_spin_lock_bh+0xd0/0xe0
      [  798.008916]  ? smb2_read+0x15e0/0x15e0 [ksmbd]
      [  798.008927]  ? memcpy+0x4e/0x60
      [  798.008931]  ? _raw_spin_unlock+0x19/0x30
      [  798.008934]  ? ksmbd_smb2_check_message+0x16af/0x2350 [ksmbd]
      [  798.008946]  ? _raw_spin_lock_bh+0xe0/0xe0
      [  798.008950]  handle_ksmbd_work+0x30e/0x1020 [ksmbd]
      [  798.008962]  process_one_work+0x778/0x11c0
      [  798.008966]  ? _raw_spin_lock_irq+0x8e/0xe0
      [  798.008970]  worker_thread+0x544/0x1180
      [  798.008973]  ? __cpuidle_text_end+0x4/0x4
      [  798.008977]  kthread+0x282/0x320
      [  798.008982]  ? process_one_work+0x11c0/0x11c0
      [  798.008985]  ? kthread_complete_and_exit+0x30/0x30
      [  798.008989]  ret_from_fork+0x1f/0x30
      [  798.008995]  </TASK>
      
      Fixes: e2f34481 ("cifsd: add server-side procedures for SMB3")
      Cc: stable@vger.kernel.org
      Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-17817
      Signed-off-by: NHyunchul Lee <hyc.lee@gmail.com>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      
      conflicts:
      	fs/ksmbd/smb2pdu.c
      Signed-off-by: NLong Li <leo.lilong@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      (cherry picked from commit 6bd39552)
      ec3d0f21
    • M
      ksmbd: validate length in smb2_write() · 69e24ac7
      Marios Makassikis 提交于
      mainline inclusion
      from mainline-v5.18-rc6
      commit 158a66b2
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I67AMR
      CVE: CVE-2022-47940
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=158a66b245739e15858de42c0ba60fcf3de9b8e6
      
      --------------------------------
      
      The SMB2 Write packet contains data that is to be written
      to a file or to a pipe. Depending on the client, there may
      be padding between the header and the data field.
      Currently, the length is validated only in the case padding
      is present.
      
      Since the DataOffset field always points to the beginning
      of the data, there is no need to have a special case for
      padding. By removing this, the length is validated in both
      cases.
      Signed-off-by: NMarios Makassikis <mmakassikis@freebox.fr>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      
      conflicts:
      	fs/ksmbd/smb2pdu.c
      Signed-off-by: NLong Li <leo.lilong@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      (cherry picked from commit 61dc2a2e)
      69e24ac7
    • G
      xfs: fix super block buf log item UAF during force shutdown · 766ae6eb
      Guo Xuenan 提交于
      mainline inclusion
      from mainline-v6.1-rc4
      commit 575689fc
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=575689fc0ffa6c4bb4e72fd18e31a6525a6124e0
      
      --------------------------------
      
      xfs log io error will trigger xlog shut down, and end_io worker call
      xlog_state_shutdown_callbacks to unpin and release the buf log item.
      The race condition is that when there are some thread doing transaction
      commit and happened not to be intercepted by xlog_is_shutdown, then,
      these log item will be insert into CIL, when unpin and release these
      buf log item, UAF will occur. BTW, add delay before `xlog_cil_commit`
      can increase recurrence probability.
      
      The following call graph actually encountered this bad situation.
      fsstress                    io end worker kworker/0:1H-216
                                  xlog_ioend_work
                                    ->xlog_force_shutdown
                                      ->xlog_state_shutdown_callbacks
                                        ->xlog_cil_process_committed
                                          ->xlog_cil_committed
                                            ->xfs_trans_committed_bulk
      ->xfs_trans_apply_sb_deltas             ->li_ops->iop_unpin(lip, 1);
        ->xfs_trans_getsb
          ->_xfs_trans_bjoin
            ->xfs_buf_item_init
              ->if (bip) { return 0;} //relog
      ->xlog_cil_commit
        ->xlog_cil_insert_items //insert into CIL
                                                 ->xfs_buf_ioend_fail(bp);
                                                   ->xfs_buf_ioend
                                                     ->xfs_buf_item_done
                                                       ->xfs_buf_item_relse
                                                         ->xfs_buf_item_free
      
      when cil push worker gather percpu cil and insert super block buf log item
      into ctx->log_items then uaf occurs.
      
      ==================================================================
      BUG: KASAN: use-after-free in xlog_cil_push_work+0x1c8f/0x22f0
      Write of size 8 at addr ffff88801800f3f0 by task kworker/u4:4/105
      
      CPU: 0 PID: 105 Comm: kworker/u4:4 Tainted: G W
      6.1.0-rc1-00001-g274115149b42 #136
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      1.13.0-1ubuntu1.1 04/01/2014
      Workqueue: xfs-cil/sda xlog_cil_push_work
      Call Trace:
       <TASK>
       dump_stack_lvl+0x4d/0x66
       print_report+0x171/0x4a6
       kasan_report+0xb3/0x130
       xlog_cil_push_work+0x1c8f/0x22f0
       process_one_work+0x6f9/0xf70
       worker_thread+0x578/0xf30
       kthread+0x28c/0x330
       ret_from_fork+0x1f/0x30
       </TASK>
      
      Allocated by task 2145:
       kasan_save_stack+0x1e/0x40
       kasan_set_track+0x21/0x30
       __kasan_slab_alloc+0x54/0x60
       kmem_cache_alloc+0x14a/0x510
       xfs_buf_item_init+0x160/0x6d0
       _xfs_trans_bjoin+0x7f/0x2e0
       xfs_trans_getsb+0xb6/0x3f0
       xfs_trans_apply_sb_deltas+0x1f/0x8c0
       __xfs_trans_commit+0xa25/0xe10
       xfs_symlink+0xe23/0x1660
       xfs_vn_symlink+0x157/0x280
       vfs_symlink+0x491/0x790
       do_symlinkat+0x128/0x220
       __x64_sys_symlink+0x7a/0x90
       do_syscall_64+0x35/0x80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Freed by task 216:
       kasan_save_stack+0x1e/0x40
       kasan_set_track+0x21/0x30
       kasan_save_free_info+0x2a/0x40
       __kasan_slab_free+0x105/0x1a0
       kmem_cache_free+0xb6/0x460
       xfs_buf_ioend+0x1e9/0x11f0
       xfs_buf_item_unpin+0x3d6/0x840
       xfs_trans_committed_bulk+0x4c2/0x7c0
       xlog_cil_committed+0xab6/0xfb0
       xlog_cil_process_committed+0x117/0x1e0
       xlog_state_shutdown_callbacks+0x208/0x440
       xlog_force_shutdown+0x1b3/0x3a0
       xlog_ioend_work+0xef/0x1d0
       process_one_work+0x6f9/0xf70
       worker_thread+0x578/0xf30
       kthread+0x28c/0x330
       ret_from_fork+0x1f/0x30
      
      The buggy address belongs to the object at ffff88801800f388
       which belongs to the cache xfs_buf_item of size 272
      The buggy address is located 104 bytes inside of
       272-byte region [ffff88801800f388, ffff88801800f498)
      
      The buggy address belongs to the physical page:
      page:ffffea0000600380 refcount:1 mapcount:0 mapping:0000000000000000
      index:0xffff88801800f208 pfn:0x1800e
      head:ffffea0000600380 order:1 compound_mapcount:0 compound_pincount:0
      flags: 0x1fffff80010200(slab|head|node=0|zone=1|lastcpupid=0x1fffff)
      raw: 001fffff80010200 ffffea0000699788 ffff88801319db50 ffff88800fb50640
      raw: ffff88801800f208 000000000015000a 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff88801800f280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff88801800f300: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc
      >ffff88801800f380: fc fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                   ^
       ffff88801800f400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff88801800f480: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc
      ==================================================================
      Disabling lock debugging due to kernel taint
      Signed-off-by: NGuo Xuenan <guoxuenan@huawei.com>
      Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: NGuo Xuenan <guoxuenan@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      (cherry picked from commit 5a5e896a)
      766ae6eb
    • G
      xfs: wait iclog complete before tearing down AIL · fabfebe7
      Guo Xuenan 提交于
      mainline inclusion
      from mainline-v6.1-rc4
      commit 1eb52a6a
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1eb52a6a71981b80f9acbd915acd6a05a5037196
      
      --------------------------------
      
      Fix uaf in xfs_trans_ail_delete during xlog force shutdown.
      In commit cd6f79d1 ("xfs: run callbacks before waking waiters in
      xlog_state_shutdown_callbacks") changed the order of running callbacks
      and wait for iclog completion to avoid unmount path untimely destroy AIL.
      But which seems not enough to ensue this, adding mdelay in
      `xfs_buf_item_unpin` can prove that.
      
      The reproduction is as follows. To ensure destroy AIL safely,
      we should wait all xlog ioend workers done and sync the AIL.
      
      ==================================================================
      BUG: KASAN: use-after-free in xfs_trans_ail_delete+0x240/0x2a0
      Read of size 8 at addr ffff888023169400 by task kworker/1:1H/43
      
      CPU: 1 PID: 43 Comm: kworker/1:1H Tainted: G        W
      6.1.0-rc1-00002-gc28266863c4a #137
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      1.13.0-1ubuntu1.1 04/01/2014
      Workqueue: xfs-log/sda xlog_ioend_work
      Call Trace:
       <TASK>
       dump_stack_lvl+0x4d/0x66
       print_report+0x171/0x4a6
       kasan_report+0xb3/0x130
       xfs_trans_ail_delete+0x240/0x2a0
       xfs_buf_item_done+0x7b/0xa0
       xfs_buf_ioend+0x1e9/0x11f0
       xfs_buf_item_unpin+0x4c8/0x860
       xfs_trans_committed_bulk+0x4c2/0x7c0
       xlog_cil_committed+0xab6/0xfb0
       xlog_cil_process_committed+0x117/0x1e0
       xlog_state_shutdown_callbacks+0x208/0x440
       xlog_force_shutdown+0x1b3/0x3a0
       xlog_ioend_work+0xef/0x1d0
       process_one_work+0x6f9/0xf70
       worker_thread+0x578/0xf30
       kthread+0x28c/0x330
       ret_from_fork+0x1f/0x30
       </TASK>
      
      Allocated by task 9606:
       kasan_save_stack+0x1e/0x40
       kasan_set_track+0x21/0x30
       __kasan_kmalloc+0x7a/0x90
       __kmalloc+0x59/0x140
       kmem_alloc+0xb2/0x2f0
       xfs_trans_ail_init+0x20/0x320
       xfs_log_mount+0x37e/0x690
       xfs_mountfs+0xe36/0x1b40
       xfs_fs_fill_super+0xc5c/0x1a70
       get_tree_bdev+0x3c5/0x6c0
       vfs_get_tree+0x85/0x250
       path_mount+0xec3/0x1830
       do_mount+0xef/0x110
       __x64_sys_mount+0x150/0x1f0
       do_syscall_64+0x35/0x80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Freed by task 9662:
       kasan_save_stack+0x1e/0x40
       kasan_set_track+0x21/0x30
       kasan_save_free_info+0x2a/0x40
       __kasan_slab_free+0x105/0x1a0
       __kmem_cache_free+0x99/0x2d0
       kvfree+0x3a/0x40
       xfs_log_unmount+0x60/0xf0
       xfs_unmountfs+0xf3/0x1d0
       xfs_fs_put_super+0x78/0x300
       generic_shutdown_super+0x151/0x400
       kill_block_super+0x9a/0xe0
       deactivate_locked_super+0x82/0xe0
       deactivate_super+0x91/0xb0
       cleanup_mnt+0x32a/0x4a0
       task_work_run+0x15f/0x240
       exit_to_user_mode_prepare+0x188/0x190
       syscall_exit_to_user_mode+0x12/0x30
       do_syscall_64+0x42/0x80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      The buggy address belongs to the object at ffff888023169400
       which belongs to the cache kmalloc-128 of size 128
      The buggy address is located 0 bytes inside of
       128-byte region [ffff888023169400, ffff888023169480)
      
      The buggy address belongs to the physical page:
      page:ffffea00008c5a00 refcount:1 mapcount:0 mapping:0000000000000000
      index:0xffff888023168f80 pfn:0x23168
      head:ffffea00008c5a00 order:1 compound_mapcount:0 compound_pincount:0
      flags: 0x1fffff80010200(slab|head|node=0|zone=1|lastcpupid=0x1fffff)
      raw: 001fffff80010200 ffffea00006b3988 ffffea0000577a88 ffff88800f842ac0
      raw: ffff888023168f80 0000000000150007 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff888023169300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff888023169380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      >ffff888023169400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
       ffff888023169480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff888023169500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      ==================================================================
      Disabling lock debugging due to kernel taint
      
      Fixes: cd6f79d1 ("xfs: run callbacks before waking waiters in xlog_state_shutdown_callbacks")
      Signed-off-by: NGuo Xuenan <guoxuenan@huawei.com>
      Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: NGuo Xuenan <guoxuenan@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      (cherry picked from commit 1146fdf4)
      fabfebe7
    • G
      xfs: get rid of assert from xfs_btree_islastblock · 837215b2
      Guo Xuenan 提交于
      mainline inclusion
      from mainline-v6.1-rc4
      commit 8c25febf
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8c25febf23963431686f04874b96321288504127
      
      --------------------------------
      
      xfs_btree_check_block contains debugging knobs. With XFS_DEBUG setting up,
      turn on the debugging knob can trigger the assert of xfs_btree_islastblock,
      test script as follows:
      
      while true
      do
          mount $disk $mountpoint
          fsstress -d $testdir -l 0 -n 10000 -p 4 >/dev/null
          echo 1 > /sys/fs/xfs/sda/errortag/btree_chk_sblk
          sleep 10
          umount $mountpoint
      done
      
      Kick off fsstress and only *then* turn on the debugging knob. If it
      happens that the knob gets turned on after the cntbt lookup succeeds
      but before the call to xfs_btree_islastblock, then we *can* end up in
      the situation where a previously checked btree block suddenly starts
      returning EFSCORRUPTED from xfs_btree_check_block. Kaboom.
      
      Darrick give a very detailed explanation as follows:
      Looking back at commit 27d9ee57, I think the point of all this was
      to make sure that the cursor has actually performed a lookup, and that
      the btree block at whatever level we're asking about is ok.
      
      If the caller hasn't ever done a lookup, the bc_levels array will be
      empty, so cur->bc_levels[level].bp pointer will be NULL.  The call to
      xfs_btree_get_block will crash anyway, so the "ASSERT(block);" part is
      pointless.
      
      If the caller did a lookup but the lookup failed due to block
      corruption, the corresponding cur->bc_levels[level].bp pointer will also
      be NULL, and we'll still crash.  The "ASSERT(xfs_btree_check_block);"
      logic is also unnecessary.
      
      If the cursor level points to an inode root, the block buffer will be
      incore, so it had better always be consistent.
      
      If the caller ignores a failed lookup after a successful one and calls
      this function, the cursor state is garbage and the assert wouldn't have
      tripped anyway. So get rid of the assert.
      
      Fixes: 27d9ee57 ("xfs: actually check xfs_btree_check_block return in xfs_btree_islastblock")
      Signed-off-by: NGuo Xuenan <guoxuenan@huawei.com>
      Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: NGuo Xuenan <guoxuenan@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      (cherry picked from commit be18cd15)
      837215b2
  4. 04 1月, 2023 11 次提交
  5. 13 12月, 2022 1 次提交
  6. 08 12月, 2022 2 次提交
    • W
      arm64/mpam: remove kernfs_get() calls() and add kernfs_put() calls to prevent refcount leak · 84f77990
      Wang ShaoBo 提交于
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I61CPK
      CVE: NA
      
      --------------------------------
      
      Refer to the two commits:
      
        commit fd8d9db3 ("x86/resctrl: Remove superfluous kernfs_get() calls
        to prevent refcount leak")
      
        commit 75899924 ("x86/resctrl: Add necessary kernfs_put() calls to
        prevent refcount leak")
      
      there are some places where a kernfs_node reference is obtained
      without a corresponding release. The excessive amount of reference
      count on kernfs nodes will never be dropped to 0 and the kernfs nodes
      will never be freed in the call paths of rmdir and umount.
      It leads to reference count leak and kernfs_node_cache memory leak.
      
      For example, reference count leak is observed in these two cases:
      
        (1) mount -t resctrl none /sys/fs/resctrl
            mkdir /sys/fs/resctrl/c1
            mkdir /sys/fs/resctrl/c1/mon_groups/m1
            umount /sys/fs/resctrl
      
        (2) mkdir /sys/fs/resctrl/c1
            mkdir /sys/fs/resctrl/c1/mon_groups/m1
            rmdir /sys/fs/resctrl/c1
      
      Superfluous kernfs_get() calls are removed from two areas:
      
        (1) In call paths of mount and mkdir, when kernfs nodes for "info",
        "mon_groups" and "mon_data" directories and sub-directories are
        created, the reference count of newly created kernfs node is set to 1.
        But after kernfs_create_dir() returns, superfluous kernfs_get() are
        called to take an additional reference.
      
        (2) kernfs_get() calls in rmdir call paths.
      
      Necessary kernfs_put() calls are added by following changes:
      
        (1) Introduce rdtgroup removal helper rdtgroup_remove() to wrap up
        kernfs_put() and kfree().
      
        (2) Call rdtgroup_remove() in rdtgroup removal path where the rdtgroup
        structure is about to be freed by kfree().
      
        (3) Call rdtgroup_remove() or kernfs_put() as appropriate in the error
        exit paths of mkdir where an extra reference is taken by kernfs_get().
      Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
      Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      84f77990
    • W
      arm64/mpam: Fix indent format error in resctrl_parse_param() · 68dc7081
      Wang ShaoBo 提交于
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I61CPK
      CVE: NA
      
      --------------------------------
      
      This fixes indent format error in resctrl_parse_param():
       fs/resctrlfs.c:616 resctrl_parse_param() warn: ignoring unreachable code.
       fs/resctrlfs.c:616 resctrl_parse_param() warn: inconsistent indenting
       fs/resctrlfs.c:619 resctrl_parse_param() warn: inconsistent indenting
      
      Fixes: 100e2317 ("arm64/mpam: Use fs_context to parse mount options")
      Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
      Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      68dc7081
  7. 02 12月, 2022 9 次提交