CVE-2021-46988

Severity CVSS v4.0:
Pending analysis
Type:
CWE-416 Use After Free
Publication date:
28/02/2024
Last modified:
26/12/2024

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> userfaultfd: release page in error path to avoid BUG_ON<br /> <br /> Consider the following sequence of events:<br /> <br /> 1. Userspace issues a UFFD ioctl, which ends up calling into<br /> shmem_mfill_atomic_pte(). We successfully account the blocks, we<br /> shmem_alloc_page(), but then the copy_from_user() fails. We return<br /> -ENOENT. We don&amp;#39;t release the page we allocated.<br /> 2. Our caller detects this error code, tries the copy_from_user() after<br /> dropping the mmap_lock, and retries, calling back into<br /> shmem_mfill_atomic_pte().<br /> 3. Meanwhile, let&amp;#39;s say another process filled up the tmpfs being used.<br /> 4. So shmem_mfill_atomic_pte() fails to account blocks this time, and<br /> immediately returns - without releasing the page.<br /> <br /> This triggers a BUG_ON in our caller, which asserts that the page<br /> should always be consumed, unless -ENOENT is returned.<br /> <br /> To fix this, detect if we have such a "dangling" page when accounting<br /> fails, and if so, release it before returning.

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.11 (including) 4.14.233 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.15 (including) 4.19.191 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.20 (including) 5.4.120 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.5 (including) 5.10.38 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.11 (including) 5.11.22 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.12 (including) 5.12.5 (excluding)
cpe:2.3:o:linux:linux_kernel:5.13:rc1:*:*:*:*:*:*