1. 24 8月, 2023 4 次提交
  2. 23 8月, 2023 2 次提交
  3. 22 8月, 2023 6 次提交
  4. 21 8月, 2023 2 次提交
  5. 20 8月, 2023 1 次提交
    • S
      Bluetooth: L2CAP: Fix use-after-free in l2cap_sock_ready_cb · ba8196b0
      Sungwoo Kim 提交于
      stable inclusion
      from stable-v4.19.290
      commit 82cdb2ccbe43337798393369f0ceb98699fe6037
      category: bugfix
      bugzilla: 189135, https://gitee.com/src-openeuler/kernel/issues/I7SXVG
      CVE: CVE-2023-40283
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=82cdb2ccbe43337798393369f0ceb98699fe6037
      
      --------------------------------
      
      commit 1728137b33c00d5a2b5110ed7aafb42e7c32e4a1 upstream.
      
      l2cap_sock_release(sk) frees sk. However, sk's children are still alive
      and point to the already free'd sk's address.
      To fix this, l2cap_sock_release(sk) also cleans sk's children.
      
      ==================================================================
      BUG: KASAN: use-after-free in l2cap_sock_ready_cb+0xb7/0x100 net/bluetooth/l2cap_sock.c:1650
      Read of size 8 at addr ffff888104617aa8 by task kworker/u3:0/276
      
      CPU: 0 PID: 276 Comm: kworker/u3:0 Not tainted 6.2.0-00001-gef397bd4d5fb-dirty #59
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
      Workqueue: hci2 hci_rx_work
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x72/0x95 lib/dump_stack.c:106
       print_address_description mm/kasan/report.c:306 [inline]
       print_report+0x175/0x478 mm/kasan/report.c:417
       kasan_report+0xb1/0x130 mm/kasan/report.c:517
       l2cap_sock_ready_cb+0xb7/0x100 net/bluetooth/l2cap_sock.c:1650
       l2cap_chan_ready+0x10e/0x1e0 net/bluetooth/l2cap_core.c:1386
       l2cap_config_req+0x753/0x9f0 net/bluetooth/l2cap_core.c:4480
       l2cap_bredr_sig_cmd net/bluetooth/l2cap_core.c:5739 [inline]
       l2cap_sig_channel net/bluetooth/l2cap_core.c:6509 [inline]
       l2cap_recv_frame+0xe2e/0x43c0 net/bluetooth/l2cap_core.c:7788
       l2cap_recv_acldata+0x6ed/0x7e0 net/bluetooth/l2cap_core.c:8506
       hci_acldata_packet net/bluetooth/hci_core.c:3813 [inline]
       hci_rx_work+0x66e/0xbc0 net/bluetooth/hci_core.c:4048
       process_one_work+0x4ea/0x8e0 kernel/workqueue.c:2289
       worker_thread+0x364/0x8e0 kernel/workqueue.c:2436
       kthread+0x1b9/0x200 kernel/kthread.c:376
       ret_from_fork+0x2c/0x50 arch/x86/entry/entry_64.S:308
       </TASK>
      
      Allocated by task 288:
       kasan_save_stack+0x22/0x50 mm/kasan/common.c:45
       kasan_set_track+0x25/0x30 mm/kasan/common.c:52
       ____kasan_kmalloc mm/kasan/common.c:374 [inline]
       __kasan_kmalloc+0x82/0x90 mm/kasan/common.c:383
       kasan_kmalloc include/linux/kasan.h:211 [inline]
       __do_kmalloc_node mm/slab_common.c:968 [inline]
       __kmalloc+0x5a/0x140 mm/slab_common.c:981
       kmalloc include/linux/slab.h:584 [inline]
       sk_prot_alloc+0x113/0x1f0 net/core/sock.c:2040
       sk_alloc+0x36/0x3c0 net/core/sock.c:2093
       l2cap_sock_alloc.constprop.0+0x39/0x1c0 net/bluetooth/l2cap_sock.c:1852
       l2cap_sock_create+0x10d/0x220 net/bluetooth/l2cap_sock.c:1898
       bt_sock_create+0x183/0x290 net/bluetooth/af_bluetooth.c:132
       __sock_create+0x226/0x380 net/socket.c:1518
       sock_create net/socket.c:1569 [inline]
       __sys_socket_create net/socket.c:1606 [inline]
       __sys_socket_create net/socket.c:1591 [inline]
       __sys_socket+0x112/0x200 net/socket.c:1639
       __do_sys_socket net/socket.c:1652 [inline]
       __se_sys_socket net/socket.c:1650 [inline]
       __x64_sys_socket+0x40/0x50 net/socket.c:1650
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Freed by task 288:
       kasan_save_stack+0x22/0x50 mm/kasan/common.c:45
       kasan_set_track+0x25/0x30 mm/kasan/common.c:52
       kasan_save_free_info+0x2e/0x50 mm/kasan/generic.c:523
       ____kasan_slab_free mm/kasan/common.c:236 [inline]
       ____kasan_slab_free mm/kasan/common.c:200 [inline]
       __kasan_slab_free+0x10a/0x190 mm/kasan/common.c:244
       kasan_slab_free include/linux/kasan.h:177 [inline]
       slab_free_hook mm/slub.c:1781 [inline]
       slab_free_freelist_hook mm/slub.c:1807 [inline]
       slab_free mm/slub.c:3787 [inline]
       __kmem_cache_free+0x88/0x1f0 mm/slub.c:3800
       sk_prot_free net/core/sock.c:2076 [inline]
       __sk_destruct+0x347/0x430 net/core/sock.c:2168
       sk_destruct+0x9c/0xb0 net/core/sock.c:2183
       __sk_free+0x82/0x220 net/core/sock.c:2194
       sk_free+0x7c/0xa0 net/core/sock.c:2205
       sock_put include/net/sock.h:1991 [inline]
       l2cap_sock_kill+0x256/0x2b0 net/bluetooth/l2cap_sock.c:1257
       l2cap_sock_release+0x1a7/0x220 net/bluetooth/l2cap_sock.c:1428
       __sock_release+0x80/0x150 net/socket.c:650
       sock_close+0x19/0x30 net/socket.c:1368
       __fput+0x17a/0x5c0 fs/file_table.c:320
       task_work_run+0x132/0x1c0 kernel/task_work.c:179
       resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
       exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
       exit_to_user_mode_prepare+0x113/0x120 kernel/entry/common.c:203
       __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
       syscall_exit_to_user_mode+0x21/0x50 kernel/entry/common.c:296
       do_syscall_64+0x4c/0x90 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      The buggy address belongs to the object at ffff888104617800
       which belongs to the cache kmalloc-1k of size 1024
      The buggy address is located 680 bytes inside of
       1024-byte region [ffff888104617800, ffff888104617c00)
      
      The buggy address belongs to the physical page:
      page:00000000dbca6a80 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888104614000 pfn:0x104614
      head:00000000dbca6a80 order:2 compound_mapcount:0 subpages_mapcount:0 compound_pincount:0
      flags: 0x200000000010200(slab|head|node=0|zone=2)
      raw: 0200000000010200 ffff888100041dc0 ffffea0004212c10 ffffea0004234b10
      raw: ffff888104614000 0000000000080002 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff888104617980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff888104617a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      >ffff888104617a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
       ffff888104617b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff888104617b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      ==================================================================
      
      Ack: This bug is found by FuzzBT with a modified Syzkaller. Other
      contributors are Ruoyu Wu and Hui Peng.
      Signed-off-by: NSungwoo Kim <iam@sung-woo.kim>
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NDong Chenchen <dongchenchen2@huawei.com>
      ba8196b0
  6. 18 8月, 2023 2 次提交
  7. 15 8月, 2023 8 次提交
  8. 14 8月, 2023 9 次提交
  9. 10 8月, 2023 1 次提交
  10. 09 8月, 2023 1 次提交
    • L
      xfrm: add NULL check in xfrm_update_ae_params · 6f03ab1c
      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>
      6f03ab1c
  11. 08 8月, 2023 4 次提交