1. 31 7月, 2023 1 次提交
  2. 11 7月, 2023 2 次提交
  3. 06 1月, 2023 3 次提交
    • 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
  4. 25 11月, 2022 34 次提交