CVE-2023-31436: A Deep Dive into the Out-of-Bounds Write Vulnerability in the Linux Kernel's qfq_change_class Function
CVE-2023-31436 is a critical vulnerability that has been discovered in the Linux kernel before version 6.2.13. This vulnerability allows cyber attackers to perform an out-of-bounds write operation because the lmax value can exceed the QFQ_MIN_LMAX limit. This vulnerability exists within the qfq_change_class function in the net/sched/sch_qfq.c file in the Linux kernel.
In this article, we will dig deeper into the details of this vulnerability, explore the code snippet associated with the vulnerability, provide links to original references, and go over the exploit information.
Code Snippet
Below is the code snippet showcasing the vulnerable part found in the qfq_change_class function in the net/sched/sch_qfq.c file:
static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
struct nlattr **tca, unsigned long *arg, bool ovr)
{
struct qfq_class *cl = (struct qfq_class *)*arg;
/* ... */
cl->lmax = nla_get_u32(tb[TCA_QFQ_LMAX]);
cl->lmax = max_t(u32, cl->lmax, QFQ_MIN_LMAX);
/* ... */
prorate_class(sch, cl, &cl->params, &curve_new, -cl->deficit);
/* ... */
}
In this code snippet, cl->lmax receives the value from nla_get_u32 function call, and then it is set to the maximum of its current value and QFQ_MIN_LMAX. However, the critical problem is that there is no control mechanism to ensure that the cl->lmax does not exceed the QFQ_MIN_LMAX limit, leading to the out-of-bounds write vulnerability.
Here are some primary sources and links to the original references for this vulnerability
1. Linux Kernel Git Repository - The complete source code for the Linux kernel, including the net/sched/sch_qfq.c file: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
2. National Vulnerability Database (NVD) Entry - The official disclosure of CVE-2023-31436: https://nvd.nist.gov/view/vuln/detail?vulnId=CVE-2023-31436
3. Documentations and Details on the Linux's qfq_change_class function - Provides technical information regarding the qfq_change_class function within the context of linux kernel development: https://elixir.bootlin.com/linux/latest/source/net/sched/sch_qfq.c#L181
Exploit Details
A successful exploitation of this vulnerability will potentially enable the attacker to compromise the integrity and stability of an affected Linux system. The absence of proper input validation and control on cl->lmax value might result in writing arbitrary data to an arbitrary memory location, possibly causing memory corruption, kernel crashes, or potentially allowing the attacker to elevate their privileges on the system.
Closing Thoughts
CVE-2023-31436 is a significant vulnerability that impacts the Linux kernel before version 6.2.13, targeting the qfq_change_class function within the net/sched/sch_qfq.c file. By exploiting the lack of control on lmax values and allowing it to exceed QFQ_MIN_LMAX, an attacker can cause out-of-bounds write issues, leading to potential kernel crashes, memory corruption, or privilege escalation.
It is essential for organizations and individuals using the Linux kernel to keep their systems up-to-date and apply patches as soon as they are available in order to mitigate such vulnerabilities and maintain the security and stability of their systems.
Timeline
Published on: 04/28/2023 02:15:00 UTC
Last modified on: 06/22/2023 15:15:00 UTC