In the Linux kernel, the following vulnerability has been resolved:
tty: n_gsm: Fix use-after-free in gsm_cleanup_mux
BUG: KASAN: slab-use-after-free in gsm_cleanup_mux+0x77b/0x7b0drivers/tty/n_gsm.c:3160 [n_gsm]
Read of size 8 at addr ffff88815fe99c00 by task poc/3379
CPU: 0 UID: 0 PID: 3379 Comm: poc Not tainted 6.11.0+ #56
Hardware name: VMware, Inc. VMware Virtual Platform/440BX
Desktop Reference Platform, BIOS 6.00 11/12/2020
Call Trace:<TASK>gsm_cleanup_mux+0x77b/0x7b0drivers/tty/n_gsm.c:3160 [n_gsm]
__pfx_gsm_cleanup_mux+0x10/0x10drivers/tty/n_gsm.c:3124 [n_gsm]
__pfx_sched_clock_cpu+0x10/0x10kernel/sched/clock.c:389update_load_avg+0x1c1/0x27b0kernel/sched/fair.c:4500__pfx_min_vruntime_cb_rotate+0x10/0x10kernel/sched/fair.c:846__rb_insert_augmented+0x492/0xbf0lib/rbtree.c:161gsmld_ioctl+0x395/0x1450drivers/tty/n_gsm.c:3408 [n_gsm]
_raw_spin_lock_irqsave+0x92/0xf0arch/x86/include/asm/atomic.h:107__pfx_gsmld_ioctl+0x10/0x10drivers/tty/n_gsm.c:3822 [n_gsm]
ktime_get+0x5e/0x140kernel/time/timekeeping.c:195ldsem_down_read+0x94/0x4e0arch/x86/include/asm/atomic64_64.h:79__pfx_ldsem_down_read+0x10/0x10drivers/tty/tty_ldsem.c:338__pfx_do_vfs_ioctl+0x10/0x10fs/ioctl.c:805tty_ioctl+0x643/0x1100drivers/tty/tty_io.c:2818Allocated by task 65:gsm_data_alloc.constprop.0+0x27/0x190drivers/tty/n_gsm.c:926 [n_gsm]
gsm_send+0x2c/0x580drivers/tty/n_gsm.c:819 [n_gsm]
gsm1_receive+0x547/0xad0drivers/tty/n_gsm.c:3038 [n_gsm]
gsmld_receive_buf+0x176/0x280drivers/tty/n_gsm.c:3609 [n_gsm]
tty_ldisc_receive_buf+0x101/0x1e0drivers/tty/tty_buffer.c:391tty_port_default_receive_buf+0x61/0xa0drivers/tty/tty_port.c:39flush_to_ldisc+0x1b0/0x750drivers/tty/tty_buffer.c:445process_scheduled_works+0x2b0/0x10d0kernel/workqueue.c:3229worker_thread+0x3dc/0x950kernel/workqueue.c:3391kthread+0x2a3/0x370kernel/kthread.c:389ret_from_fork+0x2d/0x70arch/x86/kernel/process.c:147ret_from_fork_asm+0x1a/0x30arch/x86/entry/entry_64.S:257Freed by task 3367:kfree+0x126/0x420mm/slub.c:4580gsm_cleanup_mux+0x36c/0x7b0drivers/tty/n_gsm.c:3160 [n_gsm]
gsmld_ioctl+0x395/0x1450drivers/tty/n_gsm.c:3408 [n_gsm]
tty_ioctl+0x643/0x1100drivers/tty/tty_io.c:2818
[Analysis]
gsm_msg on the tx_ctrl_list or tx_data_list of gsm_mux
can be freed by multi threads through ioctl,which leads
to the occurrence of uaf. Protect it by gsm tx lock.