1. 18 1月, 2023 18 次提交
  2. 11 1月, 2023 7 次提交
  3. 06 1月, 2023 10 次提交
    • O
      !340 Backport CVEs and fs bugfixes · b57e6cba
      openeuler-ci-bot 提交于
      Merge Pull Request from: @zhangjialin11 
       
      Pull new CVEs:
        CVE-2022-2196
        CVE-2022-2873
        CVE-2022-47942
        CVE-2022-47943
        CVE-2022-47940
      
      fs bugfixes from Guo Xuenan and Li Nan:
      xfs: fix super block buf log item UAF during force shutdown
      xfs: wait iclog complete before tearing down AIL
      xfs: get rid of assert from xfs_btree_islastblock
      bfq: fix null-ptr-deref in bfq_pd_offline 
       
      Link:https://gitee.com/openeuler/kernel/pulls/340 
      Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> 
      Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> 
      b57e6cba
    • J
      KVM: VMX: Execute IBPB on emulated VM-exit when guest has IBRS · 04856b0e
      Jim Mattson 提交于
      mainline inclusion
      from mainline-v6.2-rc1
      commit 2e7eab81
      category: bugfix
      bugzilla: 188212
      CVE: CVE-2022-2196
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=2e7eab81425ad6c875f2ed47c0ce01e78afc38a5
      
      --------------------------------
      
      According to Intel's document on Indirect Branch Restricted
      Speculation, "Enabling IBRS does not prevent software from controlling
      the predicted targets of indirect branches of unrelated software
      executed later at the same predictor mode (for example, between two
      different user applications, or two different virtual machines). Such
      isolation can be ensured through use of the Indirect Branch Predictor
      Barrier (IBPB) command." This applies to both basic and enhanced IBRS.
      
      Since L1 and L2 VMs share hardware predictor modes (guest-user and
      guest-kernel), hardware IBRS is not sufficient to virtualize
      IBRS. (The way that basic IBRS is implemented on pre-eIBRS parts,
      hardware IBRS is actually sufficient in practice, even though it isn't
      sufficient architecturally.)
      
      For virtual CPUs that support IBRS, add an indirect branch prediction
      barrier on emulated VM-exit, to ensure that the predicted targets of
      indirect branches executed in L1 cannot be controlled by software that
      was executed in L2.
      
      Since we typically don't intercept guest writes to IA32_SPEC_CTRL,
      perform the IBPB at emulated VM-exit regardless of the current
      IA32_SPEC_CTRL.IBRS value, even though the IBPB could technically be
      deferred until L1 sets IA32_SPEC_CTRL.IBRS, if IA32_SPEC_CTRL.IBRS is
      clear at emulated VM-exit.
      
      This is CVE-2022-2196.
      
      Fixes: 5c911bef ("KVM: nVMX: Skip IBPB when switching between vmcs01 and vmcs02")
      Cc: Sean Christopherson <seanjc@google.com>
      Signed-off-by: NJim Mattson <jmattson@google.com>
      Reviewed-by: NSean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20221019213620.1953281-3-jmattson@google.comSigned-off-by: NSean Christopherson <seanjc@google.com>
      Signed-off-by: NChenXiaoSong <chenxiaosong2@huawei.com>
      Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      04856b0e
    • L
      bfq: fix null-ptr-deref in bfq_pd_offline · a9d49f94
      Li Nan 提交于
      hulk inclusion
      category: bugfix
      bugzilla: 188174, https://gitee.com/openeuler/kernel/issues/I677QO
      CVE: NA
      
      --------------------------------
      
      bfqg->bfqd is assigned in bfq_pd_init(). bfqg may be allocted but not
      initialized when bfq_pd_alloc() return NULL in blkcg_activate_policy().
      queue_lock is unlock now and delete cgroup at this time will cause error.
      
        T1					T2
        bfq_init_queue
         bfq_create_group_hierarchy
          blkcg_activate_policy
           traverse q->blkg_list
            1)pd_alloc_fn success
               blkg->pd[pol->plid] = pd
            2)pd_alloc_fn fail
               spin_unlock_irq(&q->queue_lock)
      	  -> 1)is alloced but not init
      					blkcg_destroy_blkgs
        					 blkg_destroy
        					  if blkg->pd[i]
        					   bfq_pd_offline
        					    use bfqg->bfqd -> error
      Signed-off-by: NLi Nan <linan122@huawei.com>
      Reviewed-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      a9d49f94
    • Z
      i2c: ismt: Fix an out-of-bounds bug in ismt_access() · 9da915fa
      Zheyu Ma 提交于
      stable inclusion
      from stable-v5.15.86
      commit 96c12fd0ec74641295e1c3c34dea3dce1b6c3422
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I5MZPE
      CVE: CVE-2022-2873
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.86&id=96c12fd0ec74641295e1c3c34dea3dce1b6c3422
      
      --------------------------------
      
      [ Upstream commit 39244cc7 ]
      
      When the driver does not check the data from the user, the variable
      'data->block[0]' may be very large to cause an out-of-bounds bug.
      
      The following log can reveal it:
      
      [   33.995542] i2c i2c-1: ioctl, cmd=0x720, arg=0x7ffcb3dc3a20
      [   33.995978] ismt_smbus 0000:00:05.0: I2C_SMBUS_BLOCK_DATA:  WRITE
      [   33.996475] ==================================================================
      [   33.996995] BUG: KASAN: out-of-bounds in ismt_access.cold+0x374/0x214b
      [   33.997473] Read of size 18446744073709551615 at addr ffff88810efcfdb1 by task ismt_poc/485
      [   33.999450] Call Trace:
      [   34.001849]  memcpy+0x20/0x60
      [   34.002077]  ismt_access.cold+0x374/0x214b
      [   34.003382]  __i2c_smbus_xfer+0x44f/0xfb0
      [   34.004007]  i2c_smbus_xfer+0x10a/0x390
      [   34.004291]  i2cdev_ioctl_smbus+0x2c8/0x710
      [   34.005196]  i2cdev_ioctl+0x5ec/0x74c
      
      Fix this bug by checking the size of 'data->block[0]' first.
      
      Fixes: 13f35ac1 ("i2c: Adding support for Intel iSMT SMBus 2.0 host controller")
      Signed-off-by: NZheyu Ma <zheyuma97@gmail.com>
      Signed-off-by: NWolfram Sang <wsa@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NGuo Mengqi <guomengqi3@huawei.com>
      Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
      Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      9da915fa
    • N
      ksmbd: fix heap-based overflow in set_ntacl_dacl() · 9bb7487f
      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>
      9bb7487f
    • H
      ksmbd: prevent out of bound read for SMB2_WRITE · 6bd39552
      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>
      6bd39552
    • M
      ksmbd: validate length in smb2_write() · 61dc2a2e
      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>
      61dc2a2e
    • G
      xfs: fix super block buf log item UAF during force shutdown · 5a5e896a
      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>
      5a5e896a
    • G
      xfs: wait iclog complete before tearing down AIL · 1146fdf4
      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>
      1146fdf4
    • G
      xfs: get rid of assert from xfs_btree_islastblock · be18cd15
      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>
      be18cd15
  4. 04 1月, 2023 5 次提交