1. 15 8月, 2023 5 次提交
  2. 14 8月, 2023 23 次提交
  3. 10 8月, 2023 1 次提交
    • L
      xfrm: add NULL check in xfrm_update_ae_params · cf6b2232
      Lin Ma 提交于
      mainline inclusion
      from mainline-v6.5-rc3
      commit 00374d9b6d9f932802b55181be9831aa948e5b7c
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I7NYWN
      CVE: CVE-2023-3772
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=00374d9b6d9f932802b55181be9831aa948e5b7c
      
      --------------------------------
      
      Normally, x->replay_esn and x->preplay_esn should be allocated at
      xfrm_alloc_replay_state_esn(...) in xfrm_state_construct(...), hence the
      xfrm_update_ae_params(...) is okay to update them. However, the current
      implementation of xfrm_new_ae(...) allows a malicious user to directly
      dereference a NULL pointer and crash the kernel like below.
      
      BUG: kernel NULL pointer dereference, address: 0000000000000000
      PGD 8253067 P4D 8253067 PUD 8e0e067 PMD 0
      Oops: 0002 [#1] PREEMPT SMP KASAN NOPTI
      CPU: 0 PID: 98 Comm: poc.npd Not tainted 6.4.0-rc7-00072-gdad9774d #8
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.o4
      RIP: 0010:memcpy_orig+0xad/0x140
      Code: e8 4c 89 5f e0 48 8d 7f e0 73 d2 83 c2 20 48 29 d6 48 29 d7 83 fa 10 72 34 4c 8b 06 4c 8b 4e 08 c
      RSP: 0018:ffff888008f57658 EFLAGS: 00000202
      RAX: 0000000000000000 RBX: ffff888008bd0000 RCX: ffffffff8238e571
      RDX: 0000000000000018 RSI: ffff888007f64844 RDI: 0000000000000000
      RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000000 R12: ffff888008f57818
      R13: ffff888007f64aa4 R14: 0000000000000000 R15: 0000000000000000
      FS:  00000000014013c0(0000) GS:ffff88806d600000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000000 CR3: 00000000054d8000 CR4: 00000000000006f0
      Call Trace:
       <TASK>
       ? __die+0x1f/0x70
       ? page_fault_oops+0x1e8/0x500
       ? __pfx_is_prefetch.constprop.0+0x10/0x10
       ? __pfx_page_fault_oops+0x10/0x10
       ? _raw_spin_unlock_irqrestore+0x11/0x40
       ? fixup_exception+0x36/0x460
       ? _raw_spin_unlock_irqrestore+0x11/0x40
       ? exc_page_fault+0x5e/0xc0
       ? asm_exc_page_fault+0x26/0x30
       ? xfrm_update_ae_params+0xd1/0x260
       ? memcpy_orig+0xad/0x140
       ? __pfx__raw_spin_lock_bh+0x10/0x10
       xfrm_update_ae_params+0xe7/0x260
       xfrm_new_ae+0x298/0x4e0
       ? __pfx_xfrm_new_ae+0x10/0x10
       ? __pfx_xfrm_new_ae+0x10/0x10
       xfrm_user_rcv_msg+0x25a/0x410
       ? __pfx_xfrm_user_rcv_msg+0x10/0x10
       ? __alloc_skb+0xcf/0x210
       ? stack_trace_save+0x90/0xd0
       ? filter_irq_stacks+0x1c/0x70
       ? __stack_depot_save+0x39/0x4e0
       ? __kasan_slab_free+0x10a/0x190
       ? kmem_cache_free+0x9c/0x340
       ? netlink_recvmsg+0x23c/0x660
       ? sock_recvmsg+0xeb/0xf0
       ? __sys_recvfrom+0x13c/0x1f0
       ? __x64_sys_recvfrom+0x71/0x90
       ? do_syscall_64+0x3f/0x90
       ? entry_SYSCALL_64_after_hwframe+0x72/0xdc
       ? copyout+0x3e/0x50
       netlink_rcv_skb+0xd6/0x210
       ? __pfx_xfrm_user_rcv_msg+0x10/0x10
       ? __pfx_netlink_rcv_skb+0x10/0x10
       ? __pfx_sock_has_perm+0x10/0x10
       ? mutex_lock+0x8d/0xe0
       ? __pfx_mutex_lock+0x10/0x10
       xfrm_netlink_rcv+0x44/0x50
       netlink_unicast+0x36f/0x4c0
       ? __pfx_netlink_unicast+0x10/0x10
       ? netlink_recvmsg+0x500/0x660
       netlink_sendmsg+0x3b7/0x700
      
      This Null-ptr-deref bug is assigned CVE-2023-3772. And this commit
      adds additional NULL check in xfrm_update_ae_params to fix the NPD.
      
      Fixes: d8647b79 ("xfrm: Add user interface for esn and big anti-replay windows")
      Signed-off-by: NLin Ma <linma@zju.edu.cn>
      Reviewed-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      
      Conflicts:
      	net/xfrm/xfrm_user.c
      Signed-off-by: NZhengchao Shao <shaozhengchao@huawei.com>
      (cherry picked from commit 5bfbef90)
      cf6b2232
  4. 09 8月, 2023 3 次提交
  5. 08 8月, 2023 6 次提交
  6. 07 8月, 2023 2 次提交
    • N
      ksmbd: fix out-of-bound read in deassemble_neg_contexts() · 180916a6
      Namjae Jeon 提交于
      mainline inclusion
      from mainline-v6.4-rc6
      commit f1a41187
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I7LU2Q
      CVE: CVE-2023-38427
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/fs/smb/server?id=f1a411873c85b642f13b01f21b534c2bab81fc1b
      
      --------------------------------
      
      The check in the beginning is
      `clen + sizeof(struct smb2_neg_context) <= len_of_ctxts`,
      but in the end of loop, `len_of_ctxts` will subtract
      `((clen + 7) & ~0x7) + sizeof(struct smb2_neg_context)`, which causes
      integer underflow when clen does the 8 alignment. We should use
      `(clen + 7) & ~0x7` in the check to avoid underflow from happening.
      
      Then there are some variables that need to be declared unsigned
      instead of signed.
      
      [   11.671070] BUG: KASAN: slab-out-of-bounds in smb2_handle_negotiate+0x799/0x1610
      [   11.671533] Read of size 2 at addr ffff888005e86cf2 by task kworker/0:0/7
      ...
      [   11.673383] Call Trace:
      [   11.673541]  <TASK>
      [   11.673679]  dump_stack_lvl+0x33/0x50
      [   11.673913]  print_report+0xcc/0x620
      [   11.674671]  kasan_report+0xae/0xe0
      [   11.675171]  kasan_check_range+0x35/0x1b0
      [   11.675412]  smb2_handle_negotiate+0x799/0x1610
      [   11.676217]  ksmbd_smb_negotiate_common+0x526/0x770
      [   11.676795]  handle_ksmbd_work+0x274/0x810
      ...
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NChih-Yen Chang <cc85nod@gmail.com>
      Tested-by: NChih-Yen Chang <cc85nod@gmail.com>
      Signed-off-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      
      Conflict:
        fs/smb/server/smb2pdu.c
      Signed-off-by: NLi Lingfeng <lilingfeng3@huawei.com>
      (cherry picked from commit 5df19222)
      180916a6
    • D
      media: usb: siano: Fix warning due to null work_func_t function pointer · 575fd2f3
      Duoming Zhou 提交于
      mainline inclusion
      from mainline-v6.5-rc1
      commit 6f489a966fbeb0da63d45c2c66a8957eab604bf6
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7QTMZ
      CVE: CVE-2023-4132
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6f489a966fbeb0da63d45c2c66a8957eab604bf6
      
      --------------------------------
      
      The previous commit ebad8e73 ("media: usb: siano: Fix use after
      free bugs caused by do_submit_urb") adds cancel_work_sync() in
      smsusb_stop_streaming(). But smsusb_stop_streaming() may be called,
      even if the work_struct surb->wq has not been initialized. As a result,
      the warning will occur. One of the processes that could lead to warning
      is shown below:
      
      smsusb_probe()
        smsusb_init_device()
          if (!dev->in_ep || !dev->out_ep || align < 0) {
               smsusb_term_device(intf);
                 smsusb_stop_streaming()
                   cancel_work_sync(&dev->surbs[i].wq);
                     __cancel_work_timer()
                       __flush_work()
                         if (WARN_ON(!work->func)) // work->func is null
      
      The log reported by syzbot is shown below:
      
      WARNING: CPU: 0 PID: 897 at kernel/workqueue.c:3066 __flush_work+0x798/0xa80 kernel/workqueue.c:3063
      Modules linked in:
      CPU: 0 PID: 897 Comm: kworker/0:2 Not tainted 6.2.0-rc1-syzkaller #0
      RIP: 0010:__flush_work+0x798/0xa80 kernel/workqueue.c:3066
      ...
      RSP: 0018:ffffc9000464ebf8 EFLAGS: 00010246
      RAX: 1ffff11002dbb420 RBX: 0000000000000021 RCX: 1ffffffff204fa4e
      RDX: dffffc0000000000 RSI: 0000000000000001 RDI: ffff888016dda0e8
      RBP: ffffc9000464ed98 R08: 0000000000000001 R09: ffffffff90253b2f
      R10: 0000000000000001 R11: 0000000000000000 R12: ffff888016dda0e8
      R13: ffff888016dda0e8 R14: ffff888016dda100 R15: 0000000000000001
      FS:  0000000000000000(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007ffd4331efe8 CR3: 000000000b48e000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       __cancel_work_timer+0x315/0x460 kernel/workqueue.c:3160
       smsusb_stop_streaming drivers/media/usb/siano/smsusb.c:182 [inline]
       smsusb_term_device+0xda/0x2d0 drivers/media/usb/siano/smsusb.c:344
       smsusb_init_device+0x400/0x9ce drivers/media/usb/siano/smsusb.c:419
       smsusb_probe+0xbbd/0xc55 drivers/media/usb/siano/smsusb.c:567
      ...
      
      This patch adds check before cancel_work_sync(). If surb->wq has not
      been initialized, the cancel_work_sync() will not be executed.
      
      Reported-by: syzbot+27b0b464864741b18b99@syzkaller.appspotmail.com
      Fixes: ebad8e73 ("media: usb: siano: Fix use after free bugs caused by do_submit_urb")
      Signed-off-by: NDuoming Zhou <duoming@zju.edu.cn>
      Signed-off-by: NHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: NRuan Jinjie <ruanjinjie@huawei.com>
      (cherry picked from commit d6a3c21a)
      575fd2f3