// For flags

CVE-2021-47350

powerpc/mm: Fix lockup on kernel exec fault

Severity Score

"-"
*CVSS v-

Exploit Likelihood

*EPSS

Affected Versions

*CPE

Public Exploits

0
*Multiple Sources

Exploited in Wild

-
*KEV

Decision

Track
*SSVC
Descriptions

In the Linux kernel, the following vulnerability has been resolved:

powerpc/mm: Fix lockup on kernel exec fault

The powerpc kernel is not prepared to handle exec faults from kernel.
Especially, the function is_exec_fault() will return 'false' when an
exec fault is taken by kernel, because the check is based on reading
current->thread.regs->trap which contains the trap from user.

For instance, when provoking a LKDTM EXEC_USERSPACE test,
current->thread.regs->trap is set to SYSCALL trap (0xc00), and
the fault taken by the kernel is not seen as an exec fault by
set_access_flags_filter().

Commit d7df2443cd5f ("powerpc/mm: Fix spurious segfaults on radix
with autonuma") made it clear and handled it properly. But later on
commit d3ca587404b3 ("powerpc/mm: Fix reporting of kernel execute
faults") removed that handling, introducing test based on error_code.
And here is the problem, because on the 603 all upper bits of SRR1
get cleared when the TLB instruction miss handler bails out to ISI.

Until commit cbd7e6ca0210 ("powerpc/fault: Avoid heavy
search_exception_tables() verification"), an exec fault from kernel
at a userspace address was indirectly caught by the lack of entry for
that address in the exception tables. But after that commit the
kernel mainly relies on KUAP or on core mm handling to catch wrong
user accesses. Here the access is not wrong, so mm handles it.
It is a minor fault because PAGE_EXEC is not set,
set_access_flags_filter() should set PAGE_EXEC and voila.
But as is_exec_fault() returns false as explained in the beginning,
set_access_flags_filter() bails out without setting PAGE_EXEC flag,
which leads to a forever minor exec fault.

As the kernel is not prepared to handle such exec faults, the thing to
do is to fire in bad_kernel_fault() for any exec fault taken by the
kernel, as it was prior to commit d3ca587404b3.

En el kernel de Linux, se resolvió la siguiente vulnerabilidad: powerpc/mm: corrige el bloqueo en el fallo de ejecución del kernel. El kernel de powerpc no está preparado para manejar fallos de ejecución del kernel. Especialmente, la función is_exec_fault() devolverá 'false' cuando el kernel tome un fallo de ejecución, porque la verificación se basa en la lectura de current->thread.regs->trap que contiene la trampa del usuario. Por ejemplo, al provocar una prueba LKDTM EXEC_USERSPACE, current->thread.regs->trap se establece en SYSCALL trap (0xc00), y set_access_flags_filter() no ve el error cometido por el kernel como un error de ejecución. La confirmación d7df2443cd5f ("powerpc/mm: corregir errores de segmentación falsos en radix con autonuma") lo dejó claro y lo manejó correctamente. Pero más tarde, la confirmación d3ca587404b3 ("powerpc/mm: corregir informes de fallas de ejecución del kernel") eliminó ese manejo, introduciendo una prueba basada en error_code. Y aquí está el problema, porque en el 603 todos los bits superiores de SRR1 se borran cuando el controlador de errores de instrucción TLB sale a ISI. Hasta la confirmación cbd7e6ca0210 ("powerpc/fault: Evite la verificación pesada de search_exception_tables()"), un fallo de ejecución del kernel en una dirección de espacio de usuario se detectaba indirectamente por la falta de entrada para esa dirección en las tablas de excepción. Pero después de esa confirmación, el kernel depende principalmente de KUAP o del manejo de mm del núcleo para detectar accesos de usuarios incorrectos. Aquí el acceso no es incorrecto, por lo que mm lo maneja. Es un fallo menor porque PAGE_EXEC no está configurada, set_access_flags_filter() debería configurar PAGE_EXEC y listo. Pero como is_exec_fault() devuelve false como se explicó al principio, set_access_flags_filter() sale sin configurar el indicador PAGE_EXEC, lo que conduce a un fallo de ejecución menor para siempre. Como el kernel no está preparado para manejar tales fallos de ejecución, lo que hay que hacer es activar bad_kernel_fault() para cualquier fallo de ejecución tomado por el kernel, como estaba antes de la confirmación d3ca587404b3.

*Credits: N/A
CVSS Scores
Attack Vector
-
Attack Complexity
-
Privileges Required
-
User Interaction
-
Scope
-
Confidentiality
-
Integrity
-
Availability
-
* Common Vulnerability Scoring System
SSVC
  • Decision:Track
Exploitation
None
Automatable
No
Tech. Impact
Partial
* Organization's Worst-case Scenario
Timeline
  • 2024-05-21 CVE Reserved
  • 2024-05-21 CVE Published
  • 2024-05-22 EPSS Updated
  • 2024-08-04 CVE Updated
  • ---------- Exploited in Wild
  • ---------- KEV Due Date
  • ---------- First Exploit
CWE
CAPEC
Affected Vendors, Products, and Versions
Vendor Product Version Other Status
Vendor Product Version Other Status <-- --> Vendor Product Version Other Status
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 4.14 < 5.4.133
Search vendor "Linux" for product "Linux Kernel" and version " >= 4.14 < 5.4.133"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 4.14 < 5.10.51
Search vendor "Linux" for product "Linux Kernel" and version " >= 4.14 < 5.10.51"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 4.14 < 5.12.18
Search vendor "Linux" for product "Linux Kernel" and version " >= 4.14 < 5.12.18"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 4.14 < 5.13.3
Search vendor "Linux" for product "Linux Kernel" and version " >= 4.14 < 5.13.3"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 4.14 < 5.14
Search vendor "Linux" for product "Linux Kernel" and version " >= 4.14 < 5.14"
en
Affected