# CVE-2023-52851: IB/mlx5: Fix init stage error handling to avoid double free of same QP and UAF

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.32% (percentile 17, 2026-11-26)
- **CWE:** CWE-415, CWE-416
- **Published:** 2024-05-21T15:31:47.220Z
- **Modified:** 2026-06-17T06:43:44.010Z

## Who should check

- Anyone running Linux \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 437f033e30c897bb3723eac9e9003cd9f88d00a3; \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 4f4a7a7d1404297f2a92df0046f7e64dc5c52dd9; \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 6387f269d84e6e149499408c4d1fc805017729b2; \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 2ef422f063b74adcc4a4a9004b0a87bb55e0a836
- Anyone running Linux 5.19

## Description

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

IB/mlx5: Fix init stage error handling to avoid double free of same QP and UAF

In the unlikely event that workqueue allocation fails and returns NULL in
mlx5\_mkey\_cache\_init(), delete the call to
mlx5r\_umr\_resource\_cleanup() (which frees the QP) in
mlx5\_ib\_stage\_post\_ib\_reg\_umr\_init().  This will avoid attempted double
free of the same QP when \_\_mlx5\_ib\_add() does its cleanup.

Resolves a splat:

   Syzkaller reported a UAF in ib\_destroy\_qp\_user

   workqueue: Failed to create a rescuer kthread for wq "mkey\_cache": -EINTR
   infiniband mlx5\_0: mlx5\_mkey\_cache\_init:981:(pid 1642):
   failed to create work queue
   infiniband mlx5\_0: mlx5\_ib\_stage\_post\_ib\_reg\_umr\_init:4075:(pid 1642):
   mr cache init failed -12
   ==================================================================
   BUG: KASAN: slab-use-after-free in ib\_destroy\_qp\_user (drivers/infiniband/core/verbs.c:2073)
   Read of size 8 at addr ffff88810da310a8 by task repro\_upstream/1642

   Call Trace:
   \<TASK\>
   kasan\_report (mm/kasan/report.c:590)
   ib\_destroy\_qp\_user (drivers/infiniband/core/verbs.c:2073)
   mlx5r\_umr\_resource\_cleanup (drivers/infiniband/hw/mlx5/umr.c:198)
   \_\_mlx5\_ib\_add (drivers/infiniband/hw/mlx5/main.c:4178)
   mlx5r\_probe (drivers/infiniband/hw/mlx5/main.c:4402)
   ...
   \</TASK\>

   Allocated by task 1642:
   \_\_kmalloc (./include/linux/kasan.h:198 mm/slab\_common.c:1026
   mm/slab\_common.c:1039)
   create\_qp (./include/linux/slab.h:603 ./include/linux/slab.h:720
   ./include/rdma/ib\_verbs.h:2795 drivers/infiniband/core/verbs.c:1209)
   ib\_create\_qp\_kernel (drivers/infiniband/core/verbs.c:1347)
   mlx5r\_umr\_resource\_init (drivers/infiniband/hw/mlx5/umr.c:164)
   mlx5\_ib\_stage\_post\_ib\_reg\_umr\_init (drivers/infiniband/hw/mlx5/main.c:4070)
   \_\_mlx5\_ib\_add (drivers/infiniband/hw/mlx5/main.c:4168)
   mlx5r\_probe (drivers/infiniband/hw/mlx5/main.c:4402)
   ...

   Freed by task 1642:
   \_\_kmem\_cache\_free (mm/slub.c:1826 mm/slub.c:3809 mm/slub.c:3822)
   ib\_destroy\_qp\_user (drivers/infiniband/core/verbs.c:2112)
   mlx5r\_umr\_resource\_cleanup (drivers/infiniband/hw/mlx5/umr.c:198)
   mlx5\_ib\_stage\_post\_ib\_reg\_umr\_init (drivers/infiniband/hw/mlx5/main.c:4076
   drivers/infiniband/hw/mlx5/main.c:4065)
   \_\_mlx5\_ib\_add (drivers/infiniband/hw/mlx5/main.c:4168)
   mlx5r\_probe (drivers/infiniband/hw/mlx5/main.c:4402)
   ...

## Affected and fixed versions

- Linux: \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 437f033e30c897bb3723eac9e9003cd9f88d00a3; \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 4f4a7a7d1404297f2a92df0046f7e64dc5c52dd9; \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 6387f269d84e6e149499408c4d1fc805017729b2; \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 2ef422f063b74adcc4a4a9004b0a87bb55e0a836 (cvelist)
- Linux: 5.19 (cvelist)

## Mitigation

- Upgrade Linux to 2ef422f063b74adcc4a4a9004b0a87bb55e0a836 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2023-52851. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2023-52851.md
Affected: Linux >= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, < 437f033e30c897bb3723eac9e9003cd9f88d00a3; >= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, < 4f4a7a7d1404297f2a92df0046f7e64dc5c52dd9; >= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, < 6387f269d84e6e149499408c4d1fc805017729b2; >= 04876c12c19e94bbbc94bb0…
Fixed in: Linux 437f033e30c897bb3723eac9e9003cd9f88d00a3, Linux 4f4a7a7d1404297f2a92df0046f7e64dc5c52dd9, Linux 6387f269d84e6e149499408c4d1fc805017729b2, Linux 2ef422f063b74adcc4a4a9004b0a87bb55e0a836

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2023-52851 being exploited?

There is no confirmed exploitation: CVE-2023-52851 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.32% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2023-52851?

High: CVSS 7.8 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2023-52851?

Linux \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 437f033e30c897bb3723eac9e9003cd9f88d00a3; \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 4f4a7a7d1404297f2a92df0046f7e64dc5c52dd9; \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 6387f269d84e6e149499408c4d1fc805017729b2; \>= 04876c12c19e94bbbc94bb0446c7bc7cd75163de, \< 2ef422f063b74adcc4a4a9004b0a87bb55e0a836; Linux 5.19.

### Is there a fix for CVE-2023-52851?

Yes. Fixed in Linux 437f033e30c897bb3723eac9e9003cd9f88d00a3, Linux 4f4a7a7d1404297f2a92df0046f7e64dc5c52dd9, Linux 6387f269d84e6e149499408c4d1fc805017729b2, Linux 2ef422f063b74adcc4a4a9004b0a87bb55e0a836. Upgrade Linux to 2ef422f063b74adcc4a4a9004b0a87bb55e0a836 or later.

### How do I check if I'm affected by CVE-2023-52851?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/437f033e30c897bb3723eac9e9003cd9f88d00a3>
- patch: <https://git.kernel.org/stable/c/4f4a7a7d1404297f2a92df0046f7e64dc5c52dd9>
- patch: <https://git.kernel.org/stable/c/6387f269d84e6e149499408c4d1fc805017729b2>
- patch: <https://git.kernel.org/stable/c/2ef422f063b74adcc4a4a9004b0a87bb55e0a836>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2023-52851>

HTML: <https://flawdb.com/CVE-2023-52851> · JSON: <https://flawdb.com/api/v1/entries/CVE-2023-52851>
