Thanks for the link.
I was able to build a bootable Kext Collection as instructed in the post you referenced.
I was then able to boot into a KASAN instrumented kernel on my Apple Silicon machine.
On reproducing a kernel panic via a UAF I got the following symbolication, which I didn't find useful in identifying the source of a UAF in my KEXT.
% symbolicateKernelPanicBacktrace.sh ~/2025-09-24-114045.kernel.core.kasan.myfs.uninstrumented.log /System/Volumes/Data/Library/Developer/KDKs/KDK_12.5.1_21G83.kdk/System/Library/Kernels/kernel.kasan.t8101
ASCII text
panic(cpu 2 caller 0xfffffe0024926790): KASan: UaF of quarantined object 0xfffffe167506f880
handle_debugger_trap (in kernel.kasan.t8101) (debug.c:1431)
kdp_trap (in kernel.kasan.t8101) (kdp_machdep.c:363)
sleh_synchronous (in kernel.kasan.t8101) (sleh.c:854)
fleh_synchronous (in kernel.kasan.t8101) + 40
DebuggerTrapWithState (in kernel.kasan.t8101) (debug.c:662)
panic_trap_to_debugger (in kernel.kasan.t8101) (debug.c:1074)
Assert (in kernel.kasan.t8101) (debug.c:688)
ubsan_json_init.cold.1 (in kernel.kasan.t8101) (ubsan.c:0)
asan.module_ctor (in kernel.kasan.t8101) + 0
kasan_crash_report (in kernel.kasan.t8101) (kasan-report.c:136)
kasan_violation (in kernel.kasan.t8101) (kasan-report.c:0)
kasan_free_internal (in kernel.kasan.t8101) (kasan-classic.c:815)
kasan_free (in kernel.kasan.t8101) (kasan-classic.c:843)
kfree_zone (in kernel.kasan.t8101) (kalloc.c:2416)
kfree_ext (in kernel.kasan.t8101) (kalloc.c:0)
IOFree_internal (in kernel.kasan.t8101) (IOLib.cpp:360)
__asan_global_.str.102 (in kernel.kasan.t8101) + 8
nx_netif_na_txsync (in kernel.kasan.t8101) (nx_netif.c:1682)
netif_ring_tx_refill (in kernel.kasan.t8101) (nx_netif.c:4025)
nx_netif_na_txsync (in kernel.kasan.t8101) (nx_netif.c:1708)
netif_transmit (in kernel.kasan.t8101) (nx_netif.c:3770)
nx_netif_host_output (in kernel.kasan.t8101) (nx_netif_host.c:0)
dlil_output (in kernel.kasan.t8101) (dlil.c:6776)
ip_output_list (in kernel.kasan.t8101) (ip_output.c:1626)
tcp_ip_output (in kernel.kasan.t8101) (tcp_output.c:0)
tcp_output (in kernel.kasan.t8101) (tcp_output.c:2713)
tcp_input (in kernel.kasan.t8101) (tcp_input.c:0)
ip_proto_dispatch_in (in kernel.kasan.t8101) (ip_input.c:0)
ip_input (in kernel.kasan.t8101) (ip_input.c:0)
proto_input (in kernel.kasan.t8101) (kpi_protocol.c:0)
ether_inet_input (in kernel.kasan.t8101) (ether_inet_pr_module.c:221)
dlil_ifproto_input (in kernel.kasan.t8101) (dlil.c:5696)
dlil_input_packet_list_common (in kernel.kasan.t8101) (dlil.c:6121)
dlil_input_thread_cont (in kernel.kasan.t8101) (dlil.c:3169)
Call_continuation (in kernel.kasan.t8101) + 216
I also was able to instrument my KEXT as described in the Pishi project.
But the instrument_kext.py Ghidra script ended up garbling the LR register in my KC by overwriting the two most significant bytes of the address:
panic(cpu 7 caller 0xfffffe002d0984c0): Kernel data abort. at pc 0xfffffe002d46a9b0, lr 0xc8b2fe002d46a9ac (saved state: 0xfffffe3d227eed70)
x0: 0x0000000000447ed0 x1: 0xfffffe0030f6d1c0 x2: 0x0000000000000000 x3: 0xfffffe1017381410
x4: 0x00000000000000fd x5: 0x0000000000000000 x6: 0xfffffe002b81606c x7: 0xfffffe3d227ee980
x8: 0x0000000000000000 x9: 0x64627135a6d70010 x10: 0x0000000000000005 x11: 0xfffffe1014d87e40
x12: 0xfffffe1014d7c000 x13: 0x0000000000000000 x14: 0x0000000000000000 x15: 0x0000000000000008
x16: 0x0000020077cba83c x17: 0xfffffe0030259920 x18: 0x0000000000000000 x19: 0x0000000000000000
x20: 0xfffffe167f157890 x21: 0xfffffe167f15617c x22: 0x00000000e00002bd x23: 0x0000000000000000
x24: 0x000000000014b4dc x25: 0x0000000000000000 x26: 0xfffffe167e137840 x27: 0x0000000000000000
x28: 0x0000000000000000 fp: 0xfffffe3d227ef140 lr: 0xc8b2fe002d46a9ac sp: 0xfffffe3d227ef0c0
pc: 0xfffffe002d46a9b0 cpsr: 0x60401208 esr: 0x96000006 far: 0x0000000000000000
Debugger message: panic
Memory ID: 0x6
OS release type: User
OS version: 21G83
Kernel version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:18 PDT 2022; root:xnu_kasan-8020.141.5~2/KASAN_ARM64_T8101
This has just about exhausted my options in being able to locate the source of UAFs in my KEXT.
If you have any other practical advice to offer, it would be greatly appreciated.
How do kernel devs at Apple debug UAFs?
Topic:
App & System Services
SubTopic:
Core OS
Tags: