CVE-2024-36899
Linux Kernel: GPIOlib: Use-After-Free Vulnerability in GPIO Chip Device File Closure
Description
In the Linux kernel, the following vulnerability has been resolved: gpiolib: cdev: Fix use after free in lineinfo_changed_notify The use-after-free issue occurs as follows: when the GPIO chip device file is being closed by invoking gpio_chrdev_release(), watched_lines is freed by bitmap_free(), but the unregistration of lineinfo_changed_nb notifier chain failed due to waiting write rwsem. Additionally, one of the GPIO chip's lines is also in the release process and holds the notifier chain's read rwsem. Consequently, a race condition leads to the use-after-free of watched_lines. Here is the typical stack when issue happened: [free] gpio_chrdev_release() --> bitmap_free(cdev->watched_lines) <-- freed --> blocking_notifier_chain_unregister() --> down_write(&nh->rwsem) <-- waiting rwsem --> __down_write_common() --> rwsem_down_write_slowpath() --> schedule_preempt_disabled() --> schedule() [use] st54spi_gpio_dev_release() --> gpio_free() --> gpiod_free() --> gpiod_free_commit() --> gpiod_line_state_notify() --> blocking_notifier_call_chain() --> down_read(&nh->rwsem); <-- held rwsem --> notifier_call_chain() --> lineinfo_changed_notify() --> test_bit(xxxx, cdev->watched_lines) <-- use after free The side effect of the use-after-free issue is that a GPIO line event is being generated for userspace where it shouldn't. However, since the chrdev is being closed, userspace won't have the chance to read that event anyway. To fix the issue, call the bitmap_free() function after the unregistration of lineinfo_changed_nb notifier chain.
INFO
Published Date :
May 30, 2024, 4:15 p.m.
Last Modified :
Feb. 2, 2025, 11:15 a.m.
Source :
416baaa9-dc9f-4396-8d5f-8c081fb06d67
Remotely Exploitable :
No
Impact Score :
5.9
Exploitability Score :
1.0
Public PoC/Exploit Available at Github
CVE-2024-36899 has a 1 public PoC/Exploit
available at Github.
Go to the Public Exploits
tab to see the list.
References to Advisories, Solutions, and Tools
Here, you will find a curated list of external links that provide in-depth
information, practical solutions, and valuable tools related to
CVE-2024-36899
.
We scan GitHub repositories to detect new proof-of-concept exploits. Following list is a collection of public exploits and proof-of-concepts, which have been published on GitHub (sorted by the most recently updated).
DSA and DLA for Debian last 14 days
Python
Results are limited to the first 15 repositories due to potential performance issues.
The following list is the news that have been mention
CVE-2024-36899
vulnerability anywhere in the article.
The following table lists the changes that have been made to the
CVE-2024-36899
vulnerability over time.
Vulnerability history details can be useful for understanding the evolution of a vulnerability, and for identifying the most recent changes that may impact the vulnerability's severity, exploitability, or other characteristics.
-
CVE Modified by 416baaa9-dc9f-4396-8d5f-8c081fb06d67
Feb. 02, 2025
Action Type Old Value New Value Added Reference https://git.kernel.org/stable/c/2dfbb920a89bdc58087672ad5325dc6c588b6860 -
CVE Modified by 416baaa9-dc9f-4396-8d5f-8c081fb06d67
Jan. 23, 2025
Action Type Old Value New Value Added Reference https://git.kernel.org/stable/c/2d008d4961b039d2edce8976289773961b7e5fb5 Added Reference https://git.kernel.org/stable/c/d38c49f7bdf14381270736299e2ff68ec248a017 -
Initial Analysis by [email protected]
Jan. 14, 2025
Action Type Old Value New Value Added CVSS V3.1 NIST AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H Added CWE NIST CWE-362 Added CWE NIST CWE-416 Added CPE Configuration OR *cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* versions from (including) 5.7 up to (excluding) 6.6.31 *cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* versions from (including) 6.7 up to (excluding) 6.8.10 *cpe:2.3:o:linux:linux_kernel:6.9:rc1:*:*:*:*:*:* *cpe:2.3:o:linux:linux_kernel:6.9:rc2:*:*:*:*:*:* *cpe:2.3:o:linux:linux_kernel:6.9:rc3:*:*:*:*:*:* *cpe:2.3:o:linux:linux_kernel:6.9:rc4:*:*:*:*:*:* *cpe:2.3:o:linux:linux_kernel:6.9:rc5:*:*:*:*:*:* *cpe:2.3:o:linux:linux_kernel:6.9:rc6:*:*:*:*:*:* *cpe:2.3:o:linux:linux_kernel:6.9:rc7:*:*:*:*:*:* Changed Reference Type https://git.kernel.org/stable/c/02f6b0e1ec7e0e7d059dddc893645816552039da No Types Assigned https://git.kernel.org/stable/c/02f6b0e1ec7e0e7d059dddc893645816552039da Patch Changed Reference Type https://git.kernel.org/stable/c/02f6b0e1ec7e0e7d059dddc893645816552039da No Types Assigned https://git.kernel.org/stable/c/02f6b0e1ec7e0e7d059dddc893645816552039da Patch Changed Reference Type https://git.kernel.org/stable/c/95ca7c90eaf5ea8a8460536535101e3e81160e2a No Types Assigned https://git.kernel.org/stable/c/95ca7c90eaf5ea8a8460536535101e3e81160e2a Patch Changed Reference Type https://git.kernel.org/stable/c/95ca7c90eaf5ea8a8460536535101e3e81160e2a No Types Assigned https://git.kernel.org/stable/c/95ca7c90eaf5ea8a8460536535101e3e81160e2a Patch Changed Reference Type https://git.kernel.org/stable/c/ca710b5f40b8b16fdcad50bebd47f50e4c62d239 No Types Assigned https://git.kernel.org/stable/c/ca710b5f40b8b16fdcad50bebd47f50e4c62d239 Patch Changed Reference Type https://git.kernel.org/stable/c/ca710b5f40b8b16fdcad50bebd47f50e4c62d239 No Types Assigned https://git.kernel.org/stable/c/ca710b5f40b8b16fdcad50bebd47f50e4c62d239 Patch -
CVE Modified by af854a3a-2127-422b-91ae-364da2661108
Nov. 21, 2024
Action Type Old Value New Value Added Reference https://git.kernel.org/stable/c/02f6b0e1ec7e0e7d059dddc893645816552039da Added Reference https://git.kernel.org/stable/c/95ca7c90eaf5ea8a8460536535101e3e81160e2a Added Reference https://git.kernel.org/stable/c/ca710b5f40b8b16fdcad50bebd47f50e4c62d239 -
CVE Received by 416baaa9-dc9f-4396-8d5f-8c081fb06d67
May. 30, 2024
Action Type Old Value New Value Added Description In the Linux kernel, the following vulnerability has been resolved: gpiolib: cdev: Fix use after free in lineinfo_changed_notify The use-after-free issue occurs as follows: when the GPIO chip device file is being closed by invoking gpio_chrdev_release(), watched_lines is freed by bitmap_free(), but the unregistration of lineinfo_changed_nb notifier chain failed due to waiting write rwsem. Additionally, one of the GPIO chip's lines is also in the release process and holds the notifier chain's read rwsem. Consequently, a race condition leads to the use-after-free of watched_lines. Here is the typical stack when issue happened: [free] gpio_chrdev_release() --> bitmap_free(cdev->watched_lines) <-- freed --> blocking_notifier_chain_unregister() --> down_write(&nh->rwsem) <-- waiting rwsem --> __down_write_common() --> rwsem_down_write_slowpath() --> schedule_preempt_disabled() --> schedule() [use] st54spi_gpio_dev_release() --> gpio_free() --> gpiod_free() --> gpiod_free_commit() --> gpiod_line_state_notify() --> blocking_notifier_call_chain() --> down_read(&nh->rwsem); <-- held rwsem --> notifier_call_chain() --> lineinfo_changed_notify() --> test_bit(xxxx, cdev->watched_lines) <-- use after free The side effect of the use-after-free issue is that a GPIO line event is being generated for userspace where it shouldn't. However, since the chrdev is being closed, userspace won't have the chance to read that event anyway. To fix the issue, call the bitmap_free() function after the unregistration of lineinfo_changed_nb notifier chain. Added Reference kernel.org https://git.kernel.org/stable/c/95ca7c90eaf5ea8a8460536535101e3e81160e2a [No types assigned] Added Reference kernel.org https://git.kernel.org/stable/c/ca710b5f40b8b16fdcad50bebd47f50e4c62d239 [No types assigned] Added Reference kernel.org https://git.kernel.org/stable/c/02f6b0e1ec7e0e7d059dddc893645816552039da [No types assigned]
CWE - Common Weakness Enumeration
While CVE identifies
specific instances of vulnerabilities, CWE categorizes the common flaws or
weaknesses that can lead to vulnerabilities. CVE-2024-36899
is
associated with the following CWEs:
Common Attack Pattern Enumeration and Classification (CAPEC)
Common Attack Pattern Enumeration and Classification
(CAPEC)
stores attack patterns, which are descriptions of the common attributes and
approaches employed by adversaries to exploit the CVE-2024-36899
weaknesses.