CVE-2021-47505: aio: fix use-after-free due to missing POLLFREE handling

Published May 24, 2024
·
Updated

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

aio: fix use-after-free due to missing POLLFREE handling

signalfdpoll() and binderpoll() 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 <ramjiyani@google.com> (https://lore.kernel.org/r/20211027011834.2497484-1-ramjiyani@google.com) tried to do this by making aiopollwake() 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.

Other sources

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

aio: fix use-after-free due to missing POLLFREE handling

The Linux kernel CVE team has assigned CVE-2021-47505 to this issue.

Upstream advisory: https://lore.kernel.org/linux-cve-announce/2024052452-CVE-2021-47505-427f@gregkh/T

Red Hat

Affected Software

13 affected componentsFixes available
redhat/kernel<4.19.221
4.19.221
redhat/kernel<5.4.165
5.4.165
redhat/kernel<5.10.85
5.10.85
redhat/kernel<5.15.8
5.15.8
redhat/kernel<5.16
5.16
Linux Linux kernel>=4.18<4.19.221
Linux Linux kernel>=4.20<5.4.165
Linux Linux kernel>=5.5<5.10.85
Linux Linux kernel>=5.11<5.15.8
Linux Linux kernel=5.16-rc1
Linux Linux kernel=5.16-rc2
Linux Linux kernel=5.16-rc3
Linux Linux kernel=5.16-rc4

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade redhat/kernel to a version that resolves this vulnerability.

    Fixed in 4.19.221
  2. Upgrade

    Upgrade redhat/kernel to a version that resolves this vulnerability.

    Fixed in 5.4.165
  3. Upgrade

    Upgrade redhat/kernel to a version that resolves this vulnerability.

    Fixed in 5.10.85
  4. Upgrade

    Upgrade redhat/kernel to a version that resolves this vulnerability.

    Fixed in 5.15.8
  5. Upgrade

    Upgrade redhat/kernel to a version that resolves this vulnerability.

    Fixed in 5.16
  6. Upgrade

    Upgrade linux kernel aio to a version that resolves this vulnerability.

    Fixed in v4.18Patch CVE-2021-47505
  7. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Patch CVE-2021-47505
  8. Configuration

    Fix CVE-2021-47505 by ensuring aio poll/wake correctly handles POLLFREE (e.g., inline handling when POLLFREE is seen) so waiters are notified before the waitqueue is freed, preventing a use-after-free.

    aio_poll_wake / POLLFREE handling POLLFREE notification handling = enable

Event History

May 24, 2024
CVE Published
via MITRE·03:01 PM
Data Sourced
via MITRE·03:01 PM
DescriptionSeverity
Data Sourced
via NVD·03:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
May 27, 2024
Data Sourced
via Red Hat·10:57 AM
DescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2021-47505?

CVE-2021-47505 is considered a medium severity vulnerability in the Linux kernel.

2

How do I fix CVE-2021-47505?

To fix CVE-2021-47505, upgrade the Linux kernel to versions 4.19.221, 5.4.165, 5.10.85, 5.15.8, or 5.16.

3

Which systems are affected by CVE-2021-47505?

CVE-2021-47505 affects various Linux kernel versions between 4.18 and 5.16-rc4.

4

What type of vulnerability is CVE-2021-47505?

CVE-2021-47505 is a use-after-free vulnerability due to missing POLLFREE handling in the Linux kernel.

5

Is CVE-2021-47505 remotely exploitable?

CVE-2021-47505 can potentially be exploited locally, as it relates to the handling of specific kernel functions.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203