CVE-2021-47505 (GCVE-0-2021-47505)

Vulnerability from cvelistv5 – Published: 2024-05-24 15:01 – Updated: 2025-05-04 07:12
VLAI?
Title
aio: fix use-after-free due to missing POLLFREE handling
Summary
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 <ramjiyani@google.com> (https://lore.kernel.org/r/20211027011834.2497484-1-ramjiyani@google.com) 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.
Severity ?
No CVSS data available.
Assigner
Impacted products
Vendor Product Version
Linux Linux Affected: 2c14fa838cbefc23cf1c73ca167ed85b274b2913 , < 321fba81ec034f88aea4898993c1bf15605c023f (git)
Affected: 2c14fa838cbefc23cf1c73ca167ed85b274b2913 , < 4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f (git)
Affected: 2c14fa838cbefc23cf1c73ca167ed85b274b2913 , < 47ffefd88abfffe8a040bcc1dd0554d4ea6f7689 (git)
Affected: 2c14fa838cbefc23cf1c73ca167ed85b274b2913 , < 60d311f9e6381d779d7d53371f87285698ecee24 (git)
Affected: 2c14fa838cbefc23cf1c73ca167ed85b274b2913 , < 50252e4b5e989ce64555c7aef7516bdefc2fea72 (git)
Create a notification for this product.
    Linux Linux Affected: 4.18
Unaffected: 0 , < 4.18 (semver)
Unaffected: 4.19.221 , ≤ 4.19.* (semver)
Unaffected: 5.4.165 , ≤ 5.4.* (semver)
Unaffected: 5.10.85 , ≤ 5.10.* (semver)
Unaffected: 5.15.8 , ≤ 5.15.* (semver)
Unaffected: 5.16 , ≤ * (original_commit_for_fix)
Create a notification for this product.
Show details on NVD website

{
  "containers": {
    "adp": [
      {
        "metrics": [
          {
            "other": {
              "content": {
                "id": "CVE-2021-47505",
                "options": [
                  {
                    "Exploitation": "none"
                  },
                  {
                    "Automatable": "no"
                  },
                  {
                    "Technical Impact": "partial"
                  }
                ],
                "role": "CISA Coordinator",
                "timestamp": "2024-06-14T18:37:27.922309Z",
                "version": "2.0.3"
              },
              "type": "ssvc"
            }
          }
        ],
        "providerMetadata": {
          "dateUpdated": "2024-07-30T15:15:43.456Z",
          "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
          "shortName": "CISA-ADP"
        },
        "title": "CISA ADP Vulnrichment"
      },
      {
        "providerMetadata": {
          "dateUpdated": "2024-08-04T05:39:59.807Z",
          "orgId": "af854a3a-2127-422b-91ae-364da2661108",
          "shortName": "CVE"
        },
        "references": [
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72"
          }
        ],
        "title": "CVE Program Container"
      }
    ],
    "cna": {
      "affected": [
        {
          "defaultStatus": "unaffected",
          "product": "Linux",
          "programFiles": [
            "fs/aio.c",
            "include/uapi/asm-generic/poll.h"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "lessThan": "321fba81ec034f88aea4898993c1bf15605c023f",
              "status": "affected",
              "version": "2c14fa838cbefc23cf1c73ca167ed85b274b2913",
              "versionType": "git"
            },
            {
              "lessThan": "4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f",
              "status": "affected",
              "version": "2c14fa838cbefc23cf1c73ca167ed85b274b2913",
              "versionType": "git"
            },
            {
              "lessThan": "47ffefd88abfffe8a040bcc1dd0554d4ea6f7689",
              "status": "affected",
              "version": "2c14fa838cbefc23cf1c73ca167ed85b274b2913",
              "versionType": "git"
            },
            {
              "lessThan": "60d311f9e6381d779d7d53371f87285698ecee24",
              "status": "affected",
              "version": "2c14fa838cbefc23cf1c73ca167ed85b274b2913",
              "versionType": "git"
            },
            {
              "lessThan": "50252e4b5e989ce64555c7aef7516bdefc2fea72",
              "status": "affected",
              "version": "2c14fa838cbefc23cf1c73ca167ed85b274b2913",
              "versionType": "git"
            }
          ]
        },
        {
          "defaultStatus": "affected",
          "product": "Linux",
          "programFiles": [
            "fs/aio.c",
            "include/uapi/asm-generic/poll.h"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "status": "affected",
              "version": "4.18"
            },
            {
              "lessThan": "4.18",
              "status": "unaffected",
              "version": "0",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "4.19.*",
              "status": "unaffected",
              "version": "4.19.221",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.4.*",
              "status": "unaffected",
              "version": "5.4.165",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.10.*",
              "status": "unaffected",
              "version": "5.10.85",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.15.*",
              "status": "unaffected",
              "version": "5.15.8",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "*",
              "status": "unaffected",
              "version": "5.16",
              "versionType": "original_commit_for_fix"
            }
          ]
        }
      ],
      "cpeApplicability": [
        {
          "nodes": [
            {
              "cpeMatch": [
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "4.19.221",
                  "versionStartIncluding": "4.18",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.4.165",
                  "versionStartIncluding": "4.18",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.10.85",
                  "versionStartIncluding": "4.18",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.15.8",
                  "versionStartIncluding": "4.18",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.16",
                  "versionStartIncluding": "4.18",
                  "vulnerable": true
                }
              ],
              "negate": false,
              "operator": "OR"
            }
          ]
        }
      ],
      "descriptions": [
        {
          "lang": "en",
          "value": "In the Linux kernel, the following vulnerability has been resolved:\n\naio: fix use-after-free due to missing POLLFREE handling\n\nsignalfd_poll() and binder_poll() are special in that they use a\nwaitqueue whose lifetime is the current task, rather than the struct\nfile as is normally the case.  This is okay for blocking polls, since a\nblocking poll occurs within one task; however, non-blocking polls\nrequire another solution.  This solution is for the queue to be cleared\nbefore it is freed, by sending a POLLFREE notification to all waiters.\n\nUnfortunately, only eventpoll handles POLLFREE.  A second type of\nnon-blocking poll, aio poll, was added in kernel v4.18, and it doesn\u0027t\nhandle POLLFREE.  This allows a use-after-free to occur if a signalfd or\nbinder fd is polled with aio poll, and the waitqueue gets freed.\n\nFix this by making aio poll handle POLLFREE.\n\nA patch by Ramji Jiyani \u003cramjiyani@google.com\u003e\n(https://lore.kernel.org/r/20211027011834.2497484-1-ramjiyani@google.com)\ntried to do this by making aio_poll_wake() always complete the request\ninline if POLLFREE is seen.  However, that solution had two bugs.\nFirst, it introduced a deadlock, as it unconditionally locked the aio\ncontext while holding the waitqueue lock, which inverts the normal\nlocking order.  Second, it didn\u0027t consider that POLLFREE notifications\nare missed while the request has been temporarily de-queued.\n\nThe second problem was solved by my previous patch.  This patch then\nproperly fixes the use-after-free by handling POLLFREE in a\ndeadlock-free way.  It does this by taking advantage of the fact that\nfreeing of the waitqueue is RCU-delayed, similar to what eventpoll does."
        }
      ],
      "providerMetadata": {
        "dateUpdated": "2025-05-04T07:12:28.338Z",
        "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
        "shortName": "Linux"
      },
      "references": [
        {
          "url": "https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f"
        },
        {
          "url": "https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f"
        },
        {
          "url": "https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689"
        },
        {
          "url": "https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24"
        },
        {
          "url": "https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72"
        }
      ],
      "title": "aio: fix use-after-free due to missing POLLFREE handling",
      "x_generator": {
        "engine": "bippy-1.2.0"
      }
    }
  },
  "cveMetadata": {
    "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
    "assignerShortName": "Linux",
    "cveId": "CVE-2021-47505",
    "datePublished": "2024-05-24T15:01:52.088Z",
    "dateReserved": "2024-05-22T06:20:56.205Z",
    "dateUpdated": "2025-05-04T07:12:28.338Z",
    "state": "PUBLISHED"
  },
  "dataType": "CVE_RECORD",
  "dataVersion": "5.1",
  "vulnerability-lookup:meta": {
    "vulnrichment": {
      "containers": "{\"adp\": [{\"title\": \"CVE Program Container\", \"references\": [{\"url\": \"https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f\", \"tags\": [\"x_transferred\"]}, {\"url\": \"https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f\", \"tags\": [\"x_transferred\"]}, {\"url\": \"https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689\", \"tags\": [\"x_transferred\"]}, {\"url\": \"https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24\", \"tags\": [\"x_transferred\"]}, {\"url\": \"https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72\", \"tags\": [\"x_transferred\"]}], \"providerMetadata\": {\"orgId\": \"af854a3a-2127-422b-91ae-364da2661108\", \"shortName\": \"CVE\", \"dateUpdated\": \"2024-08-04T05:39:59.807Z\"}}, {\"title\": \"CISA ADP Vulnrichment\", \"metrics\": [{\"other\": {\"type\": \"ssvc\", \"content\": {\"id\": \"CVE-2021-47505\", \"role\": \"CISA Coordinator\", \"options\": [{\"Exploitation\": \"none\"}, {\"Automatable\": \"no\"}, {\"Technical Impact\": \"partial\"}], \"version\": \"2.0.3\", \"timestamp\": \"2024-06-14T18:37:27.922309Z\"}}}], \"providerMetadata\": {\"orgId\": \"134c704f-9b21-4f2e-91b3-4a467353bcc0\", \"shortName\": \"CISA-ADP\", \"dateUpdated\": \"2024-06-14T18:37:35.159Z\"}}], \"cna\": {\"title\": \"aio: fix use-after-free due to missing POLLFREE handling\", \"affected\": [{\"repo\": \"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git\", \"vendor\": \"Linux\", \"product\": \"Linux\", \"versions\": [{\"status\": \"affected\", \"version\": \"2c14fa838cbefc23cf1c73ca167ed85b274b2913\", \"lessThan\": \"321fba81ec034f88aea4898993c1bf15605c023f\", \"versionType\": \"git\"}, {\"status\": \"affected\", \"version\": \"2c14fa838cbefc23cf1c73ca167ed85b274b2913\", \"lessThan\": \"4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f\", \"versionType\": \"git\"}, {\"status\": \"affected\", \"version\": \"2c14fa838cbefc23cf1c73ca167ed85b274b2913\", \"lessThan\": \"47ffefd88abfffe8a040bcc1dd0554d4ea6f7689\", \"versionType\": \"git\"}, {\"status\": \"affected\", \"version\": \"2c14fa838cbefc23cf1c73ca167ed85b274b2913\", \"lessThan\": \"60d311f9e6381d779d7d53371f87285698ecee24\", \"versionType\": \"git\"}, {\"status\": \"affected\", \"version\": \"2c14fa838cbefc23cf1c73ca167ed85b274b2913\", \"lessThan\": \"50252e4b5e989ce64555c7aef7516bdefc2fea72\", \"versionType\": \"git\"}], \"programFiles\": [\"fs/aio.c\", \"include/uapi/asm-generic/poll.h\"], \"defaultStatus\": \"unaffected\"}, {\"repo\": \"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git\", \"vendor\": \"Linux\", \"product\": \"Linux\", \"versions\": [{\"status\": \"affected\", \"version\": \"4.18\"}, {\"status\": \"unaffected\", \"version\": \"0\", \"lessThan\": \"4.18\", \"versionType\": \"semver\"}, {\"status\": \"unaffected\", \"version\": \"4.19.221\", \"versionType\": \"semver\", \"lessThanOrEqual\": \"4.19.*\"}, {\"status\": \"unaffected\", \"version\": \"5.4.165\", \"versionType\": \"semver\", \"lessThanOrEqual\": \"5.4.*\"}, {\"status\": \"unaffected\", \"version\": \"5.10.85\", \"versionType\": \"semver\", \"lessThanOrEqual\": \"5.10.*\"}, {\"status\": \"unaffected\", \"version\": \"5.15.8\", \"versionType\": \"semver\", \"lessThanOrEqual\": \"5.15.*\"}, {\"status\": \"unaffected\", \"version\": \"5.16\", \"versionType\": \"original_commit_for_fix\", \"lessThanOrEqual\": \"*\"}], \"programFiles\": [\"fs/aio.c\", \"include/uapi/asm-generic/poll.h\"], \"defaultStatus\": \"affected\"}], \"references\": [{\"url\": \"https://git.kernel.org/stable/c/321fba81ec034f88aea4898993c1bf15605c023f\"}, {\"url\": \"https://git.kernel.org/stable/c/4105e6a128e8a98455dfc9e6dbb2ab0c33c4497f\"}, {\"url\": \"https://git.kernel.org/stable/c/47ffefd88abfffe8a040bcc1dd0554d4ea6f7689\"}, {\"url\": \"https://git.kernel.org/stable/c/60d311f9e6381d779d7d53371f87285698ecee24\"}, {\"url\": \"https://git.kernel.org/stable/c/50252e4b5e989ce64555c7aef7516bdefc2fea72\"}], \"x_generator\": {\"engine\": \"bippy-1.2.0\"}, \"descriptions\": [{\"lang\": \"en\", \"value\": \"In the Linux kernel, the following vulnerability has been resolved:\\n\\naio: fix use-after-free due to missing POLLFREE handling\\n\\nsignalfd_poll() and binder_poll() are special in that they use a\\nwaitqueue whose lifetime is the current task, rather than the struct\\nfile as is normally the case.  This is okay for blocking polls, since a\\nblocking poll occurs within one task; however, non-blocking polls\\nrequire another solution.  This solution is for the queue to be cleared\\nbefore it is freed, by sending a POLLFREE notification to all waiters.\\n\\nUnfortunately, only eventpoll handles POLLFREE.  A second type of\\nnon-blocking poll, aio poll, was added in kernel v4.18, and it doesn\u0027t\\nhandle POLLFREE.  This allows a use-after-free to occur if a signalfd or\\nbinder fd is polled with aio poll, and the waitqueue gets freed.\\n\\nFix this by making aio poll handle POLLFREE.\\n\\nA patch by Ramji Jiyani \u003cramjiyani@google.com\u003e\\n(https://lore.kernel.org/r/20211027011834.2497484-1-ramjiyani@google.com)\\ntried to do this by making aio_poll_wake() always complete the request\\ninline if POLLFREE is seen.  However, that solution had two bugs.\\nFirst, it introduced a deadlock, as it unconditionally locked the aio\\ncontext while holding the waitqueue lock, which inverts the normal\\nlocking order.  Second, it didn\u0027t consider that POLLFREE notifications\\nare missed while the request has been temporarily de-queued.\\n\\nThe second problem was solved by my previous patch.  This patch then\\nproperly fixes the use-after-free by handling POLLFREE in a\\ndeadlock-free way.  It does this by taking advantage of the fact that\\nfreeing of the waitqueue is RCU-delayed, similar to what eventpoll does.\"}], \"cpeApplicability\": [{\"nodes\": [{\"negate\": false, \"cpeMatch\": [{\"criteria\": \"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*\", \"vulnerable\": true, \"versionEndExcluding\": \"4.19.221\", \"versionStartIncluding\": \"4.18\"}, {\"criteria\": \"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*\", \"vulnerable\": true, \"versionEndExcluding\": \"5.4.165\", \"versionStartIncluding\": \"4.18\"}, {\"criteria\": \"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*\", \"vulnerable\": true, \"versionEndExcluding\": \"5.10.85\", \"versionStartIncluding\": \"4.18\"}, {\"criteria\": \"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*\", \"vulnerable\": true, \"versionEndExcluding\": \"5.15.8\", \"versionStartIncluding\": \"4.18\"}, {\"criteria\": \"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*\", \"vulnerable\": true, \"versionEndExcluding\": \"5.16\", \"versionStartIncluding\": \"4.18\"}], \"operator\": \"OR\"}]}], \"providerMetadata\": {\"orgId\": \"416baaa9-dc9f-4396-8d5f-8c081fb06d67\", \"shortName\": \"Linux\", \"dateUpdated\": \"2025-05-04T07:12:28.338Z\"}}}",
      "cveMetadata": "{\"cveId\": \"CVE-2021-47505\", \"state\": \"PUBLISHED\", \"dateUpdated\": \"2025-05-04T07:12:28.338Z\", \"dateReserved\": \"2024-05-22T06:20:56.205Z\", \"assignerOrgId\": \"416baaa9-dc9f-4396-8d5f-8c081fb06d67\", \"datePublished\": \"2024-05-24T15:01:52.088Z\", \"assignerShortName\": \"Linux\"}",
      "dataType": "CVE_RECORD",
      "dataVersion": "5.1"
    }
  }
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…