CVE-2024-50301

Source
https://nvd.nist.gov/vuln/detail/CVE-2024-50301
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2024-50301.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2024-50301
Downstream
Related
Published
2024-11-19T01:30:49.982Z
Modified
2025-11-28T02:34:15.034699Z
Severity
  • 7.1 (High) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H CVSS Calculator
Summary
security/keys: fix slab-out-of-bounds in key_task_permission
Details

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

security/keys: fix slab-out-of-bounds in keytaskpermission

KASAN reports an out of bounds read: BUG: KASAN: slab-out-of-bounds in _kuidval include/linux/uidgid.h:36 BUG: KASAN: slab-out-of-bounds in uideq include/linux/uidgid.h:63 [inline] BUG: KASAN: slab-out-of-bounds in keytask_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: _dumpstack lib/dumpstack.c:82 [inline] dumpstack+0x107/0x167 lib/dumpstack.c:123 printaddressdescription.constprop.0+0x19/0x170 mm/kasan/report.c:400 _kasanreport.cold+0x6c/0x84 mm/kasan/report.c:560 kasanreport+0x3a/0x50 mm/kasan/report.c:585 _kuidval include/linux/uidgid.h:36 [inline] uideq include/linux/uidgid.h:63 [inline] keytaskpermission+0x394/0x410 security/keys/permission.c:54 searchnested_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 searchnestedkeyrings function, when it iterates through the slots in a node(below tag ascendtonode), if the slot pointer is meta and node->backpointer != NULL(it means a root), it will proceed to descendtonode. 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 keyringptriskeyring function. However, KEYRINGPTRSUBTYPE is 0x2UL, the same as ASSOCARRAYPTRSUBTYPEMASK. 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 | +---+

  1. 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 descendtonode 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.]

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/50xxx/CVE-2024-50301.json"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
b2a4df200d570b2c33a57e1ebfa5896e4bc81b69
Fixed
c3ce634ad953ce48c75c39bdfd8b711dd95f346f
Fixed
4efb69a0e294ef201bcdf7ce3d6202cd0a545a5d
Fixed
1e4332581cd4eed75aea77af6f66cdcdda8b49b9
Fixed
199c20fb7499c79557a075dc24e9a7dae7d9f1ce
Fixed
bbad2d5b6c99db468d8f88b6ba6a56ed409b4881
Fixed
3e79ad156bedf2da0ab909a118d2cec6c9c22b79
Fixed
e0a317ad68e4ea48a0158187238c5407e4fdec8b
Fixed
4a74da044ec9ec8679e6beccc4306b936b62873f

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
3.13.0
Fixed
4.19.324
Type
ECOSYSTEM
Events
Introduced
4.20.0
Fixed
5.4.286
Type
ECOSYSTEM
Events
Introduced
5.5.0
Fixed
5.10.230
Type
ECOSYSTEM
Events
Introduced
5.11.0
Fixed
5.15.172
Type
ECOSYSTEM
Events
Introduced
5.16.0
Fixed
6.1.117
Type
ECOSYSTEM
Events
Introduced
6.2.0
Fixed
6.6.61
Type
ECOSYSTEM
Events
Introduced
6.7.0
Fixed
6.11.8