{"id":"DEBIAN-CVE-2024-40915","details":"In the Linux kernel, the following vulnerability has been resolved:  riscv: rewrite __kernel_map_pages() to fix sleeping in invalid context  __kernel_map_pages() is a debug function which clears the valid bit in page table entry for deallocated pages to detect illegal memory accesses to freed pages.  This function set/clear the valid bit using __set_memory(). __set_memory() acquires init_mm's semaphore, and this operation may sleep. This is problematic, because  __kernel_map_pages() can be called in atomic context, and thus is illegal to sleep. An example warning that this causes:  BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1578 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 2, name: kthreadd preempt_count: 2, expected: 0 CPU: 0 PID: 2 Comm: kthreadd Not tainted 6.9.0-g1d4c6d784ef6 #37 Hardware name: riscv-virtio,qemu (DT) Call Trace: [\u003cffffffff800060dc\u003e] dump_backtrace+0x1c/0x24 [\u003cffffffff8091ef6e\u003e] show_stack+0x2c/0x38 [\u003cffffffff8092baf8\u003e] dump_stack_lvl+0x5a/0x72 [\u003cffffffff8092bb24\u003e] dump_stack+0x14/0x1c [\u003cffffffff8003b7ac\u003e] __might_resched+0x104/0x10e [\u003cffffffff8003b7f4\u003e] __might_sleep+0x3e/0x62 [\u003cffffffff8093276a\u003e] down_write+0x20/0x72 [\u003cffffffff8000cf00\u003e] __set_memory+0x82/0x2fa [\u003cffffffff8000d324\u003e] __kernel_map_pages+0x5a/0xd4 [\u003cffffffff80196cca\u003e] __alloc_pages_bulk+0x3b2/0x43a [\u003cffffffff8018ee82\u003e] __vmalloc_node_range+0x196/0x6ba [\u003cffffffff80011904\u003e] copy_process+0x72c/0x17ec [\u003cffffffff80012ab4\u003e] kernel_clone+0x60/0x2fe [\u003cffffffff80012f62\u003e] kernel_thread+0x82/0xa0 [\u003cffffffff8003552c\u003e] kthreadd+0x14a/0x1be [\u003cffffffff809357de\u003e] ret_from_fork+0xe/0x1c  Rewrite this function with apply_to_existing_page_range(). It is fine to not have any locking, because __kernel_map_pages() works with pages being allocated/deallocated and those pages are not changed by anyone else in the meantime.","modified":"2026-09-15T09:03:09.480716030Z","published":"2024-07-12T13:15:14.660Z","upstream":["CVE-2024-40915"],"references":[{"type":"ADVISORY","url":"https://security-tracker.debian.org/tracker/CVE-2024-40915"}],"affected":[{"package":{"name":"linux","ecosystem":"Debian:12","purl":"pkg:deb/debian/linux?arch=source&distro=bookworm"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"6.1.99-1"}]}],"versions":["6.1.27-1","6.1.37-1","6.1.38-1","6.1.38-2","6.1.38-2~bpo11+1","6.1.38-3","6.1.38-4","6.1.38-4~bpo11+1","6.1.52-1","6.1.55-1","6.1.55-1~bpo11+1","6.1.64-1","6.1.66-1","6.1.67-1","6.1.69-1","6.1.69-1~bpo11+1","6.1.76-1","6.1.76-1~bpo11+1","6.1.82-1","6.1.85-1","6.1.90-1","6.1.90-1~bpo11+1","6.1.94-1","6.1.94-1~bpo11+1","6.1.98-1"],"ecosystem_specific":{"urgency":"not yet assigned"},"database_specific":{"source":"https://storage.googleapis.com/osv-test-debian-osv/debian-cve-osv/DEBIAN-CVE-2024-40915.json"}},{"package":{"name":"linux","ecosystem":"Debian:13","purl":"pkg:deb/debian/linux?arch=source&distro=trixie"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"6.9.7-1"}]}],"ecosystem_specific":{"urgency":"not yet assigned"},"database_specific":{"source":"https://storage.googleapis.com/osv-test-debian-osv/debian-cve-osv/DEBIAN-CVE-2024-40915.json"}},{"package":{"name":"linux","ecosystem":"Debian:14","purl":"pkg:deb/debian/linux?arch=source&distro=forky"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"6.9.7-1"}]}],"ecosystem_specific":{"urgency":"not yet assigned"},"database_specific":{"source":"https://storage.googleapis.com/osv-test-debian-osv/debian-cve-osv/DEBIAN-CVE-2024-40915.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H"}]}