CVE-2024-53193: clk: clk-loongson2: Fix memory corruption bug in struct loongson2_clk_provider

Published Dec 27, 2024
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

clk: clk-loongson2: Fix memory corruption bug in struct loongson2clkprovider

Some heap space is allocated for the flexible structure struct clkhwonecelldata and its flexible-array member hws through the composite structure struct loongson2clkprovider in function loongson2clkprobe(), as shown below:

289 struct loongson2clkprovider clp; ... 296 for (p = data; p->name; p++) 297 clksnum++; 298 299 clp = devmkzalloc(dev, structsize(clp, clkdata.hws, clksnum), 300 GFPKERNEL);

Then some data is written into the flexible array:

350 clp->clkdata.hws[p->id] = hw;

This corrupts clklock, which is the spinlock variable immediately following the clkdata member in struct loongson2clkprovider:

struct loongson2clkprovider { void iomem base; struct device dev; struct clkhwonecelldata clkdata; spinlockt clklock; / protect access to DIV registers / };

The problem is that the flexible structure is currently placed in the middle of struct loongson2clkprovider instead of at the end.

Fix this by moving struct clkhwonecelldata clkdata; to the end of struct loongson2clkprovider. Also, add a code comment to help prevent this from happening again in case new members are added to the structure in the future.

This change also fixes the following -Wflex-array-member-not-at-end warning:

drivers/clk/clk-loongson2.c:32:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Affected Software

4 affected componentsFixes available
Linux Linux kernel
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.22-16.12.25-1
Linux Linux kernel>=6.10<6.11.11
Linux Linux kernel>=6.12<6.12.2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to a version that resolves this vulnerability.

    Fixed in 5.10.223-1Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.22-1Fixed in 6.12.25-1
  2. Configuration

    Fix the memory corruption bug by relocating the flexible array container `struct clk_hw_onecell_data clk_data;` so it is the final member in `struct loongson2_clk_provider` (currently it is placed before `base`/`dev`/other members per the excerpt). Update `loongson2_clk_probe()` accordingly and ensure the flexible-array member `clk_data.hws` is only written within the allocated flexible tail.

    Linux kernel (drivers/clk/clk-loongson2.c) struct loongson2_clk_provider layout = Move `struct clk_hw_onecell_data clk_data;` to the end of `struct loongson2_clk_provider`
  3. Configuration

    Add a code comment near the `struct loongson2_clk_provider` definition explaining that `struct clk_hw_onecell_data clk_data;` must remain the last member of the struct because it contains the flexible array member `hws`, otherwise the allocation via `struct_size(..., clk_data.hws, clks_num)` can corrupt the subsequent fields (e.g., `spinlock_t clk_lock`).

    Linux kernel (drivers/clk/clk-loongson2.c) Code comment = Add a code comment preventing future flexible-array placement regressions

Event History

Dec 27, 2024
CVE Published
via MITRE·01:49 PM
Data Sourced
via MITRE·01:49 PM
DescriptionSeverity
Data Sourced
via NVD·02:15 PM
Description
Data Sourced
via NVD·02:15 PM
RemedySeverityWeaknessAffected Software
Apr 1, 2025
Data Sourced
via Ubuntu·01:03 AM
RemedyDescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-53193?

CVE-2024-53193 is classified as a medium severity vulnerability in the Linux kernel.

2

How do I fix CVE-2024-53193?

To resolve CVE-2024-53193, upgrade your Linux kernel to one of the fixed versions such as 5.10.223-1 or 6.12.15-1.

3

Which versions of the Linux kernel are affected by CVE-2024-53193?

CVE-2024-53193 affects specific versions of the Linux kernel prior to the patched releases, including versions before 5.10.223-1, 6.1.123-1, and 6.12.12-1.

4

What type of vulnerability is CVE-2024-53193?

CVE-2024-53193 is a memory corruption vulnerability found in the clk-loongson2 functionality of the Linux kernel.

5

Is CVE-2024-53193 related to any specific hardware or software?

CVE-2024-53193 primarily affects systems using the Linux kernel, particularly in relation to the Loongson2 clock provider implementation.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203