CVE-2025-21751 net/mlx5: HWS, change error flow on matcher disconnect

High 7.8 Published Updated

A use-after-free vulnerability in the Linux kernel mlx5 driver allows a local attacker to cause a system crash via firmware failure during matcher disconnect.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2025-21751?

CVE-2025-21751 is a high-severity use after free vulnerability in Linux kernel, published on 27 Feb 2025. It can only be exploited from the same machine or local network, with no action from the victim.

Official description

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

net/mlx5: HWS, change error flow on matcher disconnect

Currently, when firmware failure occurs during matcher disconnect flow, the error flow of the function reconnects the matcher back and returns an error, which continues running the calling function and eventually frees the matcher that is being disconnected. This leads to a case where we have a freed matcher on the matchers list, which in turn leads to use-after-free and eventual crash.

This patch fixes that by not trying to reconnect the matcher back when some FW command fails during disconnect.

Note that we're dealing here with FW error. We can't overcome this problem. This might lead to bad steering state (e.g. wrong connection between matchers), and will also lead to resource leakage, as it is the case with any other error handling during resource destruction.

However, the goal here is to allow the driver to continue and not crash the machine with use-after-free error.

Weakness: CWE-416

Which versions are affected by CVE-2025-21751?

It affects 1 product.

Products include Linux kernel.

How do I fix CVE-2025-21751?

Apply the vendor's patch.

Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.

Is CVE-2025-21751 being exploited?

There is no known exploitation of CVE-2025-21751 in the wild and no public exploit code.

All Linux kernel vulnerabilities

Sources

Also known as BELL-CVE-2025-21751, DEBIAN-CVE-2025-21751, GHSA-6cpx-w2cg-qmgr, ROOT-OS-DEBIAN-11-CVE-2025-21751, ROOT-OS-DEBIAN-12-CVE-2025-21751, ROOT-OS-DEBIAN-13-CVE-2025-21751 and 3 more.

Is CVE-2025-21751 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free