cve-2024-36894
Vulnerability from cvelistv5
Published
2024-05-30 15:28
Modified
2024-08-21 16:17
Severity
Summary
usb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete
Impacted products
VendorProduct
LinuxLinux
LinuxLinux
Show details on NVD website


{
  "containers": {
    "adp": [
      {
        "affected": [
          {
            "cpes": [
              "cpe:2.3:o:linux:linux_kernel:-:*:*:*:*:*:*:*"
            ],
            "defaultStatus": "unknown",
            "product": "linux_kernel",
            "vendor": "linux",
            "versions": [
              {
                "lessThan": "73c05ad46bb4",
                "status": "affected",
                "version": "2e4c7553cd6f",
                "versionType": "custom"
              }
            ]
          },
          {
            "cpes": [
              "cpe:2.3:o:linux:linux_kernel:-:*:*:*:*:*:*:*"
            ],
            "defaultStatus": "unknown",
            "product": "linux_kernel",
            "vendor": "linux",
            "versions": [
              {
                "lessThan": "d74618308232",
                "status": "affected",
                "version": "2e4c7553cd6f",
                "versionType": "custom"
              }
            ]
          },
          {
            "cpes": [
              "cpe:2.3:o:linux:linux_kernel:-:*:*:*:*:*:*:*"
            ],
            "defaultStatus": "unknown",
            "product": "linux_kernel",
            "vendor": "linux",
            "versions": [
              {
                "lessThan": "24729b307eef",
                "status": "affected",
                "version": "2e4c7553cd6f",
                "versionType": "custom"
              },
              {
                "lessThan": "f71a53148ce3",
                "status": "affected",
                "version": "2e4c7553cd6f",
                "versionType": "custom"
              },
              {
                "lessThan": "9e72ef59cbe6",
                "status": "affected",
                "version": "2e4c7553cd6f",
                "versionType": "custom"
              },
              {
                "lessThan": "e500b1c4e29a",
                "status": "affected",
                "version": "2e4c7553cd6f",
                "versionType": "custom"
              },
              {
                "lessThan": "3613e5023f09",
                "status": "affected",
                "version": "2e4c7553cd6f",
                "versionType": "custom"
              },
              {
                "lessThan": "a0fdccb1c9e0",
                "status": "affected",
                "version": "2e4c7553cd6f",
                "versionType": "custom"
              },
              {
                "status": "affected",
                "version": "3.15"
              },
              {
                "lessThan": "3.15",
                "status": "unaffected",
                "version": "0",
                "versionType": "custom"
              },
              {
                "lessThanOrEqual": "4.20",
                "status": "unaffected",
                "version": "4.19.317",
                "versionType": "custom"
              },
              {
                "lessThanOrEqual": "5.5",
                "status": "unaffected",
                "version": "5.4.279",
                "versionType": "custom"
              },
              {
                "lessThanOrEqual": "5.11",
                "status": "unaffected",
                "version": "5.10.221",
                "versionType": "custom"
              },
              {
                "lessThanOrEqual": "5.16",
                "status": "unaffected",
                "version": "5.15.162",
                "versionType": "custom"
              },
              {
                "lessThanOrEqual": "6.2",
                "status": "unaffected",
                "version": "6.1.95",
                "versionType": "custom"
              },
              {
                "lessThanOrEqual": "6.7",
                "status": "unaffected",
                "version": "6.6.31",
                "versionType": "custom"
              },
              {
                "lessThanOrEqual": "6.9",
                "status": "unaffected",
                "version": "6.8.10",
                "versionType": "custom"
              },
              {
                "lessThanOrEqual": "*",
                "status": "unaffected",
                "version": "6.9",
                "versionType": "custom"
              }
            ]
          }
        ],
        "metrics": [
          {
            "cvssV3_1": {
              "attackComplexity": "HIGH",
              "attackVector": "PHYSICAL",
              "availabilityImpact": "HIGH",
              "baseScore": 5.6,
              "baseSeverity": "MEDIUM",
              "confidentialityImpact": "HIGH",
              "integrityImpact": "NONE",
              "privilegesRequired": "LOW",
              "scope": "UNCHANGED",
              "userInteraction": "NONE",
              "vectorString": "CVSS:3.1/AV:P/AC:H/PR:L/UI:N/S:U/C:H/I:N/A:H",
              "version": "3.1"
            }
          },
          {
            "other": {
              "content": {
                "id": "CVE-2024-36894",
                "options": [
                  {
                    "Exploitation": "none"
                  },
                  {
                    "Automatable": "no"
                  },
                  {
                    "Technical Impact": "partial"
                  }
                ],
                "role": "CISA Coordinator",
                "timestamp": "2024-06-03T15:53:00.949597Z",
                "version": "2.0.3"
              },
              "type": "ssvc"
            }
          }
        ],
        "problemTypes": [
          {
            "descriptions": [
              {
                "cweId": "CWE-362",
                "description": "CWE-362 Concurrent Execution using Shared Resource with Improper Synchronization (\u0027Race Condition\u0027)",
                "lang": "en",
                "type": "CWE"
              }
            ]
          }
        ],
        "providerMetadata": {
          "dateUpdated": "2024-08-21T16:17:27.715Z",
          "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
          "shortName": "CISA-ADP"
        },
        "title": "CISA ADP Vulnrichment"
      },
      {
        "providerMetadata": {
          "dateUpdated": "2024-08-02T03:43:49.884Z",
          "orgId": "af854a3a-2127-422b-91ae-364da2661108",
          "shortName": "CVE"
        },
        "references": [
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/f71a53148ce34898fef099b75386a3a9f4449311"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/9e72ef59cbe61cd1243857a6418ca92104275867"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/e500b1c4e29ad0bd1c1332a1eaea2913627a92dd"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/3613e5023f09b3308545e9d1acda86017ebd418a"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/a0fdccb1c9e027e3195f947f61aa87d6d0d2ea14"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/73c05ad46bb4fbbdb346004651576d1c8dbcffbb"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/d7461830823242702f5d84084bcccb25159003f4"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/24729b307eefcd7c476065cd7351c1a018082c19"
          }
        ],
        "title": "CVE Program Container"
      }
    ],
    "cna": {
      "affected": [
        {
          "defaultStatus": "unaffected",
          "product": "Linux",
          "programFiles": [
            "drivers/usb/gadget/function/f_fs.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "lessThan": "f71a53148ce3",
              "status": "affected",
              "version": "2e4c7553cd6f",
              "versionType": "git"
            },
            {
              "lessThan": "9e72ef59cbe6",
              "status": "affected",
              "version": "2e4c7553cd6f",
              "versionType": "git"
            },
            {
              "lessThan": "e500b1c4e29a",
              "status": "affected",
              "version": "2e4c7553cd6f",
              "versionType": "git"
            },
            {
              "lessThan": "3613e5023f09",
              "status": "affected",
              "version": "2e4c7553cd6f",
              "versionType": "git"
            },
            {
              "lessThan": "a0fdccb1c9e0",
              "status": "affected",
              "version": "2e4c7553cd6f",
              "versionType": "git"
            },
            {
              "lessThan": "73c05ad46bb4",
              "status": "affected",
              "version": "2e4c7553cd6f",
              "versionType": "git"
            },
            {
              "lessThan": "d74618308232",
              "status": "affected",
              "version": "2e4c7553cd6f",
              "versionType": "git"
            },
            {
              "lessThan": "24729b307eef",
              "status": "affected",
              "version": "2e4c7553cd6f",
              "versionType": "git"
            }
          ]
        },
        {
          "defaultStatus": "affected",
          "product": "Linux",
          "programFiles": [
            "drivers/usb/gadget/function/f_fs.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "status": "affected",
              "version": "3.15"
            },
            {
              "lessThan": "3.15",
              "status": "unaffected",
              "version": "0",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "4.19.*",
              "status": "unaffected",
              "version": "4.19.317",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "5.4.*",
              "status": "unaffected",
              "version": "5.4.279",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "5.10.*",
              "status": "unaffected",
              "version": "5.10.221",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "5.15.*",
              "status": "unaffected",
              "version": "5.15.162",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "6.1.*",
              "status": "unaffected",
              "version": "6.1.95",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "6.6.*",
              "status": "unaffected",
              "version": "6.6.31",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "6.8.*",
              "status": "unaffected",
              "version": "6.8.10",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "*",
              "status": "unaffected",
              "version": "6.9",
              "versionType": "original_commit_for_fix"
            }
          ]
        }
      ],
      "descriptions": [
        {
          "lang": "en",
          "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nusb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete\n\nFFS based applications can utilize the aio_cancel() callback to dequeue\npending USB requests submitted to the UDC.  There is a scenario where the\nFFS application issues an AIO cancel call, while the UDC is handling a\nsoft disconnect.  For a DWC3 based implementation, the callstack looks\nlike the following:\n\n    DWC3 Gadget                               FFS Application\ndwc3_gadget_soft_disconnect()              ...\n  --\u003e dwc3_stop_active_transfers()\n    --\u003e dwc3_gadget_giveback(-ESHUTDOWN)\n      --\u003e ffs_epfile_async_io_complete()   ffs_aio_cancel()\n        --\u003e usb_ep_free_request()            --\u003e usb_ep_dequeue()\n\nThere is currently no locking implemented between the AIO completion\nhandler and AIO cancel, so the issue occurs if the completion routine is\nrunning in parallel to an AIO cancel call coming from the FFS application.\nAs the completion call frees the USB request (io_data-\u003ereq) the FFS\napplication is also referencing it for the usb_ep_dequeue() call.  This can\nlead to accessing a stale/hanging pointer.\n\ncommit b566d38857fc (\"usb: gadget: f_fs: use io_data-\u003estatus consistently\")\nrelocated the usb_ep_free_request() into ffs_epfile_async_io_complete().\nHowever, in order to properly implement locking to mitigate this issue, the\nspinlock can\u0027t be added to ffs_epfile_async_io_complete(), as\nusb_ep_dequeue() (if successfully dequeuing a USB request) will call the\nfunction driver\u0027s completion handler in the same context.  Hence, leading\ninto a deadlock.\n\nFix this issue by moving the usb_ep_free_request() back to\nffs_user_copy_worker(), and ensuring that it explicitly sets io_data-\u003ereq\nto NULL after freeing it within the ffs-\u003eeps_lock.  This resolves the race\ncondition above, as the ffs_aio_cancel() routine will not continue\nattempting to dequeue a request that has already been freed, or the\nffs_user_copy_work() not freeing the USB request until the AIO cancel is\ndone referencing it.\n\nThis fix depends on\n  commit b566d38857fc (\"usb: gadget: f_fs: use io_data-\u003estatus\n  consistently\")"
        }
      ],
      "providerMetadata": {
        "dateUpdated": "2024-07-05T07:51:30.133Z",
        "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
        "shortName": "Linux"
      },
      "references": [
        {
          "url": "https://git.kernel.org/stable/c/f71a53148ce34898fef099b75386a3a9f4449311"
        },
        {
          "url": "https://git.kernel.org/stable/c/9e72ef59cbe61cd1243857a6418ca92104275867"
        },
        {
          "url": "https://git.kernel.org/stable/c/e500b1c4e29ad0bd1c1332a1eaea2913627a92dd"
        },
        {
          "url": "https://git.kernel.org/stable/c/3613e5023f09b3308545e9d1acda86017ebd418a"
        },
        {
          "url": "https://git.kernel.org/stable/c/a0fdccb1c9e027e3195f947f61aa87d6d0d2ea14"
        },
        {
          "url": "https://git.kernel.org/stable/c/73c05ad46bb4fbbdb346004651576d1c8dbcffbb"
        },
        {
          "url": "https://git.kernel.org/stable/c/d7461830823242702f5d84084bcccb25159003f4"
        },
        {
          "url": "https://git.kernel.org/stable/c/24729b307eefcd7c476065cd7351c1a018082c19"
        }
      ],
      "title": "usb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete",
      "x_generator": {
        "engine": "bippy-7d53e8ef8be4"
      }
    }
  },
  "cveMetadata": {
    "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
    "assignerShortName": "Linux",
    "cveId": "CVE-2024-36894",
    "datePublished": "2024-05-30T15:28:59.689Z",
    "dateReserved": "2024-05-30T15:25:07.066Z",
    "dateUpdated": "2024-08-21T16:17:27.715Z",
    "state": "PUBLISHED"
  },
  "dataType": "CVE_RECORD",
  "dataVersion": "5.1",
  "meta": {
    "nvd": "{\"cve\":{\"id\":\"CVE-2024-36894\",\"sourceIdentifier\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"published\":\"2024-05-30T16:15:12.857\",\"lastModified\":\"2024-07-05T08:15:02.850\",\"vulnStatus\":\"Awaiting Analysis\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"In the Linux kernel, the following vulnerability has been resolved:\\n\\nusb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete\\n\\nFFS based applications can utilize the aio_cancel() callback to dequeue\\npending USB requests submitted to the UDC.  There is a scenario where the\\nFFS application issues an AIO cancel call, while the UDC is handling a\\nsoft disconnect.  For a DWC3 based implementation, the callstack looks\\nlike the following:\\n\\n    DWC3 Gadget                               FFS Application\\ndwc3_gadget_soft_disconnect()              ...\\n  --\u003e dwc3_stop_active_transfers()\\n    --\u003e dwc3_gadget_giveback(-ESHUTDOWN)\\n      --\u003e ffs_epfile_async_io_complete()   ffs_aio_cancel()\\n        --\u003e usb_ep_free_request()            --\u003e usb_ep_dequeue()\\n\\nThere is currently no locking implemented between the AIO completion\\nhandler and AIO cancel, so the issue occurs if the completion routine is\\nrunning in parallel to an AIO cancel call coming from the FFS application.\\nAs the completion call frees the USB request (io_data-\u003ereq) the FFS\\napplication is also referencing it for the usb_ep_dequeue() call.  This can\\nlead to accessing a stale/hanging pointer.\\n\\ncommit b566d38857fc (\\\"usb: gadget: f_fs: use io_data-\u003estatus consistently\\\")\\nrelocated the usb_ep_free_request() into ffs_epfile_async_io_complete().\\nHowever, in order to properly implement locking to mitigate this issue, the\\nspinlock can\u0027t be added to ffs_epfile_async_io_complete(), as\\nusb_ep_dequeue() (if successfully dequeuing a USB request) will call the\\nfunction driver\u0027s completion handler in the same context.  Hence, leading\\ninto a deadlock.\\n\\nFix this issue by moving the usb_ep_free_request() back to\\nffs_user_copy_worker(), and ensuring that it explicitly sets io_data-\u003ereq\\nto NULL after freeing it within the ffs-\u003eeps_lock.  This resolves the race\\ncondition above, as the ffs_aio_cancel() routine will not continue\\nattempting to dequeue a request that has already been freed, or the\\nffs_user_copy_work() not freeing the USB request until the AIO cancel is\\ndone referencing it.\\n\\nThis fix depends on\\n  commit b566d38857fc (\\\"usb: gadget: f_fs: use io_data-\u003estatus\\n  consistently\\\")\"},{\"lang\":\"es\",\"value\":\"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: usb: gadget: f_fs: corrige la ejecuci\u00f3n entre aio_cancel() y la solicitud AIO. Las aplicaciones basadas en FFS completas pueden utilizar la devoluci\u00f3n de llamada aio_cancel() para quitar de la cola las solicitudes USB pendientes enviadas al UDC. Existe un escenario en el que la aplicaci\u00f3n FFS emite una llamada de cancelaci\u00f3n de AIO, mientras el UDC maneja una desconexi\u00f3n suave. Para una implementaci\u00f3n basada en DWC3, la pila de llamadas se parece a la siguiente: Aplicaci\u00f3n DWC3 Gadget FFS dwc3_gadget_soft_disconnect() ... --\u0026gt; dwc3_stop_active_transfers() --\u0026gt; dwc3_gadget_giveback(-ESHUTDOWN) --\u0026gt; ffs_epfile_async_io_complete() ffs_aio_cancel() --\u0026gt; usb_ep_free_request () --\u0026gt; usb_ep_dequeue() Actualmente no hay ning\u00fan bloqueo implementado entre el controlador de finalizaci\u00f3n de AIO y la cancelaci\u00f3n de AIO, por lo que el problema ocurre si la rutina de finalizaci\u00f3n se ejecuta en paralelo a una llamada de cancelaci\u00f3n de AIO proveniente de la aplicaci\u00f3n FFS. A medida que la llamada de finalizaci\u00f3n libera la solicitud USB (io_data-\u0026gt;req), la aplicaci\u00f3n FFS tambi\u00e9n hace referencia a ella para la llamada usb_ep_dequeue(). Esto puede llevar a acceder a un puntero obsoleto/colgado. commit b566d38857fc (\\\"usb: gadget: f_fs: use io_data-\u0026gt;status consistentemente\\\") reubic\u00f3 usb_ep_free_request() en ffs_epfile_async_io_complete(). Sin embargo, para implementar correctamente el bloqueo para mitigar este problema, el spinlock no se puede agregar a ffs_epfile_async_io_complete(), ya que usb_ep_dequeue() (si se elimina con \u00e9xito una solicitud USB) llamar\u00e1 al controlador de finalizaci\u00f3n del controlador de funci\u00f3n en el mismo contexto. De ah\u00ed que se llegue a un punto muerto. Solucione este problema moviendo usb_ep_free_request() de nuevo a ffs_user_copy_worker() y asegur\u00e1ndose de que establezca expl\u00edcitamente io_data-\u0026gt;req en NULL despu\u00e9s de liberarlo dentro de ffs-\u0026gt;eps_lock. Esto resuelve la condici\u00f3n de ejecuci\u00f3n anterior, ya que la rutina ffs_aio_cancel() no continuar\u00e1 intentando sacar de la cola una solicitud que ya ha sido liberada, o ffs_user_copy_work() no liberar\u00e1 la solicitud USB hasta que la cancelaci\u00f3n de AIO termine de hacer referencia a ella. Esta soluci\u00f3n depende de el commit b566d38857fc (\\\"usb: gadget: f_fs: use io_data-\u0026gt;status consistentemente\\\")\"}],\"metrics\":{\"cvssMetricV31\":[{\"source\":\"134c704f-9b21-4f2e-91b3-4a467353bcc0\",\"type\":\"Secondary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:P/AC:H/PR:L/UI:N/S:U/C:H/I:N/A:H\",\"attackVector\":\"PHYSICAL\",\"attackComplexity\":\"HIGH\",\"privilegesRequired\":\"LOW\",\"userInteraction\":\"NONE\",\"scope\":\"UNCHANGED\",\"confidentialityImpact\":\"HIGH\",\"integrityImpact\":\"NONE\",\"availabilityImpact\":\"HIGH\",\"baseScore\":5.6,\"baseSeverity\":\"MEDIUM\"},\"exploitabilityScore\":0.4,\"impactScore\":5.2}]},\"weaknesses\":[{\"source\":\"134c704f-9b21-4f2e-91b3-4a467353bcc0\",\"type\":\"Secondary\",\"description\":[{\"lang\":\"en\",\"value\":\"CWE-362\"}]}],\"references\":[{\"url\":\"https://git.kernel.org/stable/c/24729b307eefcd7c476065cd7351c1a018082c19\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/3613e5023f09b3308545e9d1acda86017ebd418a\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/73c05ad46bb4fbbdb346004651576d1c8dbcffbb\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/9e72ef59cbe61cd1243857a6418ca92104275867\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/a0fdccb1c9e027e3195f947f61aa87d6d0d2ea14\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/d7461830823242702f5d84084bcccb25159003f4\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/e500b1c4e29ad0bd1c1332a1eaea2913627a92dd\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/f71a53148ce34898fef099b75386a3a9f4449311\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"}]}}"
  }
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading...

Loading...