CVE-2024-50194

In the Linux kernel, the following vulnerability has been resolved: arm64: probes: Fix uprobes for big-endian kernels The arm64 uprobes code is broken for big-endian kernels as it doesn't convert the in-memory instruction encoding (which is always little-endian) into the kernel's native endianness before analyzing and simulating instructions. This may result in a few distinct problems: * The kernel may may erroneously reject probing an instruction which can safely be probed. * The kernel may erroneously erroneously permit stepping an instruction out-of-line when that instruction cannot be stepped out-of-line safely. * The kernel may erroneously simulate instruction incorrectly dur to interpretting the byte-swapped encoding. The endianness mismatch isn't caught by the compiler or sparse because: * The arch_uprobe::{insn,ixol} fields are encoded as arrays of u8, so the compiler and sparse have no idea these contain a little-endian 32-bit value. The core uprobes code populates these with a memcpy() which similarly does not handle endianness. * While the uprobe_opcode_t type is an alias for __le32, both arch_uprobe_analyze_insn() and arch_uprobe_skip_sstep() cast from u8[] to the similarly-named probe_opcode_t, which is an alias for u32. Hence there is no endianness conversion warning. Fix this by changing the arch_uprobe::{insn,ixol} fields to __le32 and adding the appropriate __le32_to_cpu() conversions prior to consuming the instruction encoding. The core uprobes copies these fields as opaque ranges of bytes, and so is unaffected by this change. At the same time, remove MAX_UINSN_BYTES and consistently use AARCH64_INSN_SIZE for clarity. Tested with the following: | #include <stdio.h> | #include <stdbool.h> | | #define noinline __attribute__((noinline)) | | static noinline void *adrp_self(void) | { | void *addr; | | asm volatile( | " adrp %x0, adrp_self\n" | " add %x0, %x0, :lo12:adrp_self\n" | : "=r" (addr)); | } | | | int main(int argc, char *argv) | { | void *ptr = adrp_self(); | bool equal = (ptr == adrp_self); | | printf("adrp_self => %p\n" | "adrp_self() => %p\n" | "%s\n", | adrp_self, ptr, equal ? "EQUAL" : "NOT EQUAL"); | | return 0; | } .... where the adrp_self() function was compiled to: | 00000000004007e0 <adrp_self>: | 4007e0: 90000000 adrp x0, 400000 <__ehdr_start> | 4007e4: 911f8000 add x0, x0, #0x7e0 | 4007e8: d65f03c0 ret Before this patch, the ADRP is not recognized, and is assumed to be steppable, resulting in corruption of the result: | # ./adrp-self | adrp_self => 0x4007e0 | adrp_self() => 0x4007e0 | EQUAL | # echo 'p /root/adrp-self:0x007e0' > /sys/kernel/tracing/uprobe_events | # echo 1 > /sys/kernel/tracing/events/uprobes/enable | # ./adrp-self | adrp_self => 0x4007e0 | adrp_self() => 0xffffffffff7e0 | NOT EQUAL After this patch, the ADRP is correctly recognized and simulated: | # ./adrp-self | adrp_self => 0x4007e0 | adrp_self() => 0x4007e0 | EQUAL | # | # echo 'p /root/adrp-self:0x007e0' > /sys/kernel/tracing/uprobe_events | # echo 1 > /sys/kernel/tracing/events/uprobes/enable | # ./adrp-self | adrp_self => 0x4007e0 | adrp_self() => 0x4007e0 | EQUAL
Configurations

Configuration 1 (hide)

OR cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.12:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.12:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.12:rc3:*:*:*:*:*:*

History

29 Nov 2024, 19:33

Type Values Removed Values Added
First Time Linux linux Kernel
Linux
CPE cpe:2.3:o:linux:linux_kernel:6.12:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.12:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.12:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
CWE NVD-CWE-noinfo
CVSS v2 : unknown
v3 : unknown
v2 : unknown
v3 : 5.5
References () https://git.kernel.org/stable/c/13f8f1e05f1dc36dbba6cba0ae03354c0dafcde7 - () https://git.kernel.org/stable/c/13f8f1e05f1dc36dbba6cba0ae03354c0dafcde7 - Patch
References () https://git.kernel.org/stable/c/14841bb7a531b96e2dde37423a3b33e75147c60d - () https://git.kernel.org/stable/c/14841bb7a531b96e2dde37423a3b33e75147c60d - Patch
References () https://git.kernel.org/stable/c/3d2530c65be04e93720e30f191a7cf1a3aa8b51c - () https://git.kernel.org/stable/c/3d2530c65be04e93720e30f191a7cf1a3aa8b51c - Patch
References () https://git.kernel.org/stable/c/8165bf83b8a64be801d59cd2532b0d1ffed74d00 - () https://git.kernel.org/stable/c/8165bf83b8a64be801d59cd2532b0d1ffed74d00 - Patch
References () https://git.kernel.org/stable/c/b6a638cb600e13f94b5464724eaa6ab7f3349ca2 - () https://git.kernel.org/stable/c/b6a638cb600e13f94b5464724eaa6ab7f3349ca2 - Patch
References () https://git.kernel.org/stable/c/cf60d19d40184e43d9a624e55a0da73be09e938d - () https://git.kernel.org/stable/c/cf60d19d40184e43d9a624e55a0da73be09e938d - Patch
References () https://git.kernel.org/stable/c/cf9ddf9ed94c15564a05bbf6e9f18dffa0c7df80 - () https://git.kernel.org/stable/c/cf9ddf9ed94c15564a05bbf6e9f18dffa0c7df80 - Patch
References () https://git.kernel.org/stable/c/e6ab336213918575124d6db43dc5d3554526242e - () https://git.kernel.org/stable/c/e6ab336213918575124d6db43dc5d3554526242e - Patch

