CVE-2021-47505
Linux Kernel AIO Use-After-Free Vulnerability in Binder/Signalfd Poll
Description
In the Linux kernel, the following vulnerability has been resolved: aio: fix use-after-free due to missing POLLFREE handling signalfd_poll() and binder_poll() are special in that they use a waitqueue whose lifetime is the current task, rather than the struct file as is normally the case. This is okay for blocking polls, since a blocking poll occurs within one task; however, non-blocking polls require another solution. This solution is for the queue to be cleared before it is freed, by sending a POLLFREE notification to all waiters. Unfortunately, only eventpoll handles POLLFREE. A second type of non-blocking poll, aio poll, was added in kernel v4.18, and it doesn't handle POLLFREE. This allows a use-after-free to occur if a signalfd or binder fd is polled with aio poll, and the waitqueue gets freed. Fix this by making aio poll handle POLLFREE. A patch by Ramji Jiyani <[email protected]> (https://lore.kernel.org/r/[email protected]) tried to do this by making aio_poll_wake() always complete the request inline if POLLFREE is seen. However, that solution had two bugs. First, it introduced a deadlock, as it unconditionally locked the aio context while holding the waitqueue lock, which inverts the normal locking order. Second, it didn't consider that POLLFREE notifications are missed while the request has been temporarily de-queued. The second problem was solved by my previous patch. This patch then properly fixes the use-after-free by handling POLLFREE in a deadlock-free way. It does this by taking advantage of the fact that freeing of the waitqueue is RCU-delayed, similar to what eventpoll does.
INFO
Published Date :
May 24, 2024, 3:15 p.m.
Last Modified :
Jan. 10, 2025, 6 p.m.
Source :
416baaa9-dc9f-4396-8d5f-8c081fb06d67
Remotely Exploitable :
No
Impact Score :
5.9
Exploitability Score :
1.8
References to Advisories, Solutions, and Tools
Here, you will find a curated list of external links that provide in-depth
information, practical solutions, and valuable tools related to
CVE-2021-47505
.
We scan GitHub repositories to detect new proof-of-concept exploits. Following list is a collection of public exploits and proof-of-concepts, which have been published on GitHub (sorted by the most recently updated).
Results are limited to the first 15 repositories due to potential performance issues.
The following list is the news that have been mention
CVE-2021-47505
vulnerability anywhere in the article.
The following table lists the changes that have been made to the
CVE-2021-47505
vulnerability over time.
Vulnerability history details can be useful for understanding the evolution of a vulnerability, and for identifying the most recent changes that may impact the vulnerability's severity, exploitability, or other characteristics.
-
Initial Analysis by [email protected]
Jan. 10, 2025
Action Type Old Value New Value Added CVSS V3.1 NIST AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H Added CWE NIST CWE-416 Added CPE Configuration OR *cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* versions from (including) 4.18 up to (excluding) 4.19.221 *cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* versions from (including) 4.20 up to (excluding) 5.4.165 *cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* versions from (including) 5.5 up to (excluding) 5.10.85 *cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* versions from (including) 5.11 up to (excluding) 5.15.8 *cpe:2.3:o:linux:linux_kernel:5.16:rc1:*:*:*:*:*:* *cpe:2.3:o:linux:linux_kernel:5.16:rc2:*:*:*:*:*:* *cpe:2.3:o:linux:linux_kernel:5.16:rc3:*:*:*:*:*:* *cpe:2.3:o:linux:linux_kernel:5.16:rc4:*:*:*:*:*:* Changed Reference Type https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f No Types Assigned https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f Patch Changed Reference Type https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f No Types Assigned https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f Patch Changed Reference Type https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f No Types Assigned https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f Patch Changed Reference Type https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f No Types Assigned https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f Patch Changed Reference Type https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689 No Types Assigned https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689 Patch Changed Reference Type https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689 No Types Assigned https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689 Patch Changed Reference Type https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72 No Types Assigned https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72 Patch Changed Reference Type https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72 No Types Assigned https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72 Patch Changed Reference Type https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24 No Types Assigned https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24 Patch Changed Reference Type https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24 No Types Assigned https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24 Patch -
CVE Modified by af854a3a-2127-422b-91ae-364da2661108
Nov. 21, 2024
Action Type Old Value New Value Added Reference https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f Added Reference https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f Added Reference https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689 Added Reference https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72 Added Reference https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24 -
CVE Modified by 416baaa9-dc9f-4396-8d5f-8c081fb06d67
May. 28, 2024
Action Type Old Value New Value -
CVE Received by 416baaa9-dc9f-4396-8d5f-8c081fb06d67
May. 24, 2024
Action Type Old Value New Value Added Description In the Linux kernel, the following vulnerability has been resolved: aio: fix use-after-free due to missing POLLFREE handling signalfd_poll() and binder_poll() are special in that they use a waitqueue whose lifetime is the current task, rather than the struct file as is normally the case. This is okay for blocking polls, since a blocking poll occurs within one task; however, non-blocking polls require another solution. This solution is for the queue to be cleared before it is freed, by sending a POLLFREE notification to all waiters. Unfortunately, only eventpoll handles POLLFREE. A second type of non-blocking poll, aio poll, was added in kernel v4.18, and it doesn't handle POLLFREE. This allows a use-after-free to occur if a signalfd or binder fd is polled with aio poll, and the waitqueue gets freed. Fix this by making aio poll handle POLLFREE. A patch by Ramji Jiyani <[email protected]> (https://lore.kernel.org/r/[email protected]) tried to do this by making aio_poll_wake() always complete the request inline if POLLFREE is seen. However, that solution had two bugs. First, it introduced a deadlock, as it unconditionally locked the aio context while holding the waitqueue lock, which inverts the normal locking order. Second, it didn't consider that POLLFREE notifications are missed while the request has been temporarily de-queued. The second problem was solved by my previous patch. This patch then properly fixes the use-after-free by handling POLLFREE in a deadlock-free way. It does this by taking advantage of the fact that freeing of the waitqueue is RCU-delayed, similar to what eventpoll does. Added Reference kernel.org https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f [No types assigned] Added Reference kernel.org https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f [No types assigned] Added Reference kernel.org https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689 [No types assigned] Added Reference kernel.org https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24 [No types assigned] Added Reference kernel.org https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72 [No types assigned]
CWE - Common Weakness Enumeration
While CVE identifies
specific instances of vulnerabilities, CWE categorizes the common flaws or
weaknesses that can lead to vulnerabilities. CVE-2021-47505
is
associated with the following CWEs:
Common Attack Pattern Enumeration and Classification (CAPEC)
Common Attack Pattern Enumeration and Classification
(CAPEC)
stores attack patterns, which are descriptions of the common attributes and
approaches employed by adversaries to exploit the CVE-2021-47505
weaknesses.