CVE-2024-40947

Severity CVSS v4.0:
Pending analysis
Type:
CWE-476 NULL Pointer Dereference
Publication date:
12/07/2024
Last modified:
03/11/2025

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> ima: Avoid blocking in RCU read-side critical section<br /> <br /> A panic happens in ima_match_policy:<br /> <br /> BUG: unable to handle kernel NULL pointer dereference at 0000000000000010<br /> PGD 42f873067 P4D 0<br /> Oops: 0000 [#1] SMP NOPTI<br /> CPU: 5 PID: 1286325 Comm: kubeletmonit.sh<br /> Kdump: loaded Tainted: P<br /> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),<br /> BIOS 0.0.0 02/06/2015<br /> RIP: 0010:ima_match_policy+0x84/0x450<br /> Code: 49 89 fc 41 89 cf 31 ed 89 44 24 14 eb 1c 44 39<br /> 7b 18 74 26 41 83 ff 05 74 20 48 8b 1b 48 3b 1d<br /> f2 b9 f4 00 0f 84 9c 01 00 00 85 73 10 74 ea<br /> 44 8b 6b 14 41 f6 c5 01 75 d4 41 f6 c5 02 74 0f<br /> RSP: 0018:ff71570009e07a80 EFLAGS: 00010207<br /> RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000200<br /> RDX: ffffffffad8dc7c0 RSI: 0000000024924925 RDI: ff3e27850dea2000<br /> RBP: 0000000000000000 R08: 0000000000000000 R09: ffffffffabfce739<br /> R10: ff3e27810cc42400 R11: 0000000000000000 R12: ff3e2781825ef970<br /> R13: 00000000ff3e2785 R14: 000000000000000c R15: 0000000000000001<br /> FS: 00007f5195b51740(0000)<br /> GS:ff3e278b12d40000(0000) knlGS:0000000000000000<br /> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033<br /> CR2: 0000000000000010 CR3: 0000000626d24002 CR4: 0000000000361ee0<br /> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000<br /> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400<br /> Call Trace:<br /> ima_get_action+0x22/0x30<br /> process_measurement+0xb0/0x830<br /> ? page_add_file_rmap+0x15/0x170<br /> ? alloc_set_pte+0x269/0x4c0<br /> ? prep_new_page+0x81/0x140<br /> ? simple_xattr_get+0x75/0xa0<br /> ? selinux_file_open+0x9d/0xf0<br /> ima_file_check+0x64/0x90<br /> path_openat+0x571/0x1720<br /> do_filp_open+0x9b/0x110<br /> ? page_counter_try_charge+0x57/0xc0<br /> ? files_cgroup_alloc_fd+0x38/0x60<br /> ? __alloc_fd+0xd4/0x250<br /> ? do_sys_open+0x1bd/0x250<br /> do_sys_open+0x1bd/0x250<br /> do_syscall_64+0x5d/0x1d0<br /> entry_SYSCALL_64_after_hwframe+0x65/0xca<br /> <br /> Commit c7423dbdbc9e ("ima: Handle -ESTALE returned by<br /> ima_filter_rule_match()") introduced call to ima_lsm_copy_rule within a<br /> RCU read-side critical section which contains kmalloc with GFP_KERNEL.<br /> This implies a possible sleep and violates limitations of RCU read-side<br /> critical sections on non-PREEMPT systems.<br /> <br /> Sleeping within RCU read-side critical section might cause<br /> synchronize_rcu() returning early and break RCU protection, allowing a<br /> UAF to happen.<br /> <br /> The root cause of this issue could be described as follows:<br /> | Thread A | Thread B |<br /> | |ima_match_policy |<br /> | | rcu_read_lock |<br /> |ima_lsm_update_rule | |<br /> | synchronize_rcu | |<br /> | | kmalloc(GFP_KERNEL)|<br /> | | sleep |<br /> ==&gt; synchronize_rcu returns early<br /> | kfree(entry) | |<br /> | | entry = entry-&gt;next|<br /> ==&gt; UAF happens and entry now becomes NULL (or could be anything).<br /> | | entry-&gt;action |<br /> ==&gt; Accessing entry might cause panic.<br /> <br /> To fix this issue, we are converting all kmalloc that is called within<br /> RCU read-side critical section to use GFP_ATOMIC.<br /> <br /> [PM: fixed missing comment, long lines, !CONFIG_IMA_LSM_RULES case]

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.4.229 (including) 5.5 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.10.163 (including) 5.10.222 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.15.86 (including) 5.15.163 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.0.16 (including) 6.1 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.1.2 (including) 6.1.98 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.2 (including) 6.6.39 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.7 (including) 6.9.7 (excluding)
cpe:2.3:o:linux:linux_kernel:6.10:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.10:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.10:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.10:rc4:*:*:*:*:*:*