# CVE-2021-47218: selinux: fix NULL-pointer dereference when hashtab allocation fails

- 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.22%, higher than 14% of CVEs (2026-12-01)
- Published: 2024-04-10T19:01:57.060Z
- Modified: 2026-06-17T04:16:56.023Z
- Weaknesses: CWE-476
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact total
- Assigned by: Linux

## Description

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

selinux: fix NULL-pointer dereference when hashtab allocation fails

When the hash table slot array allocation fails in hashtab_init(),
h->size is left initialized with a non-zero value, but the h->htable
pointer is NULL. This may then cause a NULL pointer dereference, since
the policydb code relies on the assumption that even after a failed
hashtab_init(), hashtab_map() and hashtab_destroy() can be safely called
on it. Yet, these detect an empty hashtab only by looking at the size.

Fix this by making sure that hashtab_init() always leaves behind a valid
empty hashtab when the allocation fails.

(As written by CVE List.)

## Affected

- Linux Linux: from 03414a49ad5f3c56988c36d2070e402ffa17feaf before b17dd53cac769dd13031b0ca34f90cc65e523fab; from 03414a49ad5f3c56988c36d2070e402ffa17feaf before 83c8ab8503adf56bf68dafc7a382f4946c87da79; from 03414a49ad5f3c56988c36d2070e402ffa17feaf before dc27f3c5d10c58069672215787a96b4fae01818b; 5.8 (not affected: before 5.8; from 5.10.82 up to 5.10.*; from 5.15.5 up to 5.15.*; from 5.16 up to *)
- linux linux_kernel: from 5.8 before 5.10.82; from 5.11 before 5.15.5; 5.16

## References

- <https://git.kernel.org/stable/c/b17dd53cac769dd13031b0ca34f90cc65e523fab> (patch)
- <https://git.kernel.org/stable/c/83c8ab8503adf56bf68dafc7a382f4946c87da79> (patch)
- <https://git.kernel.org/stable/c/dc27f3c5d10c58069672215787a96b4fae01818b> (patch)

## Sources

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

---

Page: https://cve.day/CVE-2021-47218 · Whole record: https://cve.day/CVE-2021-47218.json · Rebuilt by cve.day 2026-11-25T22:58:08.722Z