08 Nov 2024, 16:15

Type Values Removed Values Added
Summary
  • (es) En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: arm64: sondas: corrige uprobes para kernels big-endian El código de uprobes de arm64 está roto para kernels big-endian ya que no convierte la codificación de instrucciones en memoria (que siempre es little-endian) al endianness nativo del kernel antes de analizar y simular instrucciones. Esto puede resultar en algunos problemas distintos: * El kernel puede rechazar erróneamente el sondeo de una instrucción que puede sondearse de forma segura. * El kernel puede permitir erróneamente el paso de una instrucción fuera de línea cuando esa instrucción no puede ser pasada fuera de línea de forma segura. * El kernel puede simular erróneamente la instrucción incorrectamente durante la interpretación de la codificación de bytes intercambiados. El desajuste de endianness no es detectado por el compilador o sparse porque: * Los campos arch_uprobe::{insn,ixol} están codificados como matrices de u8, por lo que el compilador y sparse no tienen idea de que estos contienen un valor de 32 bits little-endian. El código central de uprobes los llena con un memcpy() que de manera similar no maneja el endianness. * Si bien el tipo uprobe_opcode_t es un alias para __le32, tanto arch_uprobe_analyze_insn() como arch_uprobe_skip_sstep() convierten de u8[] al tipo de nombre similar probe_opcode_t, que es un alias para u32. Por lo tanto, no hay una advertencia de conversión de endianness. Solucione esto cambiando los campos arch_uprobe::{insn,ixol} a __le32 y agregando las conversiones __le32_to_cpu() apropiadas antes de consumir la codificación de instrucciones. El núcleo uprobes copia estos campos como rangos opacos de bytes y, por lo tanto, no se ve afectado por este cambio. Al mismo tiempo, elimine MAX_UINSN_BYTES y use consistentemente AARCH64_INSN_SIZE para mayor claridad. Probado con lo siguiente: | #include | #include | | #define noinline __attribute__((noinline)) | | static noinline void *adrp_self(void) | { | void *addr; | | asm volátil( | " adrp %x0, adrp_self\n" | " add %x0, %x0, :lo12:adrp_self\n" | : "=r" (addr)); | } | | | int main(int argc, char *argv) | { | void *ptr = adrp_self(); | bool equal = (ptr == adrp_self); | | printf("adrp_self =&gt; %p\n" | "adrp_self() =&gt; %p\n" | "%s\n", | adrp_self, ptr, equal ? "EQUAL" : "NOT EQUAL"); | | return 0; | } .... donde la función adrp_self() se compiló a: | 00000000004007e0 : | 4007e0: 90000000 adrp x0, 400000 &lt;__ehdr_start&gt; | 4007e4: 911f8000 add x0, x0, #0x7e0 | 4007e8: d65f03c0 ret Antes de este parche, no se reconocía el ADRP y se asumía que se podía ejecutar paso a paso, lo que provocaba la corrupción del resultado: | # ./adrp-self | adrp_self =&gt; 0x4007e0 | adrp_self() =&gt; 0x4007e0 | IGUAL | # echo 'p /root/adrp-self:0x007e0' &gt; /sys/kernel/tracing/uprobe_events | # echo 1 &gt; /sys/kernel/tracing/events/uprobes/enable | # ./adrp-self | adrp_self =&gt; 0x4007e0 | adrp_self() =&gt; 0xffffffffff7e0 | NO IGUAL Después de este parche, el ADRP se reconoce y simula correctamente: | # ./adrp-self | adrp_self =&gt; 0x4007e0 | adrp_self() =&gt; 0x4007e0 | IGUAL | # | # echo 'p /root/adrp-self:0x007e0' &gt; /sys/kernel/tracing/uprobe_events | # echo 1 &gt; /sys/kernel/tracing/events/uprobes/enable | # ./adrp-self | adrp_self =&gt; 0x4007e0 | adrp_self() =&gt; 0x4007e0 | IGUAL
References
  • () https://git.kernel.org/stable/c/b6a638cb600e13f94b5464724eaa6ab7f3349ca2 -
  • () https://git.kernel.org/stable/c/cf9ddf9ed94c15564a05bbf6e9f18dffa0c7df80 -
  • () https://git.kernel.org/stable/c/e6ab336213918575124d6db43dc5d3554526242e -

08 Nov 2024, 06:15

Type Values Removed Values Added
New CVE

Information

Published : 2024-11-08 06:15

Updated : 2024-11-29 19:33


NVD link : CVE-2024-50194

Mitre link : CVE-2024-50194

CVE.ORG link : CVE-2024-50194


JSON object : View

Products Affected

linux

  • linux_kernel