cve-2024-41045
Vulnerability from cvelistv5
Published
2024-07-29 14:32
Modified
2024-12-19 09:10
Severity ?
EPSS score ?
0.10% (0.25522)
Summary
In the Linux kernel, the following vulnerability has been resolved: bpf: Defer work in bpf_timer_cancel_and_free Currently, the same case as previous patch (two timer callbacks trying to cancel each other) can be invoked through bpf_map_update_elem as well, or more precisely, freeing map elements containing timers. Since this relies on hrtimer_cancel as well, it is prone to the same deadlock situation as the previous patch. It would be sufficient to use hrtimer_try_to_cancel to fix this problem, as the timer cannot be enqueued after async_cancel_and_free. Once async_cancel_and_free has been done, the timer must be reinitialized before it can be armed again. The callback running in parallel trying to arm the timer will fail, and freeing bpf_hrtimer without waiting is sufficient (given kfree_rcu), and bpf_timer_cb will return HRTIMER_NORESTART, preventing the timer from being rearmed again. However, there exists a UAF scenario where the callback arms the timer before entering this function, such that if cancellation fails (due to timer callback invoking this routine, or the target timer callback running concurrently). In such a case, if the timer expiration is significantly far in the future, the RCU grace period expiration happening before it will free the bpf_hrtimer state and along with it the struct hrtimer, that is enqueued. Hence, it is clear cancellation needs to occur after async_cancel_and_free, and yet it cannot be done inline due to deadlock issues. We thus modify bpf_timer_cancel_and_free to defer work to the global workqueue, adding a work_struct alongside rcu_head (both used at _different_ points of time, so can share space). Update existing code comments to reflect the new state of affairs.
Impacted products
Vendor Product Version
Linux Linux Version: b00628b1c7d595ae5b544e059c27b1f5828314b4
Version: b00628b1c7d595ae5b544e059c27b1f5828314b4
Create a notification for this product.
   Linux Linux Version: 5.15
Create a notification for this product.
Show details on NVD website


