cve-2021-47465
Vulnerability from cvelistv5
Published
2024-05-22 06:23
Modified
2024-08-04 05:39
Severity
Summary
KVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest()
Impacted products
VendorProduct
LinuxLinux
LinuxLinux
Show details on NVD website


{
  "containers": {
    "adp": [
      {
        "metrics": [
          {
            "other": {
              "content": {
                "id": "CVE-2021-47465",
                "options": [
                  {
                    "Exploitation": "none"
                  },
                  {
                    "Automatable": "no"
                  },
                  {
                    "Technical Impact": "partial"
                  }
                ],
                "role": "CISA Coordinator",
                "timestamp": "2024-05-29T18:41:27.701748Z",
                "version": "2.0.3"
              },
              "type": "ssvc"
            }
          }
        ],
        "providerMetadata": {
          "dateUpdated": "2024-06-04T17:14:10.403Z",
          "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
          "shortName": "CISA-ADP"
        },
        "title": "CISA ADP Vulnrichment"
      },
      {
        "providerMetadata": {
          "dateUpdated": "2024-08-04T05:39:59.601Z",
          "orgId": "af854a3a-2127-422b-91ae-364da2661108",
          "shortName": "CVE"
        },
        "references": [
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/80bbb0bc3a0288442f7fe6fc514f4ee1cb06ccb7"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/fbd724c49bead048ae9fc1a5b7bff2fb3e54f855"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/6d077c37c4643394b1bae9682da48164fc147ea8"
          },
          {
            "tags": [
              "x_transferred"
            ],
            "url": "https://git.kernel.org/stable/c/9b4416c5095c20e110c82ae602c254099b83b72f"
          }
        ],
        "title": "CVE Program Container"
      }
    ],
    "cna": {
      "affected": [
        {
          "defaultStatus": "unaffected",
          "product": "Linux",
          "programFiles": [
            "arch/powerpc/kvm/book3s_hv_rmhandlers.S"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "lessThan": "80bbb0bc3a02",
              "status": "affected",
              "version": "10d91611f426",
              "versionType": "git"
            },
            {
              "lessThan": "fbd724c49bea",
              "status": "affected",
              "version": "10d91611f426",
              "versionType": "git"
            },
            {
              "lessThan": "6d077c37c464",
              "status": "affected",
              "version": "10d91611f426",
              "versionType": "git"
            },
            {
              "lessThan": "9b4416c5095c",
              "status": "affected",
              "version": "10d91611f426",
              "versionType": "git"
            }
          ]
        },
        {
          "defaultStatus": "affected",
          "product": "Linux",
          "programFiles": [
            "arch/powerpc/kvm/book3s_hv_rmhandlers.S"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "status": "affected",
              "version": "5.2"
            },
            {
              "lessThan": "5.2",
              "status": "unaffected",
              "version": "0",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "5.4.*",
              "status": "unaffected",
              "version": "5.4.156",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "5.10.*",
              "status": "unaffected",
              "version": "5.10.76",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "5.14.*",
              "status": "unaffected",
              "version": "5.14.15",
              "versionType": "custom"
            },
            {
              "lessThanOrEqual": "*",
              "status": "unaffected",
              "version": "5.15",
              "versionType": "original_commit_for_fix"
            }
          ]
        }
      ],
      "descriptions": [
        {
          "lang": "en",
          "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nKVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest()\n\nIn commit 10d91611f426 (\"powerpc/64s: Reimplement book3s idle code in\nC\") kvm_start_guest() became idle_kvm_start_guest(). The old code\nallocated a stack frame on the emergency stack, but didn\u0027t use the\nframe to store anything, and also didn\u0027t store anything in its caller\u0027s\nframe.\n\nidle_kvm_start_guest() on the other hand is written more like a normal C\nfunction, it creates a frame on entry, and also stores CR/LR into its\ncallers frame (per the ABI). The problem is that there is no caller\nframe on the emergency stack.\n\nThe emergency stack for a given CPU is allocated with:\n\n  paca_ptrs[i]-\u003eemergency_sp = alloc_stack(limit, i) + THREAD_SIZE;\n\nSo emergency_sp actually points to the first address above the emergency\nstack allocation for a given CPU, we must not store above it without\nfirst decrementing it to create a frame. This is different to the\nregular kernel stack, paca-\u003ekstack, which is initialised to point at an\ninitial frame that is ready to use.\n\nidle_kvm_start_guest() stores the backchain, CR and LR all of which\nwrite outside the allocation for the emergency stack. It then creates a\nstack frame and saves the non-volatile registers. Unfortunately the\nframe it creates is not large enough to fit the non-volatiles, and so\nthe saving of the non-volatile registers also writes outside the\nemergency stack allocation.\n\nThe end result is that we corrupt whatever is at 0-24 bytes, and 112-248\nbytes above the emergency stack allocation.\n\nIn practice this has gone unnoticed because the memory immediately above\nthe emergency stack happens to be used for other stack allocations,\neither another CPUs mc_emergency_sp or an IRQ stack. See the order of\ncalls to irqstack_early_init() and emergency_stack_init().\n\nThe low addresses of another stack are the top of that stack, and so are\nonly used if that stack is under extreme pressue, which essentially\nnever happens in practice - and if it did there\u0027s a high likelyhood we\u0027d\ncrash due to that stack overflowing.\n\nStill, we shouldn\u0027t be corrupting someone else\u0027s stack, and it is purely\nluck that we aren\u0027t corrupting something else.\n\nTo fix it we save CR/LR into the caller\u0027s frame using the existing r1 on\nentry, we then create a SWITCH_FRAME_SIZE frame (which has space for\npt_regs) on the emergency stack with the backchain pointing to the\nexisting stack, and then finally we switch to the new frame on the\nemergency stack."
        }
      ],
      "providerMetadata": {
        "dateUpdated": "2024-05-29T05:08:24.817Z",
        "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
        "shortName": "Linux"
      },
      "references": [
        {
          "url": "https://git.kernel.org/stable/c/80bbb0bc3a0288442f7fe6fc514f4ee1cb06ccb7"
        },
        {
          "url": "https://git.kernel.org/stable/c/fbd724c49bead048ae9fc1a5b7bff2fb3e54f855"
        },
        {
          "url": "https://git.kernel.org/stable/c/6d077c37c4643394b1bae9682da48164fc147ea8"
        },
        {
          "url": "https://git.kernel.org/stable/c/9b4416c5095c20e110c82ae602c254099b83b72f"
        }
      ],
      "title": "KVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest()",
      "x_generator": {
        "engine": "bippy-a5840b7849dd"
      }
    }
  },
  "cveMetadata": {
    "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
    "assignerShortName": "Linux",
    "cveId": "CVE-2021-47465",
    "datePublished": "2024-05-22T06:23:25.027Z",
    "dateReserved": "2024-05-22T06:20:56.198Z",
    "dateUpdated": "2024-08-04T05:39:59.601Z",
    "state": "PUBLISHED"
  },
  "dataType": "CVE_RECORD",
  "dataVersion": "5.1",
  "meta": {
    "nvd": "{\"cve\":{\"id\":\"CVE-2021-47465\",\"sourceIdentifier\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"published\":\"2024-05-22T07:15:11.367\",\"lastModified\":\"2024-05-22T12:46:53.887\",\"vulnStatus\":\"Awaiting Analysis\",\"descriptions\":[{\"lang\":\"en\",\"value\":\"In the Linux kernel, the following vulnerability has been resolved:\\n\\nKVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest()\\n\\nIn commit 10d91611f426 (\\\"powerpc/64s: Reimplement book3s idle code in\\nC\\\") kvm_start_guest() became idle_kvm_start_guest(). The old code\\nallocated a stack frame on the emergency stack, but didn\u0027t use the\\nframe to store anything, and also didn\u0027t store anything in its caller\u0027s\\nframe.\\n\\nidle_kvm_start_guest() on the other hand is written more like a normal C\\nfunction, it creates a frame on entry, and also stores CR/LR into its\\ncallers frame (per the ABI). The problem is that there is no caller\\nframe on the emergency stack.\\n\\nThe emergency stack for a given CPU is allocated with:\\n\\n  paca_ptrs[i]-\u003eemergency_sp = alloc_stack(limit, i) + THREAD_SIZE;\\n\\nSo emergency_sp actually points to the first address above the emergency\\nstack allocation for a given CPU, we must not store above it without\\nfirst decrementing it to create a frame. This is different to the\\nregular kernel stack, paca-\u003ekstack, which is initialised to point at an\\ninitial frame that is ready to use.\\n\\nidle_kvm_start_guest() stores the backchain, CR and LR all of which\\nwrite outside the allocation for the emergency stack. It then creates a\\nstack frame and saves the non-volatile registers. Unfortunately the\\nframe it creates is not large enough to fit the non-volatiles, and so\\nthe saving of the non-volatile registers also writes outside the\\nemergency stack allocation.\\n\\nThe end result is that we corrupt whatever is at 0-24 bytes, and 112-248\\nbytes above the emergency stack allocation.\\n\\nIn practice this has gone unnoticed because the memory immediately above\\nthe emergency stack happens to be used for other stack allocations,\\neither another CPUs mc_emergency_sp or an IRQ stack. See the order of\\ncalls to irqstack_early_init() and emergency_stack_init().\\n\\nThe low addresses of another stack are the top of that stack, and so are\\nonly used if that stack is under extreme pressue, which essentially\\nnever happens in practice - and if it did there\u0027s a high likelyhood we\u0027d\\ncrash due to that stack overflowing.\\n\\nStill, we shouldn\u0027t be corrupting someone else\u0027s stack, and it is purely\\nluck that we aren\u0027t corrupting something else.\\n\\nTo fix it we save CR/LR into the caller\u0027s frame using the existing r1 on\\nentry, we then create a SWITCH_FRAME_SIZE frame (which has space for\\npt_regs) on the emergency stack with the backchain pointing to the\\nexisting stack, and then finally we switch to the new frame on the\\nemergency stack.\"},{\"lang\":\"es\",\"value\":\"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: KVM: PPC: Book3S HV: Arreglar el manejo de la pila en idle_kvm_start_guest() En el commit 10d91611f426 (\\\"powerpc/64s: Reimplementar el c\u00f3digo inactivo de book3s en C\\\") kvm_start_guest() se convirti\u00f3 en idle_kvm_start_guest() . El c\u00f3digo antiguo asignaba un marco de pila en la pila de emergencia, pero no usaba el marco para almacenar nada y tampoco almacenaba nada en el marco de la persona que llama. idle_kvm_start_guest(), por otro lado, se escribe m\u00e1s como una funci\u00f3n C normal, crea un marco al ingresar y tambi\u00e9n almacena CR/LR en el marco de la persona que llama (seg\u00fan la ABI). El problema es que no hay ning\u00fan marco de llamada en la pila de emergencia. La pila de emergencia para una CPU determinada se asigna con: paca_ptrs[i]-\u0026gt;emergency_sp = alloc_stack(limit, i) + THREAD_SIZE; Entonces, Emergency_sp en realidad apunta a la primera direcci\u00f3n encima de la asignaci\u00f3n de pila de emergencia para una CPU determinada; no debemos almacenar encima de ella sin primero disminuirla para crear un marco. Esto es diferente a la pila normal del kernel, paca-\u0026gt;kstack, que se inicializa para apuntar a un marco inicial que est\u00e1 listo para usar. idle_kvm_start_guest() almacena la cadena posterior, CR y LR, todos los cuales escriben fuera de la asignaci\u00f3n para la pila de emergencia. Luego crea un marco de pila y guarda los registros no vol\u00e1tiles. Desafortunadamente, el marco que crea no es lo suficientemente grande para acomodar los registros no vol\u00e1tiles, por lo que guardar los registros no vol\u00e1tiles tambi\u00e9n escribe fuera de la asignaci\u00f3n de pila de emergencia. El resultado final es que corrompemos todo lo que est\u00e9 entre 0 y 24 bytes y entre 112 y 248 bytes por encima de la asignaci\u00f3n de pila de emergencia. En la pr\u00e1ctica, esto ha pasado desapercibido porque la memoria inmediatamente encima de la pila de emergencia se usa para otras asignaciones de pila, ya sea otra CPU mc_emergency_sp o una pila IRQ. Vea el orden de las llamadas a irqstack_early_init() y Emergency_stack_init(). Las direcciones bajas de otra pila est\u00e1n en la parte superior de esa pila, por lo que solo se usan si esa pila est\u00e1 bajo una presi\u00f3n extrema, lo que esencialmente nunca sucede en la pr\u00e1ctica, y si as\u00ed fuera, existe una alta probabilidad de que fallemos debido a que esa pila se desborde. . A\u00fan as\u00ed, no deber\u00edamos estar corrompiendo la pila de otra persona, y es pura suerte que no estemos corrompiendo algo m\u00e1s. Para solucionarlo, guardamos CR/LR en el marco de la persona que llama usando el r1 existente en la entrada, luego creamos un marco SWITCH_FRAME_SIZE (que tiene espacio para pt_regs) en la pila de emergencia con la cadena posterior apuntando a la pila existente, y finalmente cambiamos al nuevo marco en la pila de emergencia.\"}],\"metrics\":{},\"references\":[{\"url\":\"https://git.kernel.org/stable/c/6d077c37c4643394b1bae9682da48164fc147ea8\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/80bbb0bc3a0288442f7fe6fc514f4ee1cb06ccb7\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/9b4416c5095c20e110c82ae602c254099b83b72f\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/fbd724c49bead048ae9fc1a5b7bff2fb3e54f855\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"}]}}"
  }
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading...

Loading...