cve-2024-26737
Vulnerability from cvelistv5
Published
2024-04-03 17:00
Modified
2024-08-02 00:14
Severity
Summary
bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel
Impacted products
VendorProduct
LinuxLinux
LinuxLinux
Show details on NVD website


{
  "containers": {
    "adp": [
      {
        "metrics": [
          {
            "other": {
              "content": {
                "id": "CVE-2024-26737",
                "options": [
                  {
                    "Exploitation": "none"
                  },
                  {
                    "Automatable": "no"
                  },
                  {
                    "Technical Impact": "partial"
                  }
                ],
                "role": "CISA Coordinator",
                "timestamp": "2024-04-03T19:13:11.173900Z",
                "version": "2.0.3"
              },
              "type": "ssvc"
            }
          }
        ],
        "providerMetadata": {
          "dateUpdated": "2024-06-04T17:48:15.973Z",
          "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
          "shortName": "CISA-ADP"
        },
        "title": "CISA ADP Vulnrichment"
      },
      {
        "providerMetadata": {
          "dateUpdated": "2024-08-02T00:14:13.230Z",
          "orgId": "af854a3a-2127-422b-91ae-364da2661108",
          "shortName": "CVE"
        },
        "references": [
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/5268bb02107b9eedfdcd51db75b407d10043368c"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/addf5e297e6cbf5341f9c07720693ca9ba0057b5"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/8327ed12e8ebc5436bfaa1786c49988894f9c8a6"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/7d80a9e745fa5b47da3bca001f186c02485c7c33"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/0281b919e175bb9c3128bd3872ac2903e9436e3f"
          }
        ],
        "title": "CVE Program Container"
      }
    ],
    "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": "5268bb02107b",
              "status": "affected",
              "version": "b00628b1c7d5",
              "versionType": "git"
            },
            {
              "lessThan": "addf5e297e6c",
              "status": "affected",
              "version": "b00628b1c7d5",
              "versionType": "git"
            },
            {
              "lessThan": "8327ed12e8eb",
              "status": "affected",
              "version": "b00628b1c7d5",
              "versionType": "git"
            },
            {
              "lessThan": "7d80a9e745fa",
              "status": "affected",
              "version": "b00628b1c7d5",
              "versionType": "git"
            },
            {
              "lessThan": "0281b919e175",
              "status": "affected",
              "version": "b00628b1c7d5",
              "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": "custom"
            },
            {
              "lessThanOrEqual": "5.15.*",
              "status": "unaffected",
              "version": "5.15.150",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "6.1.*",
              "status": "unaffected",
              "version": "6.1.80",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "6.6.*",
              "status": "unaffected",
              "version": "6.6.19",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "6.7.*",
              "status": "unaffected",
              "version": "6.7.7",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "*",
              "status": "unaffected",
              "version": "6.8",
              "versionType": "original_commit_for_fix"
            }
          ]
        }
      ],
      "descriptions": [
        {
          "lang": "en",
          "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel\n\nThe following race is possible between bpf_timer_cancel_and_free\nand bpf_timer_cancel. It will lead a UAF on the timer-\u003etimer.\n\nbpf_timer_cancel();\n\tspin_lock();\n\tt = timer-\u003etime;\n\tspin_unlock();\n\n\t\t\t\t\tbpf_timer_cancel_and_free();\n\t\t\t\t\t\tspin_lock();\n\t\t\t\t\t\tt = timer-\u003etimer;\n\t\t\t\t\t\ttimer-\u003etimer = NULL;\n\t\t\t\t\t\tspin_unlock();\n\t\t\t\t\t\thrtimer_cancel(\u0026t-\u003etimer);\n\t\t\t\t\t\tkfree(t);\n\n\t/* UAF on t */\n\thrtimer_cancel(\u0026t-\u003etimer);\n\nIn bpf_timer_cancel_and_free, this patch frees the timer-\u003etimer\nafter a rcu grace period. This requires a rcu_head addition\nto the \"struct bpf_hrtimer\". Another kfree(t) happens in bpf_timer_init,\nthis does not need a kfree_rcu because it is still under the\nspin_lock and timer-\u003etimer has not been visible by others yet.\n\nIn bpf_timer_cancel, rcu_read_lock() is added because this helper\ncan be used in a non rcu critical section context (e.g. from\na sleepable bpf prog). Other timer-\u003etimer usages in helpers.c\nhave been audited, bpf_timer_cancel() is the only place where\ntimer-\u003etimer is used outside of the spin_lock.\n\nAnother solution considered is to mark a t-\u003eflag in bpf_timer_cancel\nand clear it after hrtimer_cancel() is done.  In bpf_timer_cancel_and_free,\nit busy waits for the flag to be cleared before kfree(t). This patch\ngoes with a straight forward solution and frees timer-\u003etimer after\na rcu grace period."
        }
      ],
      "providerMetadata": {
        "dateUpdated": "2024-05-29T05:21:48.667Z",
        "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
        "shortName": "Linux"
      },
      "references": [
        {
          "url": "https://git.kernel.org/stable/c/5268bb02107b9eedfdcd51db75b407d10043368c"
        },
        {
          "url": "https://git.kernel.org/stable/c/addf5e297e6cbf5341f9c07720693ca9ba0057b5"
        },
        {
          "url": "https://git.kernel.org/stable/c/8327ed12e8ebc5436bfaa1786c49988894f9c8a6"
        },
        {
          "url": "https://git.kernel.org/stable/c/7d80a9e745fa5b47da3bca001f186c02485c7c33"
        },
        {
          "url": "https://git.kernel.org/stable/c/0281b919e175bb9c3128bd3872ac2903e9436e3f"
        }
      ],
      "title": "bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel",
      "x_generator": {
        "engine": "bippy-a5840b7849dd"
      }
    }
  },
  "cveMetadata": {
    "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
    "assignerShortName": "Linux",
    "cveId": "CVE-2024-26737",
    "datePublished": "2024-04-03T17:00:23.414Z",
    "dateReserved": "2024-02-19T14:20:24.166Z",
    "dateUpdated": "2024-08-02T00:14:13.230Z",
    "state": "PUBLISHED"
  },
  "dataType": "CVE_RECORD",
  "dataVersion": "5.1",
  "meta": {
    "nvd": "{\"cve\":{\"id\":\"CVE-2024-26737\",\"sourceIdentifier\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"published\":\"2024-04-03T17:15:51.243\",\"lastModified\":\"2024-04-03T17:24:18.150\",\"vulnStatus\":\"Awaiting Analysis\",\"descriptions\":[{\"lang\":\"en\",\"value\":\"In the Linux kernel, the following vulnerability has been resolved:\\n\\nbpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel\\n\\nThe following race is possible between bpf_timer_cancel_and_free\\nand bpf_timer_cancel. It will lead a UAF on the timer-\u003etimer.\\n\\nbpf_timer_cancel();\\n\\tspin_lock();\\n\\tt = timer-\u003etime;\\n\\tspin_unlock();\\n\\n\\t\\t\\t\\t\\tbpf_timer_cancel_and_free();\\n\\t\\t\\t\\t\\t\\tspin_lock();\\n\\t\\t\\t\\t\\t\\tt = timer-\u003etimer;\\n\\t\\t\\t\\t\\t\\ttimer-\u003etimer = NULL;\\n\\t\\t\\t\\t\\t\\tspin_unlock();\\n\\t\\t\\t\\t\\t\\thrtimer_cancel(\u0026t-\u003etimer);\\n\\t\\t\\t\\t\\t\\tkfree(t);\\n\\n\\t/* UAF on t */\\n\\thrtimer_cancel(\u0026t-\u003etimer);\\n\\nIn bpf_timer_cancel_and_free, this patch frees the timer-\u003etimer\\nafter a rcu grace period. This requires a rcu_head addition\\nto the \\\"struct bpf_hrtimer\\\". Another kfree(t) happens in bpf_timer_init,\\nthis does not need a kfree_rcu because it is still under the\\nspin_lock and timer-\u003etimer has not been visible by others yet.\\n\\nIn bpf_timer_cancel, rcu_read_lock() is added because this helper\\ncan be used in a non rcu critical section context (e.g. from\\na sleepable bpf prog). Other timer-\u003etimer usages in helpers.c\\nhave been audited, bpf_timer_cancel() is the only place where\\ntimer-\u003etimer is used outside of the spin_lock.\\n\\nAnother solution considered is to mark a t-\u003eflag in bpf_timer_cancel\\nand clear it after hrtimer_cancel() is done.  In bpf_timer_cancel_and_free,\\nit busy waits for the flag to be cleared before kfree(t). This patch\\ngoes with a straight forward solution and frees timer-\u003etimer after\\na rcu grace period.\"},{\"lang\":\"es\",\"value\":\"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: bpf: Correcci\u00f3n de ejecuci\u00f3ns entre bpf_timer_cancel_and_free y bpf_timer_cancel La siguiente ejecuci\u00f3n es posible entre bpf_timer_cancel_and_free y bpf_timer_cancel. Dirigir\u00e1 una UAF en el temporizador-\u0026gt;temporizador. bpf_timer_cancel(); spin_lock(); t = temporizador-\u0026gt;tiempo; spin_unlock(); bpf_timer_cancel_and_free(); spin_lock(); t = temporizador-\u0026gt;temporizador; temporizador-\u0026gt;temporizador = NULL; spin_unlock(); hrtimer_cancel(\u0026amp;t-\u0026gt;temporizador); klibre(t); /* UAF en t */ hrtimer_cancel(\u0026amp;t-\u0026gt;timer); En bpf_timer_cancel_and_free, este parche libera el temporizador-\u0026gt;temporizador despu\u00e9s de un per\u00edodo de gracia de rcu. Esto requiere una adici\u00f3n de rcu_head a \\\"struct bpf_hrtimer\\\". Otro kfree(t) ocurre en bpf_timer_init, esto no necesita un kfree_rcu porque todav\u00eda est\u00e1 bajo spin_lock y otros a\u00fan no han visible el temporizador-\u0026gt;temporizador. En bpf_timer_cancel, se agrega rcu_read_lock() porque este asistente puede usarse en un contexto de secci\u00f3n no cr\u00edtica para rcu (por ejemplo, desde un programa bpf que se puede dormir). Se han auditado otros usos de temporizador-\u0026gt;temporizador en helpers.c, bpf_timer_cancel() es el \u00fanico lugar donde se usa temporizador-\u0026gt;temporizador fuera de spin_lock. Otra soluci\u00f3n considerada es marcar una bandera t-\u0026gt; en bpf_timer_cancel y borrarla una vez finalizado hrtimer_cancel(). En bpf_timer_cancel_and_free, est\u00e1 ocupado esperando a que se borre la bandera antes de kfree(t). Este parche incluye una soluci\u00f3n sencilla y libera el temporizador-\u0026gt;temporizador despu\u00e9s de un per\u00edodo de gracia de rcu.\"}],\"metrics\":{},\"references\":[{\"url\":\"https://git.kernel.org/stable/c/0281b919e175bb9c3128bd3872ac2903e9436e3f\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/5268bb02107b9eedfdcd51db75b407d10043368c\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/7d80a9e745fa5b47da3bca001f186c02485c7c33\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/8327ed12e8ebc5436bfaa1786c49988894f9c8a6\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/addf5e297e6cbf5341f9c07720693ca9ba0057b5\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"}]}}"
  }
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading...

Loading...