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

- Severity: Medium 5.5 (CVSS:3.1, scored by NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.30%, higher than 15% of CVEs (2026-11-30)
- Published: 2024-10-21T18:02:31.209Z
- Modified: 2026-06-17T08:00:53.293Z
- Weaknesses: CWE-476
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: Linux

## 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.

(As written by CVE List.)

## Affected

- Linux Linux: from d0fe92fb5e3df6991c640fb9205d880b68603259 before c2d9f9a7837ab29ccae0c42252f17d436bf0a501; from d0fe92fb5e3df6991c640fb9205d880b68603259 before 2e0f6f33f2aa87493b365a38a8fd87b8854b7734; from d0fe92fb5e3df6991c640fb9205d880b68603259 before c208b02827eb642758cef65641995fd3f38c89af; from d0fe92fb5e3df6991c640fb9205d880b68603259 before f04e2ad394e2755d0bb2d858ecb5598718bf00d5; 6.4 (not affected: before 6.4; from 6.6.55 up to 6.6.*; from 6.10.14 up to 6.10.*; from 6.11.3 up to 6.11.*; from 6.12 up to *)
- linux linux_kernel: before 6.6.55; from 6.7 before 6.10.14; from 6.11 before 6.11.3

## References

- <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> (patch)

## Sources

- CVE List: [CVE-2024-49987](https://www.cve.org/CVERecord?id=CVE-2024-49987), CVE Terms of Use, modified 2026-05-11
- NVD: [CVE-2024-49987](https://nvd.nist.gov/vuln/detail/CVE-2024-49987), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2024-49987 · Whole record: https://cve.day/CVE-2024-49987.json · Rebuilt by cve.day 2026-11-25T22:58:47.079Z
