Linux Kernel GSM Multiplexing Race Condition Local Privilege Escalation Vulnerability (CVE-2023-6546)
A race condition in the Linux kernel's n_gsm tty line discipline allows two processes to trigger a use-after-free on a gsm_dlci object during mux restart. An attacker with local access could exploit this to execute arbitrary kernel code and escalate to root.
Published on github.com
BranchesTags
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a missing lock or improper synchronisation in the n_gsm mux restart path allows two threads to free and then use the same gsm_dlci object.
Impact
A local attacker could gain root privileges on affected systems, but the exploit requires a multi-core system with SMP enabled and version-specific offsets.
What the attacker needed
Local access to the system; multi-core system with SMP enabled; kernel with n_gsm line discipline available
How it was found
- Spawn two threads that each trigger the ioctl GSMIOC_SETCONF on the same tty file descriptor with the gsm line discipline enabled.
- Let the first thread proceed past the control message wait and block it in the wait for DLCI close.
- Allow the first thread to continue to gsm_cleanup_mux, which frees dlci[0].
- Spray the freed slab object with fake gsm_dlci structures using userfaultfd and add_key.
- Schedule the second thread so it uses the freed dlci object and calls gsm_dlci_begin_close.
- Through the controlled function pointer call, execute a payload that makes /usr/bin/python setuid root and spawn a root shell.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
This is a bug in a part of the Linux kernel that handles a special serial connection used by old mobile modems. Two programs can race to reset the connection at the same time, causing the kernel to use memory after it has been freed. A local attacker can then take over that memory and run their own code with the highest privileges.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.