Questions tagged [xnu]

xnu is the name of the operating system kernel that underpins Mac OS X/darwin and iOS.

xnu is the name of the operating system kernel that underpins Darwin, which in turn is the core of Apple's macOS (formerly OS X and Mac OS X), iOS/iPadOS (formerly iPhoneOS), tvOS, and watchOS operating systems. It has its origins in the NeXTStep operating system, and is a combination of parts of the Mach kernel (mainly the virtual memory subsystem and inter-process communication via Mach "ports"), the 4.3BSD kernel (networking, process management, POSIX compatibility, VFS/file system layer) and a device driver subsystem called the I/O Kit, which was developed in C++ specifically for the xnu kernel.

147 questions
2
votes
1 answer

How to boot XNU kernel?

I have compiled XNU 3789.31.2 from source successfully but don't know how to boot it and get it run. Is there any detailed instruction for that?
Breeza
  • 21
  • 2
2
votes
0 answers

catch SIGKILL in MacOS driver

I'm currently debugging my daemon that supposedly die due to SIGKILL. I'd like to catch that signal that is intended for my process and add a printout that this process got . I'm aware that SIGKILL cannot be caught in process level signal handler,…
user7256215
2
votes
1 answer

setjmp/longjmp in XNU/Darwin Kernel

I need longjmp/setjmp in a .kext file for OS X. Unfortunately, I don't think there's any official support for these functions in XNU. Is there any fundamental reason why this cannot work or is it just not implemented right now? Any ideas how I could…
Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
2
votes
1 answer

Change vm page protection attributes from XNU kernel driver

As a part of an experiment i need to make a read-only page writable in kernel address space from a non-IOKit kext. In user mode i can do vm_protect, but there is surprisingly little info on how this can be done in kernel mode (or i am completely…
Inso Reiges
  • 1,889
  • 3
  • 17
  • 30
2
votes
0 answers

How to get cpu usage in the mach kernel?

I try get cpu usages in mach kernel but i always get the same output. What i do wrong? static mach_port_t port; Get cpu load statistics int load_get(host_info_t r_load) { mach_msg_type_number_t count; count = HOST_CPU_LOAD_INFO_COUNT; …
Kfur
  • 21
  • 1
2
votes
2 answers

load kernel extension through C API?

Is it possible to load a kernel extension (kext) through a C API instead of using the system() call?
mrdvlpr
  • 526
  • 4
  • 20
2
votes
1 answer

Virtual SCSI disk device driver on OS X causes panics on when device formatted using HFS+ only

I’m currently developing a virtual SCSI device driver using IOKit. My driver loads fine and I’m able to format my device using ExFat, FAT32 or HFS+. I am also able to copy files to and from my virtual device using a CLI with any of these file…
user3814483
  • 292
  • 1
  • 2
  • 13
2
votes
1 answer

Osx kernel crash inside ctl_enqueuedata

My code is using ctl_enqueuedata for kernel-user communication. I notice that SOMETIMES (I cannot really reproduce it) - I got crash inside of ctl_enqueuedata When I connect using debugger, the backtrace is the following frame #0: 0xffffff80248bcecb…
Georgy Buranov
  • 1,296
  • 1
  • 16
  • 26
2
votes
1 answer

XNU incudes in Kext

I'm working on Kext which should have access to struct proc->p_pid field. The problem is the structure is defined in XNU sources only, so I faced incomplete definition of type 'struct proc' error during compilation. From my point of view, to include…
2
votes
1 answer

Mac OS X: recvmsg returns EMSGSIZE when sending fd's via Unix domain datagram socket

I have a piece of code that uses Unix domain sockets and sendmsg/recvmsg to send fd's between two processes. This code needs to run on both Linux and Mac (it is complied separately for both platforms). I'm using SOCK_DGRAM (datagram) sockets. I send…
Mayank
  • 1,236
  • 1
  • 12
  • 22
2
votes
1 answer

How to determine if process has root privileges in a network kernel extension?

I'm writing a socket filter kext and I would want to ignore any connections made as root. Before OS X Lion, the following code worked flawlessly: static boolean_t is_root() { proc_t p = proc_self(); boolean_t isRoot = proc_suser(p); …
jjs
  • 1,338
  • 7
  • 19
2
votes
1 answer

Where is vnode_t defined?

I'm trying to use a vnode_t which is defined as struct vnode *. I can find plenty of references to struct vnode but I cannot find the header in which is defined. Can anyone help?
Joe
  • 46,419
  • 33
  • 155
  • 245
1
vote
1 answer

On AArch64, how does SCTLR_EL1.SPAN=0 work when a translation fault occurs while PSTATE.PAN=1?

For example, the XNU kernel has the copyin()/copyout() functions to copy data from user-space to kernel-space and vice versa. Since these functions need to access user-space, they disable PAN by setting PSTATE.PAN to 0. However, if SCTLR_EL1.SPAN is…
1
vote
0 answers

How to use `proc_pid_rusage` result in Swift using UnsafeMutablePointer?

I tried this code to get result from proc_pid_rusage: import Foundation let p1 = UnsafeMutablePointer.allocate(capacity: 1) let spid = ProcessInfo.processInfo.processIdentifier let status = proc_pid_rusage(spid, 0, p1) if status ==…
egor10_4
  • 331
  • 2
  • 9
1
vote
0 answers

How to properly include C header file in macOS Swift Xcode project for `proc_selfpid` function?

I have a simple project with code: import Foundation let p1 = UnsafeMutablePointer.allocate(capacity: 1) let spid = proc_selfpid() let s = proc_pid_rusage(579, 0, p1) if s == KERN_SUCCESS { // ... } print("Status…
egor10_4
  • 331
  • 2
  • 9