{
   containers: {
      adp: [
         {
            providerMetadata: {
               dateUpdated: "2024-08-02T04:46:51.645Z",
               orgId: "af854a3a-2127-422b-91ae-364da2661108",
               shortName: "CVE",
            },
            references: [
               {
                  tags: [
                     "x_transferred",
                  ],
                  url: "https://git.kernel.org/stable/c/7aa5a19279c3639ae8b758b63f05d0c616a39fa1",
               },
               {
                  tags: [
                     "x_transferred",
                  ],
                  url: "https://git.kernel.org/stable/c/a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69",
               },
            ],
            title: "CVE Program Container",
         },
         {
            metrics: [
               {
                  other: {
                     content: {
                        id: "CVE-2024-41045",
                        options: [
                           {
                              Exploitation: "none",
                           },
                           {
                              Automatable: "no",
                           },
                           {
                              "Technical Impact": "partial",
                           },
                        ],
                        role: "CISA Coordinator",
                        timestamp: "2024-09-10T16:23:00.726132Z",
                        version: "2.0.3",
                     },
                     type: "ssvc",
                  },
               },
            ],
            providerMetadata: {
               dateUpdated: "2024-09-11T17:34:02.451Z",
               orgId: "134c704f-9b21-4f2e-91b3-4a467353bcc0",
               shortName: "CISA-ADP",
            },
            title: "CISA ADP Vulnrichment",
         },
      ],
      cna: {
         affected: [
            {
               defaultStatus: "unaffected",
               product: "Linux",
               programFiles: [
                  "kernel/bpf/helpers.c",
               ],
               repo: "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
               vendor: "Linux",
               versions: [
                  {
                     lessThan: "7aa5a19279c3639ae8b758b63f05d0c616a39fa1",
                     status: "affected",
                     version: "b00628b1c7d595ae5b544e059c27b1f5828314b4",
                     versionType: "git",
                  },
                  {
                     lessThan: "a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69",
                     status: "affected",
                     version: "b00628b1c7d595ae5b544e059c27b1f5828314b4",
                     versionType: "git",
                  },
               ],
            },
            {
               defaultStatus: "affected",
               product: "Linux",
               programFiles: [
                  "kernel/bpf/helpers.c",
               ],
               repo: "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
               vendor: "Linux",
               versions: [
                  {
                     status: "affected",
                     version: "5.15",
                  },
                  {
                     lessThan: "5.15",
                     status: "unaffected",
                     version: "0",
                     versionType: "semver",
                  },
                  {
                     lessThanOrEqual: "6.9.*",
                     status: "unaffected",
                     version: "6.9.10",
                     versionType: "semver",
                  },
                  {
                     lessThanOrEqual: "*",
                     status: "unaffected",
                     version: "6.10",
                     versionType: "original_commit_for_fix",
                  },
               ],
            },
         ],
         descriptions: [
            {
               lang: "en",
               value: "In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Defer work in bpf_timer_cancel_and_free\n\nCurrently, the same case as previous patch (two timer callbacks trying\nto cancel each other) can be invoked through bpf_map_update_elem as\nwell, or more precisely, freeing map elements containing timers. Since\nthis relies on hrtimer_cancel as well, it is prone to the same deadlock\nsituation as the previous patch.\n\nIt would be sufficient to use hrtimer_try_to_cancel to fix this problem,\nas the timer cannot be enqueued after async_cancel_and_free. Once\nasync_cancel_and_free has been done, the timer must be reinitialized\nbefore it can be armed again. The callback running in parallel trying to\narm the timer will fail, and freeing bpf_hrtimer without waiting is\nsufficient (given kfree_rcu), and bpf_timer_cb will return\nHRTIMER_NORESTART, preventing the timer from being rearmed again.\n\nHowever, there exists a UAF scenario where the callback arms the timer\nbefore entering this function, such that if cancellation fails (due to\ntimer callback invoking this routine, or the target timer callback\nrunning concurrently). In such a case, if the timer expiration is\nsignificantly far in the future, the RCU grace period expiration\nhappening before it will free the bpf_hrtimer state and along with it\nthe struct hrtimer, that is enqueued.\n\nHence, it is clear cancellation needs to occur after\nasync_cancel_and_free, and yet it cannot be done inline due to deadlock\nissues. We thus modify bpf_timer_cancel_and_free to defer work to the\nglobal workqueue, adding a work_struct alongside rcu_head (both used at\n_different_ points of time, so can share space).\n\nUpdate existing code comments to reflect the new state of affairs.",
            },
         ],
         providerMetadata: {
            dateUpdated: "2024-12-19T09:10:49.027Z",
            orgId: "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
            shortName: "Linux",
         },
         references: [
            {
               url: "https://git.kernel.org/stable/c/7aa5a19279c3639ae8b758b63f05d0c616a39fa1",
            },
            {
               url: "https://git.kernel.org/stable/c/a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69",
            },
         ],
         title: "bpf: Defer work in bpf_timer_cancel_and_free",
         x_generator: {
            engine: "bippy-5f407fcff5a0",
         },
      },
   },
   cveMetadata: {
      assignerOrgId: "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
      assignerShortName: "Linux",
      cveId: "CVE-2024-41045",
      datePublished: "2024-07-29T14:32:02.866Z",
      dateReserved: "2024-07-12T12:17:45.624Z",
      dateUpdated: "2024-12-19T09:10:49.027Z",
      state: "PUBLISHED",
   },
   dataType: "CVE_RECORD",
   dataVersion: "5.1",
   "vulnerability-lookup:meta": {
      nvd: "{\"cve\":{\"id\":\"CVE-2024-41045\",\"sourceIdentifier\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"published\":\"2024-07-29T15:15:12.873\",\"lastModified\":\"2024-11-21T09:32:07.857\",\"vulnStatus\":\"Awaiting Analysis\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"In the Linux kernel, the following vulnerability has been resolved:\\n\\nbpf: Defer work in bpf_timer_cancel_and_free\\n\\nCurrently, the same case as previous patch (two timer callbacks trying\\nto cancel each other) can be invoked through bpf_map_update_elem as\\nwell, or more precisely, freeing map elements containing timers. Since\\nthis relies on hrtimer_cancel as well, it is prone to the same deadlock\\nsituation as the previous patch.\\n\\nIt would be sufficient to use hrtimer_try_to_cancel to fix this problem,\\nas the timer cannot be enqueued after async_cancel_and_free. Once\\nasync_cancel_and_free has been done, the timer must be reinitialized\\nbefore it can be armed again. The callback running in parallel trying to\\narm the timer will fail, and freeing bpf_hrtimer without waiting is\\nsufficient (given kfree_rcu), and bpf_timer_cb will return\\nHRTIMER_NORESTART, preventing the timer from being rearmed again.\\n\\nHowever, there exists a UAF scenario where the callback arms the timer\\nbefore entering this function, such that if cancellation fails (due to\\ntimer callback invoking this routine, or the target timer callback\\nrunning concurrently). In such a case, if the timer expiration is\\nsignificantly far in the future, the RCU grace period expiration\\nhappening before it will free the bpf_hrtimer state and along with it\\nthe struct hrtimer, that is enqueued.\\n\\nHence, it is clear cancellation needs to occur after\\nasync_cancel_and_free, and yet it cannot be done inline due to deadlock\\nissues. We thus modify bpf_timer_cancel_and_free to defer work to the\\nglobal workqueue, adding a work_struct alongside rcu_head (both used at\\n_different_ points of time, so can share space).\\n\\nUpdate existing code comments to reflect the new state of affairs.\"},{\"lang\":\"es\",\"value\":\"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: bpf: Aplazar el trabajo en bpf_timer_cancel_and_free Actualmente, el mismo caso del parche anterior (dos devoluciones de llamada de temporizador que intentan cancelarse entre sí) también se puede invocar a través de bpf_map_update_elem, o más precisamente, liberando mapa elementos que contienen temporizadores. Dado que esto también depende de hrtimer_cancel, es propenso a la misma situación de punto muerto que el parche anterior. Sería suficiente usar hrtimer_try_to_cancel para solucionar este problema, ya que el temporizador no se puede poner en cola después de async_cancel_and_free. Una vez que se haya realizado async_cancel_and_free, el temporizador debe reinicializarse antes de poder armarse nuevamente. La devolución de llamada que se ejecuta en paralelo al intentar armar el temporizador fallará, y liberar bpf_hrtimer sin esperar es suficiente (dado kfree_rcu), y bpf_timer_cb devolverá HRTIMER_NORESTART, evitando que el temporizador se rearme nuevamente. Sin embargo, existe un escenario UAF en el que la devolución de llamada arma el temporizador antes de ingresar a esta función, de modo que si la cancelación falla (debido a que la devolución de llamada del temporizador invoca esta rutina o la devolución de llamada del temporizador de destino se ejecuta simultáneamente). En tal caso, si la expiración del temporizador está significativamente lejos en el futuro, la expiración del período de gracia de RCU que ocurra antes liberará el estado bpf_hrtimer y junto con él la estructura hrtimer, que está en cola. Por lo tanto, está claro que la cancelación debe ocurrir después de async_cancel_and_free y, sin embargo, no se puede realizar en línea debido a problemas de interbloqueo. Por lo tanto, modificamos bpf_timer_cancel_and_free para diferir el trabajo a la cola de trabajo global, agregando un work_struct junto con rcu_head (ambos usados en _diferentes_ puntos de tiempo, por lo que pueden compartir espacio). Actualice los comentarios del código existente para reflejar la nueva situación.\"}],\"metrics\":{},\"references\":[{\"url\":\"https://git.kernel.org/stable/c/7aa5a19279c3639ae8b758b63f05d0c616a39fa1\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/7aa5a19279c3639ae8b758b63f05d0c616a39fa1\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\"},{\"url\":\"https://git.kernel.org/stable/c/a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\"}]}}",
      vulnrichment: {
         containers: "{\"adp\": [{\"title\": \"CVE Program Container\", \"references\": [{\"url\": \"https://git.kernel.org/stable/c/7aa5a19279c3639ae8b758b63f05d0c616a39fa1\", \"tags\": [\"x_transferred\"]}, {\"url\": \"https://git.kernel.org/stable/c/a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69\", \"tags\": [\"x_transferred\"]}], \"providerMetadata\": {\"orgId\": \"af854a3a-2127-422b-91ae-364da2661108\", \"shortName\": \"CVE\", \"dateUpdated\": \"2024-08-02T04:46:51.645Z\"}}, {\"title\": \"CISA ADP Vulnrichment\", \"metrics\": [{\"other\": {\"type\": \"ssvc\", \"content\": {\"id\": \"CVE-2024-41045\", \"role\": \"CISA Coordinator\", \"options\": [{\"Exploitation\": \"none\"}, {\"Automatable\": \"no\"}, {\"Technical Impact\": \"partial\"}], \"version\": \"2.0.3\", \"timestamp\": \"2024-09-10T16:23:00.726132Z\"}}}], \"providerMetadata\": {\"orgId\": \"134c704f-9b21-4f2e-91b3-4a467353bcc0\", \"shortName\": \"CISA-ADP\", \"dateUpdated\": \"2024-09-11T12:42:20.313Z\"}}], \"cna\": {\"title\": \"bpf: Defer work in bpf_timer_cancel_and_free\", \"affected\": [{\"repo\": \"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git\", \"vendor\": \"Linux\", \"product\": \"Linux\", \"versions\": [{\"status\": \"affected\", \"version\": \"b00628b1c7d595ae5b544e059c27b1f5828314b4\", \"lessThan\": \"7aa5a19279c3639ae8b758b63f05d0c616a39fa1\", \"versionType\": \"git\"}, {\"status\": \"affected\", \"version\": \"b00628b1c7d595ae5b544e059c27b1f5828314b4\", \"lessThan\": \"a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69\", \"versionType\": \"git\"}], \"programFiles\": [\"kernel/bpf/helpers.c\"], \"defaultStatus\": \"unaffected\"}, {\"repo\": \"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git\", \"vendor\": \"Linux\", \"product\": \"Linux\", \"versions\": [{\"status\": \"affected\", \"version\": \"5.15\"}, {\"status\": \"unaffected\", \"version\": \"0\", \"lessThan\": \"5.15\", \"versionType\": \"semver\"}, {\"status\": \"unaffected\", \"version\": \"6.9.10\", \"versionType\": \"semver\", \"lessThanOrEqual\": \"6.9.*\"}, {\"status\": \"unaffected\", \"version\": \"6.10\", \"versionType\": \"original_commit_for_fix\", \"lessThanOrEqual\": \"*\"}], \"programFiles\": [\"kernel/bpf/helpers.c\"], \"defaultStatus\": \"affected\"}], \"references\": [{\"url\": \"https://git.kernel.org/stable/c/7aa5a19279c3639ae8b758b63f05d0c616a39fa1\"}, {\"url\": \"https://git.kernel.org/stable/c/a6fcd19d7eac1335eb76bc16b6a66b7f574d1d69\"}], \"x_generator\": {\"engine\": \"bippy-5f407fcff5a0\"}, \"descriptions\": [{\"lang\": \"en\", \"value\": \"In the Linux kernel, the following vulnerability has been resolved:\\n\\nbpf: Defer work in bpf_timer_cancel_and_free\\n\\nCurrently, the same case as previous patch (two timer callbacks trying\\nto cancel each other) can be invoked through bpf_map_update_elem as\\nwell, or more precisely, freeing map elements containing timers. Since\\nthis relies on hrtimer_cancel as well, it is prone to the same deadlock\\nsituation as the previous patch.\\n\\nIt would be sufficient to use hrtimer_try_to_cancel to fix this problem,\\nas the timer cannot be enqueued after async_cancel_and_free. Once\\nasync_cancel_and_free has been done, the timer must be reinitialized\\nbefore it can be armed again. The callback running in parallel trying to\\narm the timer will fail, and freeing bpf_hrtimer without waiting is\\nsufficient (given kfree_rcu), and bpf_timer_cb will return\\nHRTIMER_NORESTART, preventing the timer from being rearmed again.\\n\\nHowever, there exists a UAF scenario where the callback arms the timer\\nbefore entering this function, such that if cancellation fails (due to\\ntimer callback invoking this routine, or the target timer callback\\nrunning concurrently). In such a case, if the timer expiration is\\nsignificantly far in the future, the RCU grace period expiration\\nhappening before it will free the bpf_hrtimer state and along with it\\nthe struct hrtimer, that is enqueued.\\n\\nHence, it is clear cancellation needs to occur after\\nasync_cancel_and_free, and yet it cannot be done inline due to deadlock\\nissues. We thus modify bpf_timer_cancel_and_free to defer work to the\\nglobal workqueue, adding a work_struct alongside rcu_head (both used at\\n_different_ points of time, so can share space).\\n\\nUpdate existing code comments to reflect the new state of affairs.\"}], \"providerMetadata\": {\"orgId\": \"416baaa9-dc9f-4396-8d5f-8c081fb06d67\", \"shortName\": \"Linux\", \"dateUpdated\": \"2024-12-19T09:10:49.027Z\"}}}",
         cveMetadata: "{\"cveId\": \"CVE-2024-41045\", \"state\": \"PUBLISHED\", \"dateUpdated\": \"2024-12-19T09:10:49.027Z\", \"dateReserved\": \"2024-07-12T12:17:45.624Z\", \"assignerOrgId\": \"416baaa9-dc9f-4396-8d5f-8c081fb06d67\", \"datePublished\": \"2024-07-29T14:32:02.866Z\", \"assignerShortName\": \"Linux\"}",
         dataType: "CVE_RECORD",
         dataVersion: "5.1",
      },
   },
}


Log in or create an account to share your comment.

Security Advisory comment format.

This schema specifies the format of a comment related to a security advisory.

UUIDv4 of the comment
UUIDv4 of the Vulnerability-Lookup instance
When the comment was created originally
When the comment was last updated
Title of the comment
Description of the comment
The identifier of the vulnerability (CVE ID, GHSA-ID, PYSEC ID, etc.).



Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.