# CVE-2024-49987: bpftool: Fix undefined behavior in qsort(NULL, 0, ...)

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

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; 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.30% (percentile 15, 2026-11-26)
- **CWE:** CWE-476
- **Published:** 2024-10-21T18:02:31.209Z
- **Modified:** 2026-06-17T08:00:53.293Z

## Who should check

- Anyone running Linux \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< c2d9f9a7837ab29ccae0c42252f17d436bf0a501; \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< 2e0f6f33f2aa87493b365a38a8fd87b8854b7734; \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< c208b02827eb642758cef65641995fd3f38c89af; \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< f04e2ad394e2755d0bb2d858ecb5598718bf00d5
- Anyone running Linux 6.4

## Description

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

bpftool: Fix undefined behavior in qsort(NULL, 0, ...)

When netfilter has no entry to display, qsort is called with
qsort(NULL, 0, ...). This results in undefined behavior, as UBSan
reports:

net.c:827:2: runtime error: null pointer passed as argument 1, which is declared to never be null

Although the C standard does not explicitly state whether calling qsort
with a NULL pointer when the size is 0 constitutes undefined behavior,
Section 7.1.4 of the C standard (Use of library functions) mentions:

"Each of the following statements applies unless explicitly stated
otherwise in the detailed descriptions that follow: If an argument to a
function has an invalid value (such as a value outside the domain of
the function, or a pointer outside the address space of the program, or
a null pointer, or a pointer to non-modifiable storage when the
corresponding parameter is not const-qualified) or a type (after
promotion) not expected by a function with variable number of
arguments, the behavior is undefined."

To avoid this, add an early return when nf\_link\_info is NULL to prevent
calling qsort with a NULL pointer.

## Affected and fixed versions

- Linux: \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< c2d9f9a7837ab29ccae0c42252f17d436bf0a501; \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< 2e0f6f33f2aa87493b365a38a8fd87b8854b7734; \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< c208b02827eb642758cef65641995fd3f38c89af; \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< f04e2ad394e2755d0bb2d858ecb5598718bf00d5 (cvelist)
- Linux: 6.4 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2024-49987.md
Affected: Linux >= d0fe92fb5e3df6991c640fb9205d880b68603259, < c2d9f9a7837ab29ccae0c42252f17d436bf0a501; >= d0fe92fb5e3df6991c640fb9205d880b68603259, < 2e0f6f33f2aa87493b365a38a8fd87b8854b7734; >= d0fe92fb5e3df6991c640fb9205d880b68603259, < c208b02827eb642758cef65641995fd3f38c89af; >= d0fe92fb5e3df6991c640fb…
Fixed in: Linux 2e0f6f33f2aa87493b365a38a8fd87b8854b7734

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-2024-49987 being exploited?

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

### How serious is CVE-2024-49987?

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

### Which versions are affected by CVE-2024-49987?

Linux \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< c2d9f9a7837ab29ccae0c42252f17d436bf0a501; \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< 2e0f6f33f2aa87493b365a38a8fd87b8854b7734; \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< c208b02827eb642758cef65641995fd3f38c89af; \>= d0fe92fb5e3df6991c640fb9205d880b68603259, \< f04e2ad394e2755d0bb2d858ecb5598718bf00d5; Linux 6.4.

### Is there a fix for CVE-2024-49987?

Yes. Fixed in Linux 2e0f6f33f2aa87493b365a38a8fd87b8854b7734. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2024-49987?

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/c2d9f9a7837ab29ccae0c42252f17d436bf0a501>
- patch: <https://git.kernel.org/stable/c/2e0f6f33f2aa87493b365a38a8fd87b8854b7734>
- patch: <https://git.kernel.org/stable/c/c208b02827eb642758cef65641995fd3f38c89af>
- patch: <https://git.kernel.org/stable/c/f04e2ad394e2755d0bb2d858ecb5598718bf00d5>

## 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-2024-49987>

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