Skip to content

CVE-2025-21866 powerpc/code-patching: Fix KASAN hit by not flagging text patching area as VM_ALLOC

MediumCVSS 5.5 EPSS 0.29%
Published
Updated
Exploit status
No public exploit known
CISA SSVC
No known exploitation · automatable: no · technical impact: partial
Technology
Linux KernelUbuntuDebian

Description

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

powerpc/code-patching: Fix KASAN hit by not flagging text patching area as VM_ALLOC

Erhard reported the following KASAN hit while booting his PowerMac G4
with a KASAN-enabled kernel 6.13-rc6:

BUG: KASAN: vmalloc-out-of-bounds in copy_to_kernel_nofault+0xd8/0x1c8
Write of size 8 at addr f1000000 by task chronyd/1293

CPU: 0 UID: 123 PID: 1293 Comm: chronyd Tainted: G W 6.13.0-rc6-PMacG4 #2
Tainted: [W]=WARN
Hardware name: PowerMac3,6 7455 0x80010303 PowerMac
Call Trace:
[c2437590] [c1631a84] dump_stack_lvl+0x70/0x8c (unreliable)
[c24375b0] [c0504998] print_report+0xdc/0x504
[c2437610] [c050475c] kasan_report+0xf8/0x108
[c2437690] [c0505a3c] kasan_check_range+0x24/0x18c
[c24376a0] [c03fb5e4] copy_to_kernel_nofault+0xd8/0x1c8
[c24376c0] [c004c014] patch_instructions+0x15c/0x16c
[c2437710] [c00731a8] bpf_arch_text_copy+0x60/0x7c
[c2437730] [c0281168] bpf_jit_binary_pack_finalize+0x50/0xac
[c2437750] [c0073cf4] bpf_int_jit_compile+0xb30/0xdec
[c2437880] [c0280394] bpf_prog_select_runtime+0x15c/0x478
[c24378d0] [c1263428] bpf_prepare_filter+0xbf8/0xc14
[c2437990] [c12677ec] bpf_prog_create_from_user+0x258/0x2b4
[c24379d0] [c027111c] do_seccomp+0x3dc/0x1890
[c2437ac0] [c001d8e0] system_call_exception+0x2dc/0x420
[c2437f30] [c00281ac] ret_from_syscall+0x0/0x2c
--- interrupt: c00 at 0x5a1274
NIP: 005a1274 LR: 006a3b3c CTR: 005296c8
REGS: c2437f40 TRAP: 0c00 Tainted: G W (6.13.0-rc6-PMacG4)
MSR: 0200f932 <VEC,EE,PR,FP,ME,IR,DR,RI> CR: 24004422 XER: 00000000

GPR00: 00000166 af8f3fa0 a7ee3540 00000001 00000000 013b6500 005a5858 0200f932
GPR08: 00000000 00001fe9 013d5fc8 005296c8 2822244c 00b2fcd8 00000000 af8f4b57
GPR16: 00000000 00000001 00000000 00000000 00000000 00000001 00000000 00000002
GPR24: 00afdbb0 00000000 00000000 00000000 006e0004 013ce060 006e7c1c 00000001
NIP [005a1274] 0x5a1274
LR [006a3b3c] 0x6a3b3c
--- interrupt: c00

The buggy address belongs to the virtual mapping at
[f1000000, f1002000) created by:
text_area_cpu_up+0x20/0x190

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:00000000 index:0x0 pfn:0x76e30
flags: 0x80000000(zone=2)
raw: 80000000 00000000 00000122 00000000 00000000 00000000 ffffffff 00000001
raw: 00000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
f0ffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
f0ffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

f1000000: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
f1000080: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f1000100: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================

f8 corresponds to KASAN_VMALLOC_INVALID which means the area is not
initialised hence not supposed to be used yet.

Powerpc text patching infrastructure allocates a virtual memory area
using get_vm_area() and flags it as VM_ALLOC. But that flag is meant
to be used for vmalloc() and vmalloc() allocated memory is not
supposed to be used before a call to __vmalloc_node_range() which is
never called for that area.

