CVE-2025-21778 Information
Description
In the Linux kernel the following vulnerability has been resolved:
tracing: Do not allow mmap() of persistent ring buffer
When trying to mmap a trace instance buffer that is attached to reserve_mem it would crash:
BUG: unable to handle page fault for address: ffffe97bd00025c8
PF: supervisor read access in kernel mode
PF: error_code(0x0000) - not-present page
PGD 2862f3067 P4D 2862f3067 PUD 0
Oops: Oops: 0000 [1] PREEMPT_RT SMP PTI
CPU: 4 UID: 0 PID: 981 Comm: mmap-rb Not tainted 6.14.0-rc2-test-00003-g7f1a5e3fbf9e-dirty 233
Hardware name: QEMU Standard PC (Q35 + ICH9 2009) BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:validate_page_before_insert+0x5/0xb0
Code: e2 01 89 d0 c3 cc cc cc cc 66 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 <48> 8b 46 08 a8 01 75 67 66 90 48 89 f0 8b 50 34 85 d2 74 76 48 89
RSP: 0018:ffffb148c2f3f968 EFLAGS: 00010246
RAX: ffff9fa5d3322000 RBX: ffff9fa5ccff9c08 RCX: 00000000b879ed29
RDX: ffffe97bd00025c0 RSI: ffffe97bd00025c0 RDI: ffff9fa5ccff9c08
RBP: ffffb148c2f3f9f0 R08: 0000000000000004 R09: 0000000000000004
R10: 0000000000000000 R11: 0000000000000200 R12: 0000000000000000
R13: 00007f16a18d5000 R14: ffff9fa5c48db6a8 R15: 0000000000000000
FS: 00007f16a1b54740(0000) GS:ffff9fa73df00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffe97bd00025c8 CR3: 00000001048c6006 CR4: 0000000000172ef0
Call Trace:
The reason was that the code that maps the ring buffer pages to user space has:
page = virt_to_page((void )cpu_buffer->subbuf_ids[s]);
And uses that in:
vm_insert_pages(vma vma->vm_start pages &nr_pages);
But virt_to_page() does not work with vmap()’d memory which is what the persistent ring buffer has. It is rather trivial to allow this but for now just disable mmap() of instances that have their ring buffer from the reserve_mem option.
If an mmap() is performed on a persistent buffer it will return -ENODEV just like it would if the .mmap field wasn’t defined in the file_operations structure.
Reference
https://git.kernel.org/stable/c/129fe718819cc5e24ea2f489db9ccd4371f0c6f6 https://git.kernel.org/stable/c/cf5aa560e5c7628b57c928741d7e6a9a0f6f0e67 https://git.kernel.org/stable/c/e8dff5f73912513fc9b52ab992d861517c9a9975
Share on: