7.8high
security/keys: fix slab-out-of-bounds in key_task_permission
- Severity
- 7.8high CVSS:3.1 by Linux
- Exploit likelihood
- 0.28% (higher than 22% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- Linux
Description
In the Linux kernel, the following vulnerability has been resolved: security/keys: fix slab-out-of-bounds in key_task_permission KASAN reports an out of bounds read: BUG: KASAN: slab-out-of-bounds in __kuid_val include/linux/uidgid.h:36 BUG: KASAN: slab-out-of-bounds in uid_eq include/linux/uidgid.h:63 [inline] BUG: KASAN: slab-out-of-bounds in key_task_permission+0x394/0x410 security/keys/permission.c:54 Read of size 4 at addr ffff88813c3ab618 by task stress-ng/4362 CPU: 2 PID: 4362 Comm: stress-ng Not tainted 5.10.0-14930-gafbffd6c3ede #15 Call Trace: __dump_stack lib/dump_stack.c:82 [inline] dump_stack+0x107/0x167 lib/dump_stack.c:123 print_address_description.constprop.0+0x19/0x170 mm/kasan/report.c:400 __kasan_report.cold+0x6c/0x84 mm/kasan/report.c:560 kasan_report+0x3a/0x50 mm/kasan/report.c:585 __kuid_val include/linux/uidgid.h:36 [inline] uid_eq include/linux/uidgid.h:63 [inline] key_task_permission+0x394/0x410 security/keys/permission.c:54 search_nested_keyrings+0x90e/0xe90 security/keys/keyring.c:793 This issue was also reported by syzbot. It can be reproduced by following these steps(more details [1]): 1. Obtain more than 32 inputs that have similar hashes, which ends with the pattern '0xxxxxxxe6'. 2. Reboot and add the keys obtained in step 1. The reproducer demonstrates how this issue happened: 1. In the search_nested_keyrings function, when it iterates through the slots in a node(below tag ascend_to_node), if the slot pointer is meta and node->back_pointer != NULL(it means a root), it will proceed to descend_to_node. However, there is an exception. If node is the root, and one of the slots points to a shortcut, it will be treated as a keyring. 2. Whether the ptr is keyring decided by keyring_ptr_is_keyring function. However, KEYRING_PTR_SUBTYPE is 0x2UL, the same as ASSOC_ARRAY_PTR_SUBTYPE_MASK. 3. When 32 keys with the similar hashes are added to the tree, the ROOT has keys with hashes that are not similar (e.g. slot 0) and it splits NODE A without using a shortcut. When NODE A is filled with keys that all hashes are xxe6, the keys are similar, NODE A will split with a shortcut. Finally, it forms the tree as shown below, where slot 6 points to a shortcut. NODE A +------>+---+ ROOT | | 0 | xxe6 +---+ | +---+ xxxx | 0 | shortcut : : xxe6 +---+ | +---+ xxe6 : : | | | xxe6 +---+ | +---+ | 6 |---+ : : xxe6 +---+ +---+ xxe6 : : | f | xxe6 +---+ +---+ xxe6 | f | +---+ 4. As mentioned above, If a slot(slot 6) of the root points to a shortcut, it may be mistakenly transferred to a key*, leading to a read out-of-bounds read. To fix this issue, one should jump to descend_to_node if the ptr is a shortcut, regardless of whether the node is root or not. [1] https://lore.kernel.org/linux-kernel/1cfa878e-8c7b-4570-8606-21daf5e13ce7@huaweicloud.com/ [jarkko: tweaked the commit message a bit to have an appropriate closes tag.]
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Linux Linux | from b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 before c3ce634ad953ce48c75c39bdfd8b711dd95f346f, from b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 before 4efb69a0e294ef201bcdf7ce3d6202cd0a545a5d, from b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 before 1e4332581cd4eed75aea77af6f66cdcdda8b49b9, from b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 before 199c20fb7499c79557a075dc24e9a7dae7d9f1ce, from b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 before bbad2d5b6c99db468d8f88b6ba6a56ed409b4881, from b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 before 3e79ad156bedf2da0ab909a118d2cec6c9c22b79, from b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 before e0a317ad68e4ea48a0158187238c5407e4fdec8b, from b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 before 4a74da044ec9ec8679e6beccc4306b936b62873f and 1 more Not affected: before 3.13, from 4.19.324 up to 4.19.*, from 5.4.286 up to 5.4.*, from 5.10.230 up to 5.10.*, from 5.15.172 up to 5.15.*, from 6.1.117 up to 6.1.* | CVE List |
| linux linux_kernel | from 3.13 before 4.19.324, from 4.20 before 5.4.286, from 5.5 before 5.10.230, from 5.11 before 5.15.172, from 5.16 before 6.1.117, from 6.2 before 6.6.61, from 6.7 before 6.11.8, 6.12 | NVD |
All scores
| Linux | 7.8high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H |
| CISA-ADP | 7.1high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H |
| NVD | 7.1high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
In the Linux kernel, the following vulnerability has been resolved: security/keys: fix slab-out-of-bounds in key_task_permission KASAN reports an out of bounds read: BUG: KASAN: slab-out-of-bounds in __kuid_val include/linux/uidgid.h:36 BUG: KASAN: slab-out-of-bounds in uid_eq include/linux/uidgid.h:63 [inline] BUG: KASAN: slab-out-of-bounds in key_task_permission+0x394/0x410 security/keys/permission.c:54 Read of size 4 at addr ffff88813c3ab618 by task stress-ng/4362 CPU: 2 PID: 4362 Comm: stress-ng Not tainted 5.10.0-14930-gafbffd6c3ede #15 Call Trace: __dump_stack lib/dump_stack.c:82 [inline] dump_stack+0x107/0x167 lib/dump_stack.c:123 print_address_description.constprop.0+0x19/0x170 mm/kasan/report.c:400 __kasan_report.cold+0x6c/0x84 mm/kasan/report.c:560 kasan_report+0x3a/0x50 mm/kasan/report.c:585 __kuid_val include/linux/uidgid.h:36 [inline] uid_eq include/linux/uidgid.h:63 [inline] key_task_permission+0x394/0x410 security/keys/permission.c:54 search_nested_keyrings+0x90e/0xe90 security/keys/keyring.c:793 This issue was also reported by syzbot. It can be reproduced by following these steps(more details [1]): 1. Obtain more than 32 inputs that have similar hashes, which ends with the pattern '0xxxxxxxe6'. 2. Reboot and add the keys obtained in step 1. The reproducer demonstrates how this issue happened: 1. In the search_nested_keyrings function, when it iterates through the slots in a node(below tag ascend_to_node), if the slot pointer is meta and node->back_pointer != NULL(it means a root), it will proceed to descend_to_node. However, there is an exception. If node is the root, and one of the slots points to a shortcut, it will be treated as a keyring. 2. Whether the ptr is keyring decided by keyring_ptr_is_keyring function. However, KEYRING_PTR_SUBTYPE is 0x2UL, the same as ASSOC_ARRAY_PTR_SUBTYPE_MASK. 3. When 32 keys with the similar hashes are added to the tree, the ROOT has keys with hashes that are not similar (e.g. slot 0) and it splits NODE A without using a shortcut. When NODE A is filled with keys that all hashes are xxe6, the keys are similar, NODE A will split with a shortcut. Finally, it forms the tree as shown below, where slot 6 points to a shortcut. NODE A +------>+---+ ROOT | | 0 | xxe6 +---+ | +---+ xxxx | 0 | shortcut : : xxe6 +---+ | +---+ xxe6 : : | | | xxe6 +---+ | +---+ | 6 |---+ : : xxe6 +---+ +---+ xxe6 : : | f | xxe6 +---+ +---+ xxe6 | f | +---+ 4. As mentioned above, If a slot(slot 6) of the root points to a shortcut, it may be mistakenly transferred to a key*, leading to a read out-of-bounds read. To fix this issue, one should jump to descend_to_node if the ptr is a shortcut, regardless of whether the node is root or not. [1] https://lore.kernel.org/linux-kernel/1cfa878e-8c7b-4570-8606-21daf5e13ce7@huaweicloud.com/ [jarkko: tweaked the commit message a bit to have an appropriate closes tag.]
NVD (es)
En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: security/keys: corrección de slab-out-of-bounds en key_task_permission KASAN informa una lectura fuera de los límites: ERROR: KASAN: slab-out-of-bounds en __kuid_val include/linux/uidgid.h:36 ERROR: KASAN: slab-out-of-bounds en uid_eq include/linux/uidgid.h:63 [en línea] ERROR: KASAN: slab-out-of-bounds en key_task_permission+0x394/0x410 security/keys/permission.c:54 Lectura de tamaño 4 en la dirección ffff88813c3ab618 por la tarea stress-ng/4362 CPU: 2 PID: 4362 Comm: stress-ng No contaminado 5.10.0-14930-gafbffd6c3ede #15 Seguimiento de llamadas: __dump_stack lib/dump_stack.c:82 [en línea] dump_stack+0x107/0x167 lib/dump_stack.c:123 print_address_description.constprop.0+0x19/0x170 mm/kasan/report.c:400 __kasan_report.cold+0x6c/0x84 mm/kasan/report.c:560 kasan_report+0x3a/0x50 mm/kasan/report.c:585 __kuid_val include/linux/uidgid.h:36 [en línea] uid_eq include/linux/uidgid.h:63 [en línea] key_task_permission+0x394/0x410 security/keys/permission.c:54 search_nested_keyrings+0x90e/0xe90 security/keys/keyring.c:793 Este problema también fue informado por syzbot. Puede reproducirse siguiendo estos pasos (más detalles [1]): 1. Obtenga más de 32 entradas que tengan hashes similares, que terminen con el patrón '0xxxxxxxe6'. 2. Reinicie y agregue las claves obtenidas en el paso 1. El reproductor demuestra cómo sucedió este problema: 1. En la función search_nested_keyrings, cuando itera a través de las ranuras en un nodo (debajo de la etiqueta ascend_to_node), si el puntero de la ranura es meta y node->back_pointer != NULL (significa una raíz), procederá a descend_to_node. Sin embargo, hay una excepción. Si el nodo es la raíz y una de las ranuras apunta a un acceso directo, se tratará como un llavero. 2. Si el ptr es un llavero lo decide la función keyring_ptr_is_keyring. Sin embargo, KEYRING_PTR_SUBTYPE es 0x2UL, lo mismo que ASSOC_ARRAY_PTR_SUBTYPE_MASK. 3. Cuando se agregan 32 claves con hashes similares al árbol, la RAÍZ tiene claves con hashes que no son similares (por ejemplo, la ranura 0) y divide el NODO A sin usar un acceso directo. Cuando el NODO A se llena con claves en las que todos los hashes son xxe6, las claves son similares, el NODO A se dividirá con un acceso directo. Finalmente, forma el árbol como se muestra a continuación, donde la ranura 6 apunta a un acceso directo. NODO A +------>+---+ RAÍZ | | 0 | xxe6 +---+ | +---+ xxxx | 0 | acceso directo : : xxe6 +---+ | +---+ xxe6 : : | | | xxe6 +---+ | +---+ | 6 |---+ : : xxe6 +---+ +---+ xxe6 : : | f | xxe6 +---+ +---+ xxe6 | f | +---+ 4. Como se mencionó anteriormente, si una ranura (ranura 6) de la raíz apunta a un acceso directo, puede transferirse por error a una clave*, lo que lleva a una lectura fuera de los límites. Para solucionar este problema, uno debe saltar a descend_to_node si el ptr es un acceso directo, independientemente de si el nodo es raíz o no. [1] https://lore.kernel.org/linux-kernel/1cfa878e-8c7b-4570-8606-21daf5e13ce7@huaweicloud.com/ [jarkko: modifiqué un poco el mensaje de confirmación para tener una etiqueta de cierre apropiada].
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-50301 changed 2026-10-15 | CVE Terms of Use |
| NVD | CVE-2024-50301 changed 2026-10-15 | Public domain |