That went undetected until commit e4137f08816b ("mm, kasan, kmsan:
instrument copy_from/to_kernel_nofault")

The area allocated by text_area_cpu_up() is not vmalloc memory, it is
mapped directly on demand when needed by map_kernel_page(). There is
no VM flag corresponding to such usage, so just pass no flag. That way
the area will be unpoisonned and usable immediately.

Upgrade path

11 packages: 10 fixed, 1 with no fix yet.

PackageAffectedFixed inStatus
cbl-mariner kernel(CBL-Mariner 2.0) All versions No fix listed No fix yet
azure linux kernel(Azure Linux 3.0) < 6.6.82.1-1 6.6.82.1-1 Fixed
debian/linux(Debian 12) < 6.1.133-1; = 6.1.27-1; = 6.1.37-1; = 6.1.38-1 +33 more 6.1.133-1 Fixed
debian/linux(Debian 13) < 6.12.17-1 6.12.17-1 Fixed
debian/linux(Debian 14) < 6.12.17-1 6.12.17-1 Fixed
Linux kernel < 5.4.291; < 5.10.235; < 5.15.179; < 6.1.130 +20 more 2d542f13d26344e3452eee77613026ce9b653065, 2e6c80423f201405fd65254e52decd21663896f3, 5.4.291, 5.10.235, 5.15.179, 6.1.130, 6.6.80, 6.12.17, 6.13.5, 6.14, 8d06e9208184b2851fa79a3a39d6860320c8bdf8, 97de5852058a299ba447cd9782fe96488d30108b, 6847b3e40bb963e57b61d1cc6fe84cb37b9d3d4c, c905a3053518212a1017e50bd2be3bee59305bb0, d262a192d38e527faa5984629aabda2e0d1c4f54, f8d4c5b653c1bc0df56e15658bbf64fc359adc4e Fixed
ubuntu/linux(Ubuntu 22.04) < 5.15.0-140.150 5.15.0-140.150 Fixed
ubuntu/linux(Ubuntu 24.04) < 6.8.0-78.78 6.8.0-78.78 Fixed
ubuntu/linux-kvm(Ubuntu 22.04) < 5.15.0-1080.85 5.15.0-1080.85 Fixed
ubuntu/linux-raspi(Ubuntu 22.04) < 5.15.0-1078.81 5.15.0-1078.81 Fixed
ubuntu/linux-raspi(Ubuntu 24.04) < 6.8.0-1035.39 6.8.0-1035.39 Fixed

Affected products

ProductAffected versionsFixed in
cbl-mariner kernel(CBL-Mariner:2.0) All versions No fix listed
azure linux kernel(Azure Linux:3.0) < 6.6.82.1-1 6.6.82.1-1
debian/linux(Debian:12) < 6.1.133-1 6.1.133-1
debian/linux(Debian:12) = 6.1.106-1 No fix listed
debian/linux(Debian:12) = 6.1.106-2 No fix listed
debian/linux(Debian:12) = 6.1.106-3 No fix listed
debian/linux(Debian:12) = 6.1.112-1 No fix listed
debian/linux(Debian:12) = 6.1.115-1 No fix listed
debian/linux(Debian:12) = 6.1.119-1 No fix listed
debian/linux(Debian:12) = 6.1.123-1 No fix listed
debian/linux(Debian:12) = 6.1.124-1 No fix listed
debian/linux(Debian:12) = 6.1.128-1 No fix listed
debian/linux(Debian:12) = 6.1.129-1 No fix listed
debian/linux(Debian:12) = 6.1.27-1 No fix listed
debian/linux(Debian:12) = 6.1.37-1 No fix listed
debian/linux(Debian:12) = 6.1.38-1 No fix listed
debian/linux(Debian:12) = 6.1.38-2 No fix listed
debian/linux(Debian:12) = 6.1.38-2~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.38-3 No fix listed
debian/linux(Debian:12) = 6.1.38-4 No fix listed
debian/linux(Debian:12) = 6.1.38-4~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.52-1 No fix listed
debian/linux(Debian:12) = 6.1.55-1 No fix listed
debian/linux(Debian:12) = 6.1.55-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.64-1 No fix listed
Show 45 more
ProductAffected versionsFixed in
debian/linux(Debian:12) = 6.1.66-1 No fix listed
debian/linux(Debian:12) = 6.1.67-1 No fix listed
debian/linux(Debian:12) = 6.1.69-1 No fix listed
debian/linux(Debian:12) = 6.1.69-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.76-1 No fix listed
debian/linux(Debian:12) = 6.1.76-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.82-1 No fix listed
debian/linux(Debian:12) = 6.1.85-1 No fix listed
debian/linux(Debian:12) = 6.1.90-1 No fix listed
debian/linux(Debian:12) = 6.1.90-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.94-1 No fix listed
debian/linux(Debian:12) = 6.1.94-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.98-1 No fix listed
debian/linux(Debian:12) = 6.1.99-1 No fix listed
debian/linux(Debian:13) < 6.12.17-1 6.12.17-1
debian/linux(Debian:14) < 6.12.17-1 6.12.17-1
Linux kernel >= 37bc3e5fd764fb258ff4fcbb90b6d1b67fb466c1, < 97de5852058a299ba447cd9782fe96488d30108b 97de5852058a299ba447cd9782fe96488d30108b
Linux kernel >= 37bc3e5fd764fb258ff4fcbb90b6d1b67fb466c1, < f8d4c5b653c1bc0df56e15658bbf64fc359adc4e f8d4c5b653c1bc0df56e15658bbf64fc359adc4e
Linux kernel >= 37bc3e5fd764fb258ff4fcbb90b6d1b67fb466c1, < 6847b3e40bb963e57b61d1cc6fe84cb37b9d3d4c 6847b3e40bb963e57b61d1cc6fe84cb37b9d3d4c
Linux kernel >= 37bc3e5fd764fb258ff4fcbb90b6d1b67fb466c1, < c905a3053518212a1017e50bd2be3bee59305bb0 c905a3053518212a1017e50bd2be3bee59305bb0
Linux kernel >= 37bc3e5fd764fb258ff4fcbb90b6d1b67fb466c1, < 2d542f13d26344e3452eee77613026ce9b653065 2d542f13d26344e3452eee77613026ce9b653065
Linux kernel >= 37bc3e5fd764fb258ff4fcbb90b6d1b67fb466c1, < 8d06e9208184b2851fa79a3a39d6860320c8bdf8 8d06e9208184b2851fa79a3a39d6860320c8bdf8
Linux kernel >= 37bc3e5fd764fb258ff4fcbb90b6d1b67fb466c1, < 2e6c80423f201405fd65254e52decd21663896f3 2e6c80423f201405fd65254e52decd21663896f3
Linux kernel >= 37bc3e5fd764fb258ff4fcbb90b6d1b67fb466c1, < d262a192d38e527faa5984629aabda2e0d1c4f54 d262a192d38e527faa5984629aabda2e0d1c4f54
Linux kernel = 4.13 No fix listed
Linux kernel < 5.4.291 5.4.291
Linux kernel < 5.10.235 5.10.235
Linux kernel < 5.15.179 5.15.179
Linux kernel < 6.1.130 6.1.130
Linux kernel < 6.6.80 6.6.80
Linux kernel < 6.12.17 6.12.17
Linux kernel < 6.13.5 6.13.5
Linux kernel < 6.14 6.14
ubuntu/linux(Ubuntu:22.04) < 5.15.0-140.150 5.15.0-140.150
ubuntu/linux-kvm(Ubuntu:22.04) < 5.15.0-1080.85 5.15.0-1080.85
ubuntu/linux-raspi(Ubuntu:22.04) < 5.15.0-1078.81 5.15.0-1078.81
ubuntu/linux(Ubuntu:24.04) < 6.8.0-78.78 6.8.0-78.78
ubuntu/linux-raspi(Ubuntu:24.04) < 6.8.0-1035.39 6.8.0-1035.39
Linux kernel >= 4.13, < 6.1.130 6.1.130
Linux kernel >= 6.2, < 6.6.80 6.6.80
Linux kernel >= 6.7, < 6.12.17 6.12.17
Linux kernel >= 6.13, < 6.13.5 6.13.5
Linux kernel = 6.14-rc1 No fix listed
Linux kernel = 6.14-rc2 No fix listed
Linux kernel = 6.14-rc3 No fix listed